Committing a checkout as a different user?

John Arbash Meinel john at arbash-meinel.com
Tue Nov 20 20:11:22 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Iwan Vosloo wrote:
> Hi there,
> 
> We use bzr for configuration of machines. We have a branch with config
> in it, accessable vie bzr+ssh.
> 
> We then make a checkout of this branch on the machine being configured
> (say in /etc). But of course that must be done as root. Commits must
> also be done as root, since there are files in /etc that only root is
> allowed to see.
> 
> Now, it would be nice if we could commit as user A when user A changed
> some config and checks it in... But user B must be listed as having
> committed if he does it.
> 
> But now we have a checkout, which remembers (using the bzr+ssh url) the
> branch location and user name as whom it was originally checked out. So
> we can only ever commit (and thus do the automatic push) as the user who
> originally checked it out.
> 
> Is there a way you can specify as which user the bzr+ssh must happen for
> "bzr commit" or (less important) "bzr update"?
> (It's nice that the rest of the branch URL stays the same, ideally we
> don't want to lose that.)
> 
> - Iwan

You can do it with an environment variable.

BZR_EMAIL="My User <this at is.me>" bzr commit -m "My changes"

or you can use:

bzr commit --author=XXX

which will write the committer as 'root' but set an "author" field. Which in
"bzr log --long" will show both, and in "bzr log --short" will show the Author
rather than the committer.

The idea with --author is generally when merging other people's patches. So
whether it fits for your case is up to you.

I don't know how you switch to root. But I think if you did something like:

~user/.bashrc
  BZR_EMAIL="User"

% su root # Note this is not 'su - root'
# echo $BZR_EMAIL
User

I actually use
% sudo su root
# echo $BZR_EMAIL
User

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHQz9pJdeBCYSNAAMRAvj9AJ4mYLiZM4Ej1eMAHr3kyMXwBaWAQQCeLIat
ib4xbt2bJTHgsuXIChiBxaI=
=UHUw
-----END PGP SIGNATURE-----




More information about the bazaar mailing list