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

'git interpret-trailers' is tripped by comment characters other than '#'

From
Masahiro Yamada <yamada.masahiro@socionext.com>
Date
Jun 14, 2019, 11:35 UTC
Message-ID
<CAK7LNAR=KhTZRFFXTbcZwe-+65fGnVB7NbmVbQ7ymbmChDuhAg@mail.gmail.com>
Hi.

When I tried to add ChangeId tag for Gerrit Code Review, I noticed 'git interpret-trailers' went wrong if a comment character other than '#' is used.

Quick Test Code ---------------

cat <<EOF | git -c trailer.ifexists=doNothing interpret-trailers \
      --trailer "Change-Id: new tag"
subject: this is commit subject
Blah Blah
Change-Id: old tag
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
; This is a comment line with non-default char
EOF
[result]
subject: this is commit subject
Blah Blah
Change-Id: old tag
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
; This is a comment line with non-default char
Change-Id: new tag

The same trailer 'Change-Id' was appended, ignoring trailer.ifexists=doNothing

Details -------

For Gerrit Code Review, we add "Change-Id" tag, which will identify the patch though the review process.

For details, you can refer: https://www.gerritcodereview.com/cmd-hook-commit-msg.html

Gerrit provides a shell script "commit-msg", which is hooked from 'git commit'.

You can see its implementation here: https://github.com/GerritCodeReview/gerrit/blob/v3.0.0/resources/com/google/gerrit/server/tools/root/hooks/commit-msg

It is implemented by using 'git interpret-trailers'.

I prefer ';' to '#" for commit comment lines.
So, I add the following:
[core]
        commentChar = ";"

With core.commentChar is set, 'git interpret-trailers' is so confused that accumulate the same tag for every 'git commit --amend'.

I guess this should be fixed on the Git side.

Perhaps, 'git interpret-trailers' should be changed to recognize core.commentChar ?

-- 
Best Regards
Masahiro Yamada
Next: Jeff King
Message 1 of 13 in “'git interpret-trailers' is tripped by comment characters other than '#'”
  1. Masahiro YamadaJun 14, 2019
  2. Jeff KingJun 14, 2019
  3. Christian CouderJun 15, 2019
  4. Masahiro YamadaJun 17, 2019
  5. Christian CouderJun 17, 2019
  6. Junio C HamanoJun 17, 2019
  7. Christian CouderJun 17, 2019
  8. Masahiro YamadaJun 18, 2019
  9. interpret-trailers: load default configJeff King, Jun 19, 2019
  10. Junio C HamanoJun 19, 2019
  11. Jeff KingJun 19, 2019
  12. Masahiro YamadaJun 19, 2019
  13. Masahiro YamadaJun 17, 2019

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.