diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-08-11 13:26:56 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-08-11 13:26:56 -0700 |
commit | 127f98f42b0b72d2d23c97e7d783d369b6e33fa0 (patch) | |
tree | bb22b4381ebc8d52fa4e6abde1f17d0b342dc82f /templates | |
parent | c7528f4d8a2b8e4bf843b3eb95d2b7899a38c1fa (diff) | |
parent | 0ef1a4e32a720928a497a13ef08aa8f0a63dc476 (diff) | |
download | git-127f98f42b0b72d2d23c97e7d783d369b6e33fa0.tar.gz |
Merge branch 'ks/prepare-commit-msg-sample'
Remove an example that is now obsolete from a sample hook,
and improve an old example in it that added a sign-off manually
to use the interpret-trailers command.
* ks/prepare-commit-msg-sample:
hook: add a simple first example
hook: add sign-off using "interpret-trailers"
hook: name the positional variables
hook: cleanup script
Diffstat (limited to 'templates')
-rwxr-xr-x | templates/hooks--prepare-commit-msg.sample | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/templates/hooks--prepare-commit-msg.sample b/templates/hooks--prepare-commit-msg.sample index 86b8f227ec..dc707e46eb 100755 --- a/templates/hooks--prepare-commit-msg.sample +++ b/templates/hooks--prepare-commit-msg.sample @@ -9,8 +9,8 @@ # # To enable this hook, rename this file to "prepare-commit-msg". -# This hook includes three examples. The first comments out the -# "Conflicts:" part of a merge commit. +# 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 @@ -20,17 +20,23 @@ # The third example adds a Signed-off-by line to the message, that can # still be edited. This is rarely a good idea. -case "$2,$3" in - merge,) - @PERL_PATH@ -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; +COMMIT_MSG_FILE=$1 +COMMIT_SOURCE=$2 +SHA1=$3 -# ,|template,) -# @PERL_PATH@ -i.bak -pe ' -# print "\n" . `git diff --cached --name-status -r` -# if /^#/ && $first++ == 0' "$1" ;; +@PERL_PATH@ -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" - *) ;; -esac +# case "$COMMIT_SOURCE,$SHA1" in +# ,|template,) +# @PERL_PATH@ -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; +# *) ;; +# esac # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" +# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" +# if test -z "$COMMIT_SOURCE" +# then +# @PERL_PATH@ -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" +# fi |