threads / discuss / 56288

git format-patch -s enhancement

Subject: git format-patch -s enhancement

## tl;dr

4 messages between Aug 15, 2021 and Aug 16, 2021.

replies: 3people: 3as markdown or json

jim.cromie@gmail.com· Aug 15, 2021, 23:07 UTC · lore
hi all

git format-patch -s is sub-optimal : it appends the SoB, which falls after the snips --- changelog ... that the commit message may contain

So it misfires on any maintainer scripts expecting the SoB above the 1st snip.

The workaround is manual SoBs above any snips.
I note this in -s doc,
           Add a Signed-off-by trailer to the commit message, using
the committer identity of yourself.
           See the signoff option in git-commit(1) for more information.

"trailer" is really "document current working behavior" (normative docu-speak, so to speak;)

Ideal behavior is to find 1st in-body --- snip and insert there

Bagas Sanjaya· Aug 16, 2021, 07:56 UTC · re: jim.cromie@gmail.com · lore

Re: git format-patch -s enhancement

On 16/08/21 06.07, jim.cromie@gmail.com wrote:
Show 27 quoted lines
> hi all
> 
> git format-patch -s is sub-optimal :
> it appends the SoB,
> which falls after the snips
> ---
> changelog ...
> that the commit message may contain
> 
> 
> So it misfires on any maintainer scripts
> expecting the SoB above the 1st snip.
> 
> The workaround is manual SoBs above any snips.
> 
> I note this in -s doc,
> 
>             Add a Signed-off-by trailer to the commit message, using
> the committer identity of yourself.
>             See the signoff option in git-commit(1) for more information.
> 
> "trailer" is really "document current working behavior"
> (normative docu-speak, so to speak;)
> 
> Ideal behavior is to find 1st in-body  --- snip
> and insert there
> 

It seems like you don't tell us what snip means. Can you describe your environment and reproduction steps so that I can reproduce this issue?

And next time you can use `git bugreport`.
-- 
An old man doll... just what I always wanted! - Clara
Jeff King· Aug 16, 2021, 16:36 UTC · re: jim.cromie@gmail.com · lore

Re: git format-patch -s enhancement

On Sun, Aug 15, 2021 at 05:07:34PM -0600, jim.cromie@gmail.com wrote:
Show 24 quoted lines
> git format-patch -s is sub-optimal :
> it appends the SoB,
> which falls after the snips
> ---
> changelog ...
> that the commit message may contain
> 
> 
> So it misfires on any maintainer scripts
> expecting the SoB above the 1st snip.
> 
> The workaround is manual SoBs above any snips.
> 
> I note this in -s doc,
> 
>            Add a Signed-off-by trailer to the commit message, using
> the committer identity of yourself.
>            See the signoff option in git-commit(1) for more information.
> 
> "trailer" is really "document current working behavior"
> (normative docu-speak, so to speak;)
> 
> Ideal behavior is to find 1st in-body  --- snip
> and insert there

The big disconnect here is that "---" snip lines are not meant to be meaningful within commit messages themselves. They are part of the process of sticking a commit message into an email. So format-patch and git-am know about them, but "git commit" for example doesn't.

So "git commit --signoff" probably shouldn't take them into account when deciding the end of a commit message. The user might or might not have meant "---" to be syntactically meaningful, depending on whether they plan to send the message with format-patch (and changing the behavior now is questionable).

Doing so with "git format-patch --signoff" is a slightly different question. The current behavior is working as intended, in the sense that it signs off just as "commit -s" would, and then separately sticks the result into the email. The fact that "---" in the commit message is indistinguishable from the ones added by format-patch is mostly an accident.

That said, it's kind of a useful accident for some workflows, exactly because you can carry these non-commit-message notes inside the commit message. And since we know how any in-commit-message "---" will be treated by git-am on the other side, it might be reasonable for format-patch to start considering them to be syntactically significant.

So I guess I would disagree that it's a bug exactly, in that the workflow you're advocating was never meant to be supported. But I don't see any reason we couldn't be a little friendlier to it, if somebody wanted to teach format-patch to do so.

An alternative workflow would be to use git-notes to attach the changelog data to the commit. Those are shown after the "---" by format-patch already. Unfortunately, keeping them up to date is kind of annoying. Ages ago, I had a patch to let you modify them while editing the commit message, which makes it pretty seamless:

  https://lore.kernel.org/git/20110225133056.GA1026@sigill.intra.peff.net/

I carried the patch in my local build for a while, but never really ended up using it. So I never polished it further. But I think it's still fundamentally a reasonable idea, if somebody is interested in carrying it forward. If so, here's the version I've been rebasing forward over the years:

  https://github.com/peff/git jk/commit-notes-wip

but it doesn't seem to actually pass its own tests anymore (so it may or may not be a helpful starting point. ;) ).

-Peff
jim.cromie@gmail.com· Aug 16, 2021, 21:49 UTC · re: Jeff King · lore

Re: git format-patch -s enhancement

On Mon, Aug 16, 2021 at 10:37 AM Jeff King <peff@peff.net> wrote:
Show 57 quoted lines
>
> On Sun, Aug 15, 2021 at 05:07:34PM -0600, jim.cromie@gmail.com wrote:
>
> > git format-patch -s is sub-optimal :
> > it appends the SoB,
> > which falls after the snips
> > ---
> > changelog ...
> > that the commit message may contain
> >
> >
> > So it misfires on any maintainer scripts
> > expecting the SoB above the 1st snip.
> >
> > The workaround is manual SoBs above any snips.
> >
> > I note this in -s doc,
> >
> >            Add a Signed-off-by trailer to the commit message, using
> > the committer identity of yourself.
> >            See the signoff option in git-commit(1) for more information.
> >
> > "trailer" is really "document current working behavior"
> > (normative docu-speak, so to speak;)
> >
> > Ideal behavior is to find 1st in-body  --- snip
> > and insert there
>
> The big disconnect here is that "---" snip lines are not meant to be
> meaningful within commit messages themselves. They are part of the
> process of sticking a commit message into an email. So format-patch and
> git-am know about them, but "git commit" for example doesn't.
>
> So "git commit --signoff" probably shouldn't take them into account when
> deciding the end of a commit message. The user might or might not have
> meant "---" to be syntactically meaningful, depending on whether they
> plan to send the message with format-patch (and changing the behavior
> now is questionable).
>
> Doing so with "git format-patch --signoff" is a slightly different
> question.  The current behavior is working as intended, in the sense
> that it signs off just as "commit -s" would, and then separately sticks
> the result into the email. The fact that "---" in the commit message is
> indistinguishable from the ones added by format-patch is mostly an
> accident.
>
> That said, it's kind of a useful accident for some workflows, exactly
> because you can carry these non-commit-message notes inside the commit
> message. And since we know how any in-commit-message "---" will be
> treated by git-am on the other side, it might be reasonable for
> format-patch to start considering them to be syntactically significant.
>
> So I guess I would disagree that it's a bug exactly, in that the
> workflow you're advocating was never meant to be supported. But I don't
> see any reason we couldn't be a little friendlier to it, if somebody
> wanted to teach format-patch to do so.
>
agreed, notabug.

but it might fall afoul of others' mail handler scripts, Ive had a couple replys implying missed delivery, maybe because of details like '---'

Im just gonna add my SoB either at commit time, or manually. It will be interesting to see what happens to an SoB in a commit when its revised and --- changelogged

thanks
Show 20 quoted lines
> An alternative workflow would be to use git-notes to attach the
> changelog data to the commit. Those are shown after the "---" by
> format-patch already. Unfortunately, keeping them up to date is kind of
> annoying. Ages ago, I had a patch to let you modify them while editing
> the commit message, which makes it pretty seamless:
>
>   https://lore.kernel.org/git/20110225133056.GA1026@sigill.intra.peff.net/
>
> I carried the patch in my local build for a while, but never really
> ended up using it. So I never polished it further. But I think it's
> still fundamentally a reasonable idea, if somebody is interested in
> carrying it forward. If so, here's the version I've been rebasing
> forward over the years:
>
>   https://github.com/peff/git jk/commit-notes-wip
>
> but it doesn't seem to actually pass its own tests anymore (so it may or
> may not be a helpful starting point. ;) ).
>
> -Peff

← back to recent threads