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