Kaartic Sivaraam <kaarticsivaraam91196@xxxxxxxxx> writes: > I made an attempt to make the second example work with amending > with the aim of making it suitable for usage out of the box. It > seems that it's not easy to make it work as the status of a file > cannot be determined correctly when the index while amending > introduces changes to a file that has a change in the commit being > amended. > > Is there any way in which the second example could be made to work with > amending without much effort? I'm asking this assuming something might > have happened, since the script was added, that could ease the task. Sorry, but I do not understand what you are asking here. Ahh, do you mean if we can avoid doing one half of the 1/4 (i.e. the part that removes the commented out 'diff --name-status') and instead make it a useful example (while still removing the thing that comments out the "conflicts:")? After going back and checking 1/4, I realize that I misread the patch. you did keep the commented out 'diff --name-status' thing, so it still has three---it just lost one half of the original "first" example. So please disregard my earlier "do we still have three, not two?" > Documentation/githooks.txt | 3 +++ > templates/hooks--prepare-commit-msg.sample | 5 ++++- > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt > index fdc01aa25..59f38efba 100644 > --- a/Documentation/githooks.txt > +++ b/Documentation/githooks.txt > @@ -121,6 +121,9 @@ it is not suppressed by the `--no-verify` option. A non-zero exit > means a failure of the hook and aborts the commit. It should not > be used as replacement for pre-commit hook. > > +The sample `prepare-commit-msg` hook that comes with Git removes the > +help message found in the commented portion of the commit template. > + > commit-msg > ~~~~~~~~~~ > > diff --git a/templates/hooks--prepare-commit-msg.sample b/templates/hooks--prepare-commit-msg.sample > index a15d6d634..a84c3e5a8 100755 > --- a/templates/hooks--prepare-commit-msg.sample > +++ b/templates/hooks--prepare-commit-msg.sample > @@ -9,7 +9,8 @@ > # > # To enable this hook, rename this file to "prepare-commit-msg". > > -# This hook includes three examples. > +# This hook includes three examples. The first one removes the > +# "# Please enter the commit message..." help message. > # > # The second includes the output of "git diff --name-status -r" > # into the message, just before the "git status" output. It is > @@ -23,6 +24,8 @@ COMMIT_MSG_FILE=$1 > COMMIT_SOURCE=$2 > SHA1=$3 > > +@PERL_PATH@ -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" > + > # case "$COMMIT_SOURCE,$SHA1" in > # ,|template,) > # @PERL_PATH@ -i.bak -pe '