threads / discuss / 45055

In-body from headers ignored

Subject: In-body from headers ignored

## tl;dr

3 messages between Feb 5, 2017 and Feb 6, 2017.

replies: 2people: 2as markdown or json

Liam Breck· Feb 5, 2017, 21:45 UTC · lore
git format-patch & send-email generate the in-body From header.
git am recognizes it.

git commit & format-patch & send-email ignore it. (The latter two will add a new header above an extant one.) Is there a rationale for this?

If not, maybe this is a bug?
Junio C Hamano· Feb 5, 2017, 23:43 UTC · re: Liam Breck · lore

Re: In-body from headers ignored

Liam Breck <liam@networkimprov.net> writes:
Show 6 quoted lines
> git format-patch & send-email generate the in-body From header.
>
> git am recognizes it.
>
> git commit & format-patch & send-email ignore it. (The latter two will
> add a new header above an extant one.) Is there a rationale for this?

I may be misunderstanding you, but I am guessing that you are expecting

	$ GIT_AUTHOR_NAME="Liam Breck" GIT_AUTHOR_EMAIL='liam@n.net' \
	git commit -m 'The title of the patch
	From: Somebody Else <somebody@else.xz>
	Subject: The real title of the patch
	This is the (true) first line of the body of the message.'
to record a commit object that would give
	$ git cat-file commit HEAD
	tree ....
	parent ....
	author Somebody Else <somebody@else.xz> ....
	committer ...
	The real title of the patch
	This is the (true) first line of the body of the message.

and seeing that the real author is still you, the title is "The real title of the patch", and the first paragraph of the body consists of these two lines that begin with "From: and "Subject:".

This is very much deliberate. "git commit" does not care if the second paragraph in the body of the message resembles e-mail headers, because it is a command that can be used by people who do not even e-mail patches.

"git format-patch" and "git am" are all about passing the commit between people over e-mail, and they know that the second paragraph can have "From:", "Subject:" or "Date:" to override what "am" obtains from the header lines of the e-mail that carried the message, because the e-mail headers can be different (e.g. you may be forwarding somebody else's e-mail but you may not be able to forge the real "From:" line to your MUA/MTA) from what you really want to use. On the receiving end, "am" tells "mailinfo" program to inspect the message body with "--inbody-headers" option. After "mailinfo" inspects the message, "am" invokes the underlying machinery to actually make the commit (which corresponds to "git commit"), but at that point the invoked "git commit" does not even see these in-body header lines. That is how division of labor between these layers of the commands are structured.

Liam Breck· Feb 6, 2017, 00:08 UTC · re: Junio C Hamano · lore

Re: In-body from headers ignored

On Sun, Feb 5, 2017 at 3:43 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 21 quoted lines
> Liam Breck <liam@networkimprov.net> writes:
>
>> git format-patch & send-email generate the in-body From header.
>>
>> git am recognizes it.
>>
>> git commit & format-patch & send-email ignore it. (The latter two will
>> add a new header above an extant one.) Is there a rationale for this?
>
> I may be misunderstanding you, but I am guessing that you are
> expecting
>...
> and seeing that the real author is still you, the title is "The real
> title of the patch", and the first paragraph of the body consists of
> these two lines that begin with "From: and "Subject:".
>
> This is very much deliberate.  "git commit" does not care if the
> second paragraph in the body of the message resembles e-mail
> headers, because it is a command that can be used by people who do
> not even e-mail patches.
> ...
Hi, thanks for the detailed reply :-)
OK, that resolves my Q about git commit.

But should not git format-patch & send-email detect an extant in-body From or Subject header?

Suppose I need to forward a patchset and cannot amend the commits in git? Or that a patchset author is not the copyright holder, whom I want to be logged as the author upstream?

There is a workaround: delete the From headers in the patches, but I was looking for a command-line option or alternate default behavior :-)

← back to recent threads