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