git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: jim.cromie@gmail.com
Cc: git@vger.kernel.org
Subject: Re: git format-patch -s enhancement
Date: Mon, 16 Aug 2021 12:36:59 -0400	[thread overview]
Message-ID: <YRqUK3cRFJmANzDd@coredump.intra.peff.net> (raw)
In-Reply-To: <CAJfuBxxT_7weC8_O=KYScSbDcSeBdb3v5d_gtn-NXzW_fKLrsA@mail.gmail.com>

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.

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

  parent reply	other threads:[~2021-08-16 16:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-15 23:07 git format-patch -s enhancement jim.cromie
2021-08-16  7:56 ` Bagas Sanjaya
2021-08-16 16:36 ` Jeff King [this message]
2021-08-16 21:49   ` jim.cromie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YRqUK3cRFJmANzDd@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=jim.cromie@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).