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

Subsystems: the rest

DORMANTno replies

2 messages, 1 author, 2016-06-15 · open the first message on its own page

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

From: Gerrit Pape <hidden>
Date: 2016-06-15 22:43:20

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 <redacted>
---
 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

[PATCH] git-commit: add commit.signoff config option

From: Gerrit Pape <hidden>
Date: 2016-06-15 22:43:20

Have the commit.signoff boolean config option automatically add a
Signed-off-by: by git-commit, without giving the -s switch explicitly.

Signed-off-by: Gerrit Pape <redacted>
---
 git-commit.sh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/git-commit.sh b/git-commit.sh
index 7a7d19a..b493820 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -275,6 +275,7 @@ $1"
 	esac
 done
 case "$edit_flag" in t) no_edit= ;; esac
+test "$(git config --bool commit.signoff)" != true || signoff=t
 
 ################################################################
 # Sanity check options
-- 
1.5.2.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help