threads / patch / 8894

patchgit-commit: don't add multiple Signed-off-by: from the same identity

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

## tl;dr

5 messages between Jul 6, 2007 and Jul 8, 2007. Diffs are folded; open one to read it.

replies: 4people: 2as markdown or json

Gerrit Pape· Jul 6, 2007, 14:42 UTC · lore

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(-)
Show changes to git-commit.sh +11 −9
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
Gerrit Pape· Jul 6, 2007, 14:45 UTC · re: Gerrit Pape · lore

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

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 <pape@smarden.org>
---
 git-commit.sh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Show changes to git-commit.sh +1 −0
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
Junio C Hamano· Jul 6, 2007, 18:11 UTC · re: Gerrit Pape · lore

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

If you are trying to avoid a run of Signed-off-by: lines like this:
	Signed-off-by: Original Author <oa@example.com>
	Signed-off-by: First Reviewer <fr@example.com>
	Signed-off-by: Second Reviewer <sr@example.com>
	Signed-off-by: Original Author <oa@example.com>
	Signed-off-by: Subsystem Integrator <si@example.com>
It is not a bug.  If the last signed-off-by is not from
yourself, your signed-off-by is added when you ask with "-s",
and this is very much intentionally done to follow the existing
practice of patch passing done in the kernel community, where
Signed-off-by: was invented (Linus or somebody from the kernel
circle can correct me if I am wrong).

When you are passing patches around, tweaks to the patch contents can be made. If your patch comes back to you from the second reviewer, it is not what you originally sent out. You would want to sign it off again.

We have deliberately excluded what your other patch tries to do for a reason. Even though these lines are not digitally signed, the intent of adding a Signed-off-by: line with your name is that you are certifying its origin, according to the definition of DCO (see Documentation/SubmittingPatches). This should be a conscious act from the signer's part, and making it automatic with a config variable that you set once and forget makes it much less meaningful.

        
        
Gerrit Pape· Jul 8, 2007, 15:00 UTC · re: Junio C Hamano · lore

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

On Fri, Jul 06, 2007 at 11:11:48AM -0700, Junio C Hamano wrote:
Show 10 quoted lines
> If you are trying to avoid a run of Signed-off-by: lines like this:
> 
> 	Signed-off-by: Original Author <oa@example.com>
> 	Signed-off-by: First Reviewer <fr@example.com>
> 	Signed-off-by: Second Reviewer <sr@example.com>
> 	Signed-off-by: Original Author <oa@example.com>
> 	Signed-off-by: Subsystem Integrator <si@example.com>
> 
> It is not a bug.  If the last signed-off-by is not from
> yourself, your signed-off-by is added when you ask with "-s",

This is what the patch does, it only checks against the final line, sorry, the subject is incorrect. The behavior currently is

 $ ./git-commit -m foo foo
 Created commit 2fad03e: foo
  0 files changed, 0 insertions(+), 0 deletions(-)
  create mode 100644 foo
 $ EDITOR=cat ./git-commit --amend -s foo |head -n4
 foo
 Signed-off-by: Gerrit Pape <pape@smarden.org>
 $ EDITOR=cat ./git-commit --amend -s foo |head -n4
 foo
 Signed-off-by: Gerrit Pape <pape@smarden.org>
 Signed-off-by: Gerrit Pape <pape@smarden.org>
 $ 

with the patch, iff the last line already was the signoff to be added, it won't be added again.

Show 8 quoted lines
> We have deliberately excluded what your other patch tries to do
> for a reason.  Even though these lines are not digitally signed,
> the intent of adding a Signed-off-by: line with your name is
> that you are certifying its origin, according to the definition
> of DCO (see Documentation/SubmittingPatches).  This should be a
> conscious act from the signer's part, and making it automatic
> with a config variable that you set once and forget makes it
> much less meaningful.

Okay, to me personally it would be convenient, for the git repository I have no problem with, and want to simply singoff all commits, for other repos none.

Regards, Gerrit.
Junio C Hamano· Jul 8, 2007, 18:44 UTC · re: Gerrit Pape · lore

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

Gerrit Pape <pape@smarden.org> writes:
> with the patch, iff the last line already was the signoff to be added,
> it won't be added again.
Ah, I completely misread the patch.  Thanks.

← back to recent threads