Change ID in the commit message is shown in the middle of the commit message text.

83 views
Skip to first unread message

Renuka Holimath

unread,
Aug 7, 2018, 8:45:45 AM8/7/18
to Repo and Gerrit Discussion
Hi Team,

I have come across a scenario where commit-msg hook added the change -id in middle of text entered by committer in the patchset 1 of the Change.
But from the server end, the commit message looks fine. The Change Id is at the last line of the commit message as default for the Change.

Could you please provide any hint in what case this happens.

Eg:
<commit message line 1>
Change-Id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
<commit message line 2>

Thanks in advance.

Regards,
Renuka

Gert van Dijk

unread,
Aug 7, 2018, 9:09:32 AM8/7/18
to Repo and Gerrit Discussion
It's hard to guess what's going on without knowing some more specifics.
  • What do the other commit message lines look like? If they look like trailers (<word>: <text>), this is a works-as-intended, I think.
  • What version of the commit-msg hook did you use? It should be in the header of the .git/hooks/commit-msg file. I'm asking, since it's been refactored on master recently (running on googlesource addresses already, but not part of stable releases yet).

Renuka Holimath

unread,
Aug 7, 2018, 9:17:19 AM8/7/18
to Repo and Gerrit Discussion
Hi Gert,

Thank you for replying. Below is the last line of the commit message.
 
-PS1: replaced xml file

Regards,
Renuka

Gert van Dijk

unread,
Aug 7, 2018, 9:29:28 AM8/7/18
to Repo and Gerrit Discussion
On Tuesday, 7 August 2018 15:17:19 UTC+2, Renuka Holimath wrote:
Below is the last line of the commit message.
 
-PS1: replaced xml file

In that case, the commit-msg hook will regard your line as a trailer/footer. The conceptual part of having

<token>: <value>

as explained on https://git-scm.com/docs/git-interpret-trailers is then triggered.

Suggestion on what you can do to avoid this from happening:
  • Avoid putting this kind of lines as the last one. Put them in the non-last paragraph and they won't be parsed as such.
  • Use itemized styling, e.g.

    My commit message subject

    Some more descriptive text

    - PS1: text
    - PS2: text

    <trailers>

Renuka Holimath

unread,
Aug 7, 2018, 10:10:28 AM8/7/18
to Repo and Gerrit Discussion
Hi Gert,

Thank you for the suggestion. I shall try to avoid putting such lines at the last line of the commit message.

Regards,
Renuka
Reply all
Reply to author
Forward
0 new messages