threads / patch / 5234

patchhooks--commit-msg: no silent exit on duplicate Signed-off-by lines

Subject: [PATCH] hooks--commit-msg: no silent exit on duplicate Signed-off-by lines

## tl;dr

One message between Aug 14, 2006 and Aug 14, 2006. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Luben Tuikov· Aug 14, 2006, 02:43 UTC · lore

The commit-msg hook 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 the commit-msg hook actually print out a message that duplicate Signed-off-lines were found (and thus nothing were committed).

Signed-off-by: Luben Tuikov <ltuikov@yahoo.com>
---
 templates/hooks--commit-msg |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
Show changes to templates/hooks--commit-msg +5 −2
diff --git a/templates/hooks--commit-msg b/templates/hooks--commit-msg
index 23617f3..ec2b017 100644
--- a/templates/hooks--commit-msg
+++ b/templates/hooks--commit-msg
@@ -10,5 +10,8 @@ # To enable this hook, make this file ex
 
 # This example catches duplicate Signed-off-by lines.
 
-test "" = "$(grep '^Signed-off-by: ' "$1" |
-	 sort | uniq -c | sed -e '/^[ 	]*1[ 	]/d')"
+if [ -n "$(grep '^Signed-off-by: ' "$1" |
+	sort | uniq -c | sed -e '/^[ 	]*1[ 	]/d')" ] ; then
+    echo "Duplicate Signed-off-by lines in commit message"
+    exit 1
+fi
-- 
1.4.2.g73dbd

← back to recent threads