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

Re: Skipping adding Signed-off-by even if it's not the last on git commit

From
Jeff King <peff@peff.net>
Date
Dec 8, 2022, 07:27 UTC
Message-ID
<Y5GRx86i3ZIiVxb3@coredump.intra.peff.net>
In-Reply-To
<xmqqtu266cj5.fsf@gitster.g>
On Thu, Dec 08, 2022 at 08:04:46AM +0900, Junio C Hamano wrote:
Show 13 quoted lines
> Taylor Blau <me@ttaylorr.com> writes:
> 
> >> > >     $ git commit --signoff[=[no-]dedup]
> > ...
> > Thanks, I look forward to seeing your work. It would be nice to
> > standardize on this `--signoff[=[no-]dedup]` thing throughout all of the
> > different commands that support it.
> 
> Also, if I am not mistaken, each of trailers can be configured to
> have its own semantics (e.g. .where and .ifExists).
> 
>  * Should we have similar override to these trailer tokens, not just
>    sign-off?

This made me curious about the opposite: is there config you can set to get this behavior for --signoff? I think the answer is "no". You can do:

  git -c trailer.ifExists=addIfDifferent \
      commit --amend --trailer="Signed-off-by: Jeff King <peff@peff.net>"

to get the desired behavior, but using "--signoff" does not respect trailer settings.

I feel like config is probably a better match for the use cases here, because the decision about de-duping is not something you'd usually set for one particular operation, but is more likely to be a project policy about what the trailer means (and that includes Signed-off-by). So you'd want to set it per-repo, not per-operation.

>  * Should we offer not just [no-]dedup (which is equivalent to
>    switching from addIfDifferentNeighbor to addIfDifferent) but
>    other customization?  This affects what --signoff should be
>    allowed to take for consistency across trailers.

Yeah, writing the above made me wonder if --signoff should behave exactly like:

  --trailer="Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"

For the most part that would not change any behavior unless you set trailer.signed-off-by.*, and setting those presumably signals intent that you expect them to take effect. The one exception is that the generic trailer.ifExists, etc, would start affecting --signoff, which _might_ be a surprise. If we wanted to retain the behavior there, we could say "--signoff is special, and doesn't respect generic trailer config".

Alternatively, it would be nice if there was an easy way to put your ident into a trailer (what I wrote above doesn't really work unless you have those variables in your environment, and of course it's a lot of typing). I think you can hack it up like:

  git config trailer.sign.key Signed-off-by
  git config trailer.sign.cmd \
    'git var GIT_COMMITTER_IDENT | sed "s/>.*/>/";:'
  git commit --trailer=sign

which is only a little more typing than --signoff, but it's not very ergonomic.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 14 in “Skipping adding Signed-off-by even if it's not the last on git commit”
  1. David CaroDec 6, 2022
  2. Taylor BlauDec 7, 2022
  3. Junio C HamanoDec 7, 2022
  4. David CaroDec 7, 2022
  5. Taylor BlauDec 7, 2022
  6. Junio C HamanoDec 7, 2022
  7. Jeff KingDec 8, 2022
  8. Junio C HamanoDec 9, 2022
  9. Jeff KingDec 9, 2022
  10. Junio C HamanoDec 9, 2022
  11. Jeff KingDec 9, 2022
  12. Ævar Arnfjörð BjarmasonDec 7, 2022
  13. Junio C HamanoDec 7, 2022
  14. Konstantin RyabitsevDec 7, 2022

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.