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

5 messages from 2007-07-06 to 2007-07-08. Participants: Gerrit Pape, Junio C Hamano.
Thread: https://gitlist.dev/t/8894

## Gerrit Pape, 2007-07-06 14:42

Subject: [PATCH] git-commit: don't add multiple Signed-off-by: from the same identity
Message-ID: <20070706144227.11736.qmail@046ba2bc1a0185.315fe32.mid.smarden.org>
URL: https://gitlist.dev/e/20070706144227.11736.qmail%40046ba2bc1a0185.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

```

## Gerrit Pape, 2007-07-06 14:45

Subject: [PATCH] git-commit: add commit.signoff config option
Message-ID: <20070706144543.12001.qmail@562ca05ec1cc76.315fe32.mid.smarden.org>
URL: https://gitlist.dev/e/20070706144543.12001.qmail%40562ca05ec1cc76.315fe32.mid.smarden.org
In-Reply-To: <20070706144227.11736.qmail@046ba2bc1a0185.315fe32.mid.smarden.org>

```
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(-)

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, 2007-07-06 18:11

Subject: Re: [PATCH] git-commit: don't add multiple Signed-off-by: from the same identity
Message-ID: <7vy7hte717.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vy7hte717.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20070706144227.11736.qmail@046ba2bc1a0185.315fe32.mid.smarden.org>

```
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, 2007-07-08 15:00

Subject: Re: [PATCH] git-commit: don't add multiple Signed-off-by: from the same identity
Message-ID: <20070708150055.7018.qmail@10e1f648410572.315fe32.mid.smarden.org>
URL: https://gitlist.dev/e/20070708150055.7018.qmail%4010e1f648410572.315fe32.mid.smarden.org
In-Reply-To: <7vy7hte717.fsf@assigned-by-dhcp.cox.net>

```
On Fri, Jul 06, 2007 at 11:11:48AM -0700, Junio C Hamano wrote:
> 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.

> 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, 2007-07-08 18:44

Subject: Re: [PATCH] git-commit: don't add multiple Signed-off-by: from the same identity
Message-ID: <7vr6ni20rk.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vr6ni20rk.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20070708150055.7018.qmail@10e1f648410572.315fe32.mid.smarden.org>

```
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.

```
