threads / discuss / 3061

Re: git-commit: allow From: line to be entered in commit message

Subject: Re: git-commit: allow From: line to be entered in commit message

## tl;dr

14 messages between Jan 12, 2006 and Jan 13, 2006.

replies: 13people: 5as markdown or json

Joel Becker· Jan 12, 2006, 19:00 UTC · lore
On Thu, Jan 12, 2006 at 09:37:00AM -0500, sean wrote:
Show 8 quoted lines
> Use the author name and email information given as the 
> first line of the commit message in the form of:
> 
> From: name <email>
> 
> as the author's name and email address in the resulting
> commit object.  This makes committing foreign patches
> a little less cumbersome to handle for some workflows.
	If we do this, can we have it populated up front?  That is, when
the edit opens, the current idea of author is in the comments as "From:"
so I can see what the author would be if I changed nothing.  This would
catch surprises where I'd forgotten to set AUTHOR_*, etc.
Joel
 
-- 
Life's Little Instruction Book #182

	"Be romantic."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127
Junio C Hamano· Jan 12, 2006, 20:22 UTC · re: Joel Becker · lore
Joel Becker <Joel.Becker@oracle.com> writes:
Show 10 quoted lines
> On Thu, Jan 12, 2006 at 09:37:00AM -0500, sean wrote:
>> Use the author name and email information given as the 
>> first line of the commit message in the form of:
>> 
>> From: name <email>
>> 
> 	If we do this, can we have it populated up front?  That is, when
> the edit opens, the current idea of author is in the comments as "From:"
> so I can see what the author would be if I changed nothing.  This would
> catch surprises where I'd forgotten to set AUTHOR_*, etc.

Committing somebody else's changes by hand ought to be a rare event. Otherwise that is an indication that there needs to be a "git am/applymbox" equivalent for the mythical transport medium (other than e-mail) that feeds you somebody else's changes to you and have you commit. If something is a regular event in a workflow, we would want to be able to automate things, and having the user type in whom the changes have come from is not the way to do it.

Most of the time when I use "git commit", I'll be committing my own changes; I do not want to see "From: me" every time I commit.

"Populate upfront, only if it is different from yourself" is perhaps acceptable, but that is probably hard to arrange. There is no reliable way to know what is "yourself", and that was why we have GIT_AUTHOR_* environment variables to override things to begin with.

Joel Becker· Jan 13, 2006, 06:58 UTC · re: Junio C Hamano · lore
On Thu, Jan 12, 2006 at 12:22:53PM -0800, Junio C Hamano wrote:
Show 6 quoted lines
> Committing somebody else's changes by hand ought to be a rare
> event.  Otherwise that is an indication that there needs to be a
>...
> Most of the time when I use "git commit", I'll be committing my
> own changes; I do not want to see "From: me" every time I
> commit.
	Well, I'm wary of putting
GIT_AUTHOR_EMAIL=joel.becker@oracle.com as a permanent part of my
environment, for fear of overriding some other authors at some point.
On the other hand, if I don't put it in the environment, I get a bogus
author line (jlbec@thisbox.oracle.com).  So I end up having to
hand-write the AUTHOR_EMAIL lines on each commit line; not a solution
I'm happy with.
	This way, I'd have a chance to edit it and be sure :-)
Joel
 
-- 
Life's Little Instruction Book #274

	"Leave everything a little better than you found it."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127
Junio C Hamano· Jan 13, 2006, 07:06 UTC · re: Joel Becker · lore
Joel Becker <Joel.Becker@oracle.com> writes:
> Well, I'm wary of putting
> GIT_AUTHOR_EMAIL=joel.becker@oracle.com as a permanent part of my
> environment, for fear of overriding some other authors at some point.

The weakest default comes from .git/config so you could have this in your .git/config:

	[user]
        	name = Joel Becker 
                email = Joel.Becker@oracle.com
and you can have GIT_AUTHOR_* override it as necessary.
Joel Becker· Jan 13, 2006, 19:12 UTC · re: Junio C Hamano · lore
On Thu, Jan 12, 2006 at 11:06:07PM -0800, Junio C Hamano wrote:
Show 12 quoted lines
> Joel Becker <Joel.Becker@oracle.com> writes:
> 
> > Well, I'm wary of putting
> > GIT_AUTHOR_EMAIL=joel.becker@oracle.com as a permanent part of my
> > environment, for fear of overriding some other authors at some point.
> 
> The weakest default comes from .git/config so you could have
> this in your .git/config:
> 
> 	[user]
>         	name = Joel Becker 
>                 email = Joel.Becker@oracle.com
	This configuration is something I have the opportunity to forget
every time I call git-clone.  So I still need to leave it in the
environment permanently.
	Am I correct in assuming that "From:" lines will override the
environment when using git-applymbox?  If so, I guess leaving
GIT_AUTHOR_* in my environment permanently will be ok.
Joel
-- 
"War doesn't determine who's right; war determines who's left."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127
Junio C Hamano· Jan 13, 2006, 19:39 UTC · re: Joel Becker · lore
Joel Becker <Joel.Becker@oracle.com> writes:
> 	Am I correct in assuming that "From:" lines will override the
> environment when using git-applymbox?  If so, I guess leaving
> GIT_AUTHOR_* in my environment permanently will be ok.

That's what I do. Although I use git-am not git-applymbox, both of them are designed to work that way.

Joel Becker· Jan 13, 2006, 20:01 UTC · re: Junio C Hamano · lore
On Fri, Jan 13, 2006 at 11:39:17AM -0800, Junio C Hamano wrote:
> That's what I do.  Although I use git-am not git-applymbox, both
> of them are designed to work that way.
	While I can see that git-am and git-applymbox have different
options for the same basic task, I can't quite see why one would be
preferred to the other.  What does git-am do that git-applymbox does
not?
Joel
-- 
"I'm so tired of being tired,
 Sure as night will follow day.
 Most things I worry about
 Never happen anyway."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127
Junio C Hamano· Jan 13, 2006, 20:33 UTC · re: Joel Becker · lore
Joel Becker <Joel.Becker@oracle.com> writes:
Show 8 quoted lines
> On Fri, Jan 13, 2006 at 11:39:17AM -0800, Junio C Hamano wrote:
>> That's what I do.  Although I use git-am not git-applymbox, both
>> of them are designed to work that way.
>
> 	While I can see that git-am and git-applymbox have different
> options for the same basic task, I can't quite see why one would be
> preferred to the other.  What does git-am do that git-applymbox does
> not?

Sorry about the confusion. This is turning into a FAQ and it is all _my_ fault [*1*].

Some historical background.
 - "applymbox" was there first.  It was renamed from a tool
   'dotest' Linus had used since BK days, with somewhat
   unextensible command line syntax.
 - "am" was invented later, to majorly redo what applymbox does
   with extensible command line syntax.  It is supposed to do
   everything applymbox does, but the only thing it does not
   support is to be command-line compatible.

The primary reason why I kept applymbox maintained is because many "How to hack kernel with git" documents floating around talk about applymbox, and it still is used by Linus to apply patches with his trained fingers. Worse yet, it could be that applymbox is used as a building block in larger private scripts used by kernel developers, and its removal would force them to update their scripts to use "am" instead. I do not want to see the kernel people spending their time on adjusting their private tools for git changes unnecessarily; their time is better spent on improving the kernel.

So in short, I tend to recommend "am" to new people, but "applymbox" is still usable.

[Footnote]

*1* I do not mind keeping applymbox maintained, but at the same time I know I would feel it stupid to carry two tools that do almost the same thing if it were somebody else's project, and every time this issue comes up I feel the urge to say "in 3 months, git-applymbox will be removed, please get used to git-am", which so far I ended up resisting.

Junio C Hamano· Jan 13, 2006, 20:46 UTC · re: Junio C Hamano · lore
Junio C Hamano <junkio@cox.net> writes:
Show 10 quoted lines
> Joel Becker <Joel.Becker@oracle.com> writes:
>
>> On Fri, Jan 13, 2006 at 11:39:17AM -0800, Junio C Hamano wrote:
>>> That's what I do.  Although I use git-am not git-applymbox, both
>>> of them are designed to work that way.
>>
>> 	While I can see that git-am and git-applymbox have different
>> options for the same basic task, I can't quite see why one would be
>> preferred to the other.  What does git-am do that git-applymbox does
>> not?

The behaviour upon seeing unapplicable patch is somewhat different. In Linus workflow, he reviews (and modifies if necessary) all patches inside mbox and runs "applymbox"; upon failure, he blows what remains in .dotest away, trims mbox to get rid of what has already been applied and re-runs it from scratch. The failure recovery method "applymbox" had (this happened before my time IIRC) is to edit .dotest/patch to make it applicable and re-run it. OTOH, "am" tries to do better by allowing you to hand tweak the working tree to match what would have resulted if the patch applied cleanly and say "--resolved".

Another difference is that "am" can be told to handle binary file changes and apply such as long as the patch is intra repository (i.e. both pre and post image blob are available in the repository). This is used as a backend to do "git rebase".

Johannes Schindelin· Jan 13, 2006, 21:47 UTC · re: Joel Becker · lore
Hi,
On Fri, 13 Jan 2006, Joel Becker wrote:
Show 17 quoted lines
> On Thu, Jan 12, 2006 at 11:06:07PM -0800, Junio C Hamano wrote:
> > Joel Becker <Joel.Becker@oracle.com> writes:
> > 
> > > Well, I'm wary of putting
> > > GIT_AUTHOR_EMAIL=joel.becker@oracle.com as a permanent part of my
> > > environment, for fear of overriding some other authors at some point.
> > 
> > The weakest default comes from .git/config so you could have
> > this in your .git/config:
> > 
> > 	[user]
> >         	name = Joel Becker 
> >                 email = Joel.Becker@oracle.com
> 
> 	This configuration is something I have the opportunity to forget
> every time I call git-clone.  So I still need to leave it in the
> environment permanently.
Of course, you could put it in your templates and never forget.

Ciao, Dscho

Alex Riesen· Jan 12, 2006, 20:16 UTC · lore
sean, Thu, Jan 12, 2006 15:37:00 +0100:
Show 12 quoted lines
> 
> Mostly just for comment to see if there is any support
> for this feature....
> 
> Sean
> 
> ---
> Use the author name and email information given as the 
> first line of the commit message in the form of:
> 
> From: name <email>
> 
Isn't this what git-am expect (as a part of mbox) and handle?
sean· Jan 13, 2006, 02:46 UTC · re: Alex Riesen · lore

On Thu, 12 Jan 2006 21:16:46 +0100 Alex Riesen <raa.lkml@gmail.com> wrote:

Show 7 quoted lines
> > Use the author name and email information given as the 
> > first line of the commit message in the form of:
> > 
> > From: name <email>
> > 
> Isn't this what git-am expect (as a part of mbox) and handle?
> 
Hi Alex,

Yes it is, but not everyone is processing patches in mbox format. If this facility is good enough for the mbox users, it seems like it would be good enough for non-mbox users. In fact, it would seem more consistent to tell someone that a From: line will be handled properly whether they use git-am or git-commit.

Sean
Junio C Hamano· Jan 13, 2006, 03:58 UTC · re: sean · lore
sean <seanlkml@sympatico.ca> writes:
> ...   In fact, it would seem more
> consistent to tell someone that a From: line will be handled properly
> whether they use git-am or git-commit. 
Yuck.

Somebody using am/applymbox is not writing that "From: " line himself. The person who writes that "From: " line writes that into his MUA when sending a patch --- that is "editing an email", so there is a consistency between that activity and use of word "From: ".

The editor for commit message does not have anything to do with e-mail. What you are talking about is not consistency, but confusion.

sean· Jan 13, 2006, 03:58 UTC · re: Junio C Hamano · lore

On Thu, 12 Jan 2006 19:58:20 -0800 Junio C Hamano <junkio@cox.net> wrote:

Show 18 quoted lines
> sean <seanlkml@sympatico.ca> writes:
> 
> > ...   In fact, it would seem more
> > consistent to tell someone that a From: line will be handled properly
> > whether they use git-am or git-commit. 
> 
> Yuck.
> 
> Somebody using am/applymbox is not writing that "From: " line
> himself.  The person who writes that "From: " line writes that
> into his MUA when sending a patch --- that is "editing an
> email", so there is a consistency between that activity and use
> of word "From: ".
> 
> The editor for commit message does not have anything to do with
> e-mail.  What you are talking about is not consistency, but
> confusion.
> 

I don't imagine that the person "editing" the commit message is doing so in this case either, rather copy-n-pasting. If you're really dead-set against this method, you should at least consider adding it as a command line option, because having to set this via environment variables is a much bigger Yuck.

Sean

← back to recent threads