gerrit/resources
Jonathan Nieder 8c2dbd1eaf Do not strip out "-- >8 --" comment in commit-msg hook
When commiting with "git commit --cleanup=scissors" or "git commit
--verbose", Git includes the following lines in the commit message
template, with additional information that should not go in the commit
message after it:

 # ------------------------ >8 ------------------------
 # Do not modify or remove the line above.
 # Everything below it will be ignored.

In I78b50a789860cc11d63d891b0507786890158754 (Handle messages with
only comments in the commit-msg hook, 2018-12-18), we started
stripping comments from the proposed commit message in order to
determine whether it is empty and as an accidental side effect we lost
this line.  As a result, Git includes the supporting information
(e.g., the diff) in the commit message.

Fortunately we only needed to strip out comments in order to check for
emptiness.  Afterward, the hook invokes "git interpret-trailers",
which is prepared to cope with comments and scissor lines in front of
a diff in recent versions of Git[*].  Fix the hook to work in scissors
mode by using the stripped commit message only for the emptiness check
and going back to the unstripped message for subsequent steps.

This way, users can run "git commit -v" without having the diff end up
in the resulting commit message.

Users with older versions of Git will not benefit from this fix, but
it does not produce a regression there, either: "git commit" in
cleanup modes other than scissors continues to work as expected.  In
other words, in all cases this works as well as before I78b50a78986.

[*] v2.13.1~16^2 (interpret-trailers: honor the cut line, 2017-05-15)

Bug: Issue 10346
Change-Id: I633e5db4643851376422f839d969094043abb5c5
(cherry picked from commit 731eb42b8a)
2019-03-13 22:51:49 -07:00
..
com/google/gerrit Do not strip out "-- >8 --" comment in commit-msg hook 2019-03-13 22:51:49 -07:00
BUILD Dissolve gerrit-war top-level directory 2017-10-31 11:02:37 -04:00
log4j.properties Dissolve gerrit-war top-level directory 2017-10-31 11:02:37 -04:00