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

Re: [PATCH] hook: use correct logical variable

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 14, 2017, 18:19 UTC
Message-ID
<xmqqwp66ui5h.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170814084646.30781-1-kaarticsivaraam91196@gmail.com>
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> writes:
Show 22 quoted lines
> Sign-off added should be that of the "committer" not that of the
> "commit's author".
>
> Use the correct logical variable that identifies the committer.
>
> Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
> ---
>  This fixes a small issue when trying to do the following with the script enabled,
>
>     $ git commit --amend -s
>
>  If the commit being amended was signed off by the commit's author
>  then the above command would *append* the sign-off of the
>  committer followed by that of the commit's author.
>  That' because the script is invoked only after the sign-off is
>  added by the '-s' option AND the default of 'trailer.ifexists'
>  for interpret-trailers currently defaults to the
>  'addIfDifferentNeighbor' thus interpret-trailer fails to identify
>  the existing sign-off of the commit's author and adds it.
>
>  Anyways, it doesn't make sense for a script to add the sign-off
>  of the commit's author. So, fixing it seemed correct to me.

I tend to agree with "Anyways" above ;-) simply because I found the long paragraph more confusing than enlightening, leaving me wonder "why is the user using different settings for author and committer name" at the end, which _is_ an irrelevant point in the issue being addressed.

The real issue is that this commented-out sample hook uses "author" ident for the sign-off, while all the rest of Git (i.e. all callers of append_signoff() in sequencer.c) use committer ident.

If anything to be changed to this patch, I would say its "should be" in the log message can be clarified with "why", perhaps like:

    Sign-off added should be that of the "committer", not that of
    the "commit's author"; that is how the rest of Git adds sign-off
    using sequencer.c::append_signoff().
Thanks.
Show 16 quoted lines
>  templates/hooks--prepare-commit-msg.sample | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/templates/hooks--prepare-commit-msg.sample b/templates/hooks--prepare-commit-msg.sample
> index a84c3e5a8..12dd8fd88 100755
> --- a/templates/hooks--prepare-commit-msg.sample
> +++ b/templates/hooks--prepare-commit-msg.sample
> @@ -34,7 +34,7 @@ SHA1=$3
>  #  *) ;;
>  # esac
>  
> -# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
> +# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
>  # git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
>  # if test -z "$COMMIT_SOURCE"
>  # then
Previous: Stefan BellerNext: Kaartic Sivaraam
Message 40 of 58 in “hooks: add signature to the top of the commit message”
  1. hooks: add signature to the top of the commit messageKaartic Sivaraam, Jun 30, 2017
  2. Junio C HamanoJun 30, 2017
  3. Kaartic SivaraamJul 1, 2017
  4. "git intepret-trailers" vs. "sed script" to add the signatureKaartic Sivaraam, Jul 1, 2017
  5. hooks: add signature using "interpret-trailers"Kaartic Sivaraam, Jul 1, 2017
  6. Junio C HamanoJul 3, 2017
  7. Kaartic SivaraamJul 4, 2017
  8. Junio C HamanoJul 5, 2017
  9. hooks: add signature using "interpret-trailers"Kaartic Sivaraam, Jul 5, 2017
  10. hooks: add signature using "interpret-trailers"Kaartic Sivaraam, Jul 5, 2017
  11. Junio C HamanoJul 5, 2017
  12. Ramsay JonesJul 5, 2017
  13. Kaartic SivaraamJul 6, 2017
  14. Junio C HamanoJul 1, 2017
  15. Philip OakleyJul 1, 2017
  16. Junio C HamanoJul 1, 2017
  17. Philip OakleyJul 1, 2017
  18. Kaartic SivaraamJul 1, 2017
  19. Junio C HamanoJul 1, 2017
  20. Kaartic SivaraamJul 2, 2017
  21. hooks: replace irrelevant hook sampleKaartic Sivaraam, Jul 2, 2017
  22. hooks: replace irrelevant hook sampleKaartic Sivaraam, Jul 5, 2017
  23. Junio C HamanoJul 5, 2017
  24. Kaartic SivaraamJul 7, 2017
  25. Junio C HamanoJul 7, 2017
  26. Kaartic SivaraamJul 7, 2017
  27. 1/2 hooks: replace irrelevant hook sampleKaartic Sivaraam, Jul 7, 2017
  28. 2/2 hooks: add signature using "interpret-trailers"Kaartic Sivaraam, Jul 7, 2017
  29. Junio C HamanoJul 7, 2017
  30. 1/4 hook: cleanup scriptKaartic Sivaraam, Jul 10, 2017
  31. 2/4 hook: name the positional variablesKaartic Sivaraam, Jul 10, 2017
  32. Junio C HamanoJul 10, 2017
  33. 3/4 hook: add signature using "interpret-trailers"Kaartic Sivaraam, Jul 10, 2017
  34. Ramsay JonesJul 10, 2017
  35. Junio C HamanoJul 10, 2017
  36. 1/4 hook: cleanup scriptKaartic Sivaraam, Jul 11, 2017
  37. 3/4 hook: add sign-off using "interpret-trailers"Kaartic Sivaraam, Jul 11, 2017
  38. hook: use correct logical variableKaartic Sivaraam, Aug 14, 2017
  39. Stefan BellerAug 14, 2017
  40. Junio C HamanoAug 14, 2017
  41. Kaartic SivaraamAug 15, 2017
  42. Junio C HamanoAug 15, 2017
  43. Kaartic SivaraamAug 17, 2017
  44. hook: use correct logical variableKaartic Sivaraam, Aug 17, 2017
  45. Kaartic SivaraamAug 15, 2017
  46. 2/4 hook: name the positional variablesKaartic Sivaraam, Jul 11, 2017
  47. 4/4 hook: add a simple first exampleKaartic Sivaraam, Jul 11, 2017
  48. 4/4 hook: add a simple first exampleKaartic Sivaraam, Jul 11, 2017
  49. Kaartic SivaraamJul 11, 2017
  50. Kaartic SivaraamJul 11, 2017
  51. 4/4 hook: add a simple first exampleKaartic Sivaraam, Jul 10, 2017
  52. Junio C HamanoJul 10, 2017
  53. Kaartic SivaraamJul 11, 2017
  54. Junio C HamanoJul 11, 2017
  55. Kaartic SivaraamJul 11, 2017
  56. Kaartic SivaraamJul 11, 2017
  57. Junio C HamanoJul 10, 2017
  58. hooks: add script to HOOKS that allows adding notes from commit messageKaartic Sivaraam, Jul 2, 2017

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.