d@0: #!/bin/sh d@0: # d@0: # An example hook script to prepare the commit log message. d@0: # Called by "git commit" with the name of the file that has the d@0: # commit message, followed by the description of the commit d@0: # message's source. The hook's purpose is to edit the commit d@0: # message file. If the hook fails with a non-zero status, d@0: # the commit is aborted. d@0: # d@0: # To enable this hook, rename this file to "prepare-commit-msg". d@0: d@0: # This hook includes three examples. The first comments out the d@0: # "Conflicts:" part of a merge commit. d@0: # d@0: # The second includes the output of "git diff --name-status -r" d@0: # into the message, just before the "git status" output. It is d@0: # commented because it doesn't cope with --amend or with squashed d@0: # commits. d@0: # d@0: # The third example adds a Signed-off-by line to the message, that can d@0: # still be edited. This is rarely a good idea. d@0: d@0: case "$2,$3" in d@0: merge,) d@0: /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; d@0: d@0: # ,|template,) d@0: # /usr/bin/perl -i.bak -pe ' d@0: # print "\n" . `git diff --cached --name-status -r` d@0: # if /^#/ && $first++ == 0' "$1" ;; d@0: d@0: *) ;; d@0: esac d@0: d@0: # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') d@0: # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"