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 <[email protected]>
; 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 <[email protected]>
; 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