rlm@11: #!/bin/sh rlm@11: # rlm@11: # An example hook script to check the commit log message. rlm@11: # Called by git-commit with one argument, the name of the file rlm@11: # that has the commit message. The hook should exit with non-zero rlm@11: # status after issuing an appropriate message if it wants to stop the rlm@11: # commit. The hook is allowed to edit the commit message file. rlm@11: # rlm@11: # To enable this hook, rename this file to "commit-msg". rlm@11: rlm@11: # Uncomment the below to add a Signed-off-by line to the message. rlm@11: # Doing this in a hook is a bad idea in general, but the prepare-commit-msg rlm@11: # hook is more suited to it. 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" rlm@11: rlm@11: # This example catches duplicate Signed-off-by lines. rlm@11: rlm@11: test "" = "$(grep '^Signed-off-by: ' "$1" | rlm@11: sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { rlm@11: echo >&2 Duplicate Signed-off-by lines. rlm@11: exit 1 rlm@11: }