Junio C Hamano | 89e2c5f | 2005-08-18 17:20:08 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # An example hook script to check the commit log message. |
Ben Walton | 100e762 | 2010-03-20 10:48:09 -0400 | [diff] [blame] | 4 | # Called by "git commit" with one argument, the name of the file |
Junio C Hamano | 89e2c5f | 2005-08-18 17:20:08 -0700 | [diff] [blame] | 5 | # that has the commit message. The hook should exit with non-zero |
| 6 | # status after issuing an appropriate message if it wants to stop the |
| 7 | # commit. The hook is allowed to edit the commit message file. |
| 8 | # |
Junio C Hamano | f98f8cb | 2008-06-24 18:45:21 -0700 | [diff] [blame] | 9 | # To enable this hook, rename this file to "commit-msg". |
Junio C Hamano | 89e2c5f | 2005-08-18 17:20:08 -0700 | [diff] [blame] | 10 | |
Andy Parkins | 59f3e25 | 2006-12-21 09:24:17 +0000 | [diff] [blame] | 11 | # Uncomment the below to add a Signed-off-by line to the message. |
Paolo Bonzini | 8089c85 | 2008-02-05 08:04:18 +0100 | [diff] [blame] | 12 | # Doing this in a hook is a bad idea in general, but the prepare-commit-msg |
| 13 | # hook is more suited to it. |
| 14 | # |
Andy Parkins | 59f3e25 | 2006-12-21 09:24:17 +0000 | [diff] [blame] | 15 | # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') |
| 16 | # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" |
| 17 | |
Junio C Hamano | 89e2c5f | 2005-08-18 17:20:08 -0700 | [diff] [blame] | 18 | # This example catches duplicate Signed-off-by lines. |
| 19 | |
| 20 | test "" = "$(grep '^Signed-off-by: ' "$1" | |
Luben Tuikov | 9a1ae9a | 2006-08-13 01:41:22 -0700 | [diff] [blame] | 21 | sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { |
| 22 | echo >&2 Duplicate Signed-off-by lines. |
| 23 | exit 1 |
| 24 | } |