git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-commit: don't add multiple Signed-off-by: from the same identity

From
Gerrit Pape <pape@smarden.org>
Date
Jul 6, 2007, 14:42 UTC
Message-ID
<20070706144227.11736.qmail@046ba2bc1a0185.315fe32.mid.smarden.org>

If requested to signoff a commit, don't add another Signed-off-by: line to the commit message if the exact same line is already there.

This was noticed and requested by Josh Triplett through
 http://bugs.debian.org/430851
Signed-off-by: Gerrit Pape <pape@smarden.org>
---
 git-commit.sh |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/git-commit.sh b/git-commit.sh
index f866f95..7a7d19a 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -458,16 +458,18 @@ fi | git stripspace >"$GIT_DIR"/COMMIT_EDITMSG
 
 case "$signoff" in
 t)
-	need_blank_before_signoff=
+	sign=$(git-var GIT_COMMITTER_IDENT | sed -e '
+		s/>.*/>/
+		s/^/Signed-off-by: /
+		')
+	blank_before_signoff=
 	tail -n 1 "$GIT_DIR"/COMMIT_EDITMSG |
-	grep 'Signed-off-by:' >/dev/null || need_blank_before_signoff=yes
-	{
-		test -z "$need_blank_before_signoff" || echo
-		git-var GIT_COMMITTER_IDENT | sed -e '
-			s/>.*/>/
-			s/^/Signed-off-by: /
-		'
-	} >>"$GIT_DIR"/COMMIT_EDITMSG
+	grep 'Signed-off-by:' >/dev/null || blank_before_signoff='
+'
+	tail -n 1 "$GIT_DIR"/COMMIT_EDITMSG |
+	grep "$sign"$ >/dev/null ||
+	printf '%s%s\n' "$blank_before_signoff" "$sign" \
+		>>"$GIT_DIR"/COMMIT_EDITMSG
 	;;
 esac
 
-- 
1.5.2.1
Next: Gerrit Pape
Message 1 of 5 in “git-commit: don't add multiple Signed-off-by: from the same identity”
  1. git-commit: don't add multiple Signed-off-by: from the same identityGerrit Pape, Jul 6, 2007
  2. git-commit: add commit.signoff config optionGerrit Pape, Jul 6, 2007
  3. Junio C HamanoJul 6, 2007
  4. Gerrit PapeJul 8, 2007
  5. Junio C HamanoJul 8, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.