From e77235ea38385a127d2afc969435a56d3ff2b16d Mon Sep 17 00:00:00 2001 From: Luben Tuikov <ltuikov@yahoo.com> Date: Sun, 13 Aug 2006 00:34:37 -0700 Subject: [PATCH 1/2] Fix regex pattern in commit-msg Between the count and the line output, some uniq(1) versions put a TAB character, not a space. Make sure both are handled. Signed-off-by: Luben Tuikov <ltuikov@yahoo.com> Signed-off-by: Junio C Hamano <junkio@cox.net> --- templates/hooks--commit-msg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/hooks--commit-msg b/templates/hooks--commit-msg index 643822d2351..23617f39061 100644 --- a/templates/hooks--commit-msg +++ b/templates/hooks--commit-msg @@ -11,4 +11,4 @@ # This example catches duplicate Signed-off-by lines. test "" = "$(grep '^Signed-off-by: ' "$1" | - sort | uniq -c | sed -e '/^[ ]*1 /d')" + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" From 9a1ae9ab03abaffc977421f182997f3e735e7098 Mon Sep 17 00:00:00 2001 From: Luben Tuikov <ltuikov@yahoo.com> Date: Sun, 13 Aug 2006 01:41:22 -0700 Subject: [PATCH 2/2] sample commit-msg hook: no silent exit on duplicate Signed-off-by lines git-commit would silently exit if duplicate Signed-off-by lines were found. Users of git-commit would not know it, unless they checked '$?'. This patch makes git-commit actually print out a message that nothing was commited since duplicate Signed-off-lines were found. Signed-off-by: Luben Tuikov <ltuikov@yahoo.com> Signed-off-by: Junio C Hamano <junkio@cox.net> --- templates/hooks--commit-msg | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/hooks--commit-msg b/templates/hooks--commit-msg index 23617f39061..0b906caa98f 100644 --- a/templates/hooks--commit-msg +++ b/templates/hooks--commit-msg @@ -11,4 +11,8 @@ # This example catches duplicate Signed-off-by lines. test "" = "$(grep '^Signed-off-by: ' "$1" | - sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} +