git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH] Use SUDO_UID to guess committer identity

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 8, 2008, 00:57 UTC
Message-ID
<7vprqsn3pj.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20080608002343.GG12896@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> writes:
Show 16 quoted lines
> Junio C Hamano <gitster@pobox.com> wrote:
>> "Shawn O. Pearce" <spearce@spearce.org> writes:
>> 
>> > When invoking Git commands though sudo against a bare repository
>> > with reflogs enabled we should attempt to record the actual user's
>> > information in the reflog, not the identity of the user sudo entered.
>> >
>> > For example when executing:
>> >
>> > 	sudo -u gitadm git --git-dir=/srv/git.git branch -f pu master
>> >
>> > We want record information about the caller of sudo, not gitadm.
> ...
> The issue is when users run commands though sudo, but forget to set a
> value for GIT_COMMITTER_NAME/EMAIL, or to configure ~/.gitconfig in
> their personal account.

In your scenario, is the above "sudo -u gitadm" the exact command line the end users type, or is it wrapped in the script you give to them?

Show 5 quoted lines
> Eh, I'm myself not entirely happy with the patch.  It honors the
> real user's $HOME/.gitconfig user.name/email settings and not the
> SUDO_UID data.  I'd almost prefer favoring SUDO_UID over whatever
> we inherit in from the enviroment or from $HOME/.gitconfig when it
> comes to committer identity.

The thing is, I personally hate pseudo and wish that your solution did not rely on SUDO_UID which is too specific to that hack.

Sometimes people need to lie to their SCM when doing things in behalf of somebody else, and I agree we would want to give them a way to do so. And we do, just like RCS and CVS honor LOGNAME.

If you have /etc/hosts under RCS control but you do not want all the log entries to say 'root', and you would do:

	$ cd /etc
	$ su
	root# edit /etc/hosts
	root# LOGNAME=me ci -u -m 'Add host bar' hosts

When omebody asks you to help him fixing his bug, you go to his keyboard, show him how it should be done, and you concude the session with:

	his shell$ LOGNAME=me ci -u -m 'Fix foo' foo.c

The point is that the same mechanism works (because it is designed to) in both cases.

Previous: Shawn O. Pearce
Message 4 of 4 in “Use SUDO_UID to guess committer identity”
  1. Use SUDO_UID to guess committer identityShawn O. Pearce, Jun 7, 2008
  2. Junio C HamanoJun 7, 2008
  3. Shawn O. PearceJun 8, 2008
  4. Junio C HamanoJun 8, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.