git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v2] commit: add commit.signoff config option
@ 2015-06-25 14:50 Caio Marcelo de Oliveira Filho
  2015-06-25 14:55 ` Junio C Hamano
  2015-06-25 16:36 ` Torsten Bögershausen
  0 siblings, 2 replies; 7+ messages in thread
From: Caio Marcelo de Oliveira Filho @ 2015-06-25 14:50 UTC (permalink / raw)
  To: git; +Cc: Caio Marcelo de Oliveira Filho

In projects that use Signed-off-by, it's convenient to include that line
in the commit message by default. The commit.signoff config option
allows to add that line in all commits automatically.

Document that this config option can be overriden by using
--no-signoff.

Signed-off-by: Caio Marcelo de Oliveira Filho <cmarcelo@gmail.com>
---

Differences from v1:
* Use test_config helper in the test
* Add bash completion for commit and config

 Documentation/config.txt               |  6 ++++++
 Documentation/git-commit.txt           |  5 +++++
 builtin/commit.c                       |  4 ++++
 contrib/completion/git-completion.bash |  4 +++-
 t/t7500-commit.sh                      | 20 ++++++++++++++++++++
 5 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 3e37b93..e019f62 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1089,6 +1089,12 @@ commit.gpgSign::
 	convenient to use an agent to avoid typing your GPG passphrase
 	several times.
 
+commit.signoff::
+
+	A boolean to enable/disable whether Signed-off-by line by the
+	committer should be added to all commits at the end of the
+	commit log messages.  Defaults to false.
+
 commit.status::
 	A boolean to enable/disable inclusion of status information in the
 	commit message template when using an editor to prepare the commit
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 904dafa..7546c7a 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -156,6 +156,11 @@ OPTIONS
 	Add Signed-off-by line by the committer at the end of the commit
 	log message.
 
+--no-signoff::
+	Countermand `commit.signoff` configuration, preventing a
+	Signed-off-by line to be added at the end of the commit log
+	message.
+
 -n::
 --no-verify::
 	This option bypasses the pre-commit and commit-msg hooks.
diff --git a/builtin/commit.c b/builtin/commit.c
index 254477f..5cfbe57 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1505,6 +1505,10 @@ static int git_commit_config(const char *k, const char *v, void *cb)
 		sign_commit = git_config_bool(k, v) ? "" : NULL;
 		return 0;
 	}
+	if (!strcmp(k, "commit.signoff")) {
+		signoff = git_config_bool(k, v);
+		return 0;
+	}
 
 	status = git_gpg_config(k, v, NULL);
 	if (status)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c97c648..7a79a89 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1123,7 +1123,8 @@ _git_commit ()
 		;;
 	--*)
 		__gitcomp "
-			--all --author= --signoff --verify --no-verify
+			--all --author=
+			--signoff --no-signoff --verify --no-verify
 			--edit --no-edit
 			--amend --include --only --interactive
 			--dry-run --reuse-message= --reedit-message=
@@ -2009,6 +2010,7 @@ _git_config ()
 		color.status.untracked
 		color.status.updated
 		color.ui
+		commit.signoff
 		commit.status
 		commit.template
 		core.abbrev
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index 116885a..949272d 100755
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
@@ -179,6 +179,26 @@ test_expect_success '--signoff' '
 	test_cmp expect output
 '
 
+test_expect_success 'commit.signoff config option' '
+	test_config commit.signoff true &&
+	echo "yet another content *narf*" >> foo &&
+	echo "zort" | git commit -F - foo &&
+	git cat-file commit HEAD | sed "1,/^\$/d" > output &&
+	test_cmp expect output
+'
+
+cat > expect <<EOF
+no signed off by here
+EOF
+
+test_expect_success '--no-signoff' '
+	test_config commit.signoff true &&
+	echo "yet another content *narf*" >> foo &&
+	echo "no signed off by here" | git commit --no-signoff -F - foo &&
+	git cat-file commit HEAD | sed "1,/^\$/d" > output &&
+	test_cmp expect output
+'
+
 test_expect_success 'commit message from file (1)' '
 	mkdir subdir &&
 	echo "Log in top directory" >log &&
-- 
2.4.4.489.g5bc41de

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] commit: add commit.signoff config option
  2015-06-25 14:50 [PATCH v2] commit: add commit.signoff config option Caio Marcelo de Oliveira Filho
@ 2015-06-25 14:55 ` Junio C Hamano
  2015-06-25 15:08   ` Johannes Löthberg
  2015-06-25 15:19   ` Caio Marcelo de Oliveira Filho
  2015-06-25 16:36 ` Torsten Bögershausen
  1 sibling, 2 replies; 7+ messages in thread
From: Junio C Hamano @ 2015-06-25 14:55 UTC (permalink / raw)
  To: Caio Marcelo de Oliveira Filho; +Cc: git

Caio Marcelo de Oliveira Filho <cmarcelo@gmail.com> writes:

> In projects that use Signed-off-by, it's convenient to include that line
> in the commit message by default. The commit.signoff config option

Hmm, I do not recall seeing v1 but that is OK.

The following immediately comes to mind.

http://thread.gmane.org/gmane.comp.version-control.git/51754/focus=51780

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] commit: add commit.signoff config option
  2015-06-25 14:55 ` Junio C Hamano
@ 2015-06-25 15:08   ` Johannes Löthberg
  2015-06-25 15:19   ` Caio Marcelo de Oliveira Filho
  1 sibling, 0 replies; 7+ messages in thread
From: Johannes Löthberg @ 2015-06-25 15:08 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 515 bytes --]

On 25/06, Junio C Hamano wrote:
>Caio Marcelo de Oliveira Filho <cmarcelo@gmail.com> writes:
>Hmm, I do not recall seeing v1 but that is OK.
>
>The following immediately comes to mind.
>
>http://thread.gmane.org/gmane.comp.version-control.git/51754/focus=51780

To be honest I'm not sure I buy that since we have `git commit -s`, 
which is just as easily added as a really simple git alias.

-- 
Sincerely,
  Johannes Löthberg
  PGP Key ID: 0x50FB9B273A9D0BB5
  https://theos.kyriasis.com/~kyrias/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1495 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] commit: add commit.signoff config option
  2015-06-25 14:55 ` Junio C Hamano
  2015-06-25 15:08   ` Johannes Löthberg
@ 2015-06-25 15:19   ` Caio Marcelo de Oliveira Filho
  2015-06-25 16:01     ` Junio C Hamano
  1 sibling, 1 reply; 7+ messages in thread
From: Caio Marcelo de Oliveira Filho @ 2015-06-25 15:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Hi,

> Hmm, I do not recall seeing v1 but that is OK.

http://thread.gmane.org/gmane.comp.version-control.git/272635
http://thread.gmane.org/gmane.comp.version-control.git/272636


> The following immediately comes to mind.
>
> http://thread.gmane.org/gmane.comp.version-control.git/51754/focus=51780

Thanks for the reference, amazed that I ended up using the same title!
From the thread:

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

This is a fair point. However I've seen that in practice, in some
cases it's easier
to consider the DCO as the rules for contributing to the entire
project. In those
cases people tend to use commit templates or aliases or hooks, which in practice
automate the signing off act anyway.

A similar concern probably applies to format.signOff option. Would be sufficient
to add a note about conscious act (like format.signOff has) to the
config description?


-- 
Caio Marcelo de Oliveira Filho

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] commit: add commit.signoff config option
  2015-06-25 15:19   ` Caio Marcelo de Oliveira Filho
@ 2015-06-25 16:01     ` Junio C Hamano
  2015-06-25 18:56       ` Matthieu Moy
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2015-06-25 16:01 UTC (permalink / raw)
  To: Caio Marcelo de Oliveira Filho; +Cc: git

Caio Marcelo de Oliveira Filho <cmarcelo@gmail.com> writes:

> A similar concern probably applies to format.signOff option. Would
> be sufficient to add a note about conscious act (like
> format.signOff has) to the config description?

I am generally in negative on automating this.  This is not just you
but makes everybody else's S-o-b less and less meaningful ("Their
tool have ways to add that string randomly, and many of these ways
the user ends up adding that string without even conciously thinking
what they are doing.  Does that string even mean anything anymore?").

One solution might be to make this not a straight-forward boolean,
but an option that superficially takes a string and treats one
specific value as "true" and everything else as "false", e.g.

[commit]
    signoff = "I certify that all my work is licenseable under DCO"

I dunno.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] commit: add commit.signoff config option
  2015-06-25 14:50 [PATCH v2] commit: add commit.signoff config option Caio Marcelo de Oliveira Filho
  2015-06-25 14:55 ` Junio C Hamano
@ 2015-06-25 16:36 ` Torsten Bögershausen
  1 sibling, 0 replies; 7+ messages in thread
From: Torsten Bögershausen @ 2015-06-25 16:36 UTC (permalink / raw)
  To: Caio Marcelo de Oliveira Filho, git

On 2015-06-25 16.50, Caio Marcelo de Oliveira Filho wrote:

> +test_expect_success 'commit.signoff config option' '
> +	test_config commit.signoff true &&
> +	echo "yet another content *narf*" >> foo &&

Minor nit:
The > or >> should be written without a space, like this:
>>foo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] commit: add commit.signoff config option
  2015-06-25 16:01     ` Junio C Hamano
@ 2015-06-25 18:56       ` Matthieu Moy
  0 siblings, 0 replies; 7+ messages in thread
From: Matthieu Moy @ 2015-06-25 18:56 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Caio Marcelo de Oliveira Filho, git

Junio C Hamano <gitster@pobox.com> writes:

> [commit]
>     signoff = "I certify that all my work is licenseable under DCO"

I like this one.

The paranoid version would be

    signoff = "I certify that all my work in /home/my/projects/foo are ..."

to avoid mistakenly have the config option applied to the wrong repo.
But that's probably overkill.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-06-25 18:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-25 14:50 [PATCH v2] commit: add commit.signoff config option Caio Marcelo de Oliveira Filho
2015-06-25 14:55 ` Junio C Hamano
2015-06-25 15:08   ` Johannes Löthberg
2015-06-25 15:19   ` Caio Marcelo de Oliveira Filho
2015-06-25 16:01     ` Junio C Hamano
2015-06-25 18:56       ` Matthieu Moy
2015-06-25 16:36 ` Torsten Bögershausen

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).