blob: b58d1184a9d43a39c0d95f32453efc78581877d6 [file] [log] [blame]
Junio C Hamano89e2c5f2005-08-18 17:20:08 -07001#!/bin/sh
2#
3# An example hook script to check the commit log message.
Ben Walton100e7622010-03-20 10:48:09 -04004# Called by "git commit" with one argument, the name of the file
Junio C Hamano89e2c5f2005-08-18 17:20:08 -07005# 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 Hamanof98f8cb2008-06-24 18:45:21 -07009# To enable this hook, rename this file to "commit-msg".
Junio C Hamano89e2c5f2005-08-18 17:20:08 -070010
Andy Parkins59f3e252006-12-21 09:24:17 +000011# Uncomment the below to add a Signed-off-by line to the message.
Paolo Bonzini8089c852008-02-05 08:04:18 +010012# 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 Parkins59f3e252006-12-21 09:24:17 +000015# 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 Hamano89e2c5f2005-08-18 17:20:08 -070018# This example catches duplicate Signed-off-by lines.
19
20test "" = "$(grep '^Signed-off-by: ' "$1" |
Luben Tuikov9a1ae9a2006-08-13 01:41:22 -070021 sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
22 echo >&2 Duplicate Signed-off-by lines.
23 exit 1
24}