Re: What's cooking in git.git (Dec 2013, #03; Thu, 12)

Subsystems: documentation, the rest

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

Re: What's cooking in git.git (Dec 2013, #03; Thu, 12)

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:59:27

Junio C Hamano [off-list ref] writes:
[Stalled]

* nv/commit-gpgsign-config (2013-11-06) 1 commit
 - Add the commit.gpgsign option to sign all commits

 Introduce commit.gpgsign configuration variable to force every
 commit to be GPG signed.

 Needs tests, perhaps?
Besides, we would need at least something like this to make sure
that people have a way to selectively disable configured default
when necessary, perhaps like this.

-- >8 --
Subject: [PATCH] commit-tree: add and document --no-gpg-sign

Document how to override commit.gpgsign configuration that is set to
true per "git commit" invocation (parse-options machinery lets us
say "--no-gpg-sign" to do so).

"git commit-tree" does not use parse-options, so manually add the
corresponding option for now.

Signed-off-by: Junio C Hamano <redacted>
---
 Documentation/git-commit-tree.txt | 5 +++++
 Documentation/git-commit.txt      | 4 ++++
 builtin/commit-tree.c             | 5 +++++
 3 files changed, 14 insertions(+)
diff --git a/Documentation/git-commit-tree.txt b/Documentation/git-commit-tree.txt
index cafdc96..a469eab 100644
--- a/Documentation/git-commit-tree.txt
+++ b/Documentation/git-commit-tree.txt
@@ -55,8 +55,13 @@ OPTIONS
 	from the standard input.
 
 -S[<keyid>]::
+--gpg-sign[=<keyid>]::
 	GPG-sign commit.
 
+--no-gpg-sign::
+	Countermand `commit.gpgsign` configuration variable that is
+	set to force each and every commit to be signed.
+
 
 Commit Information
 ------------------
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 1a7616c..7c42e9c 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -302,6 +302,10 @@ configuration variable documented in linkgit:git-config[1].
 --gpg-sign[=<keyid>]::
 	GPG-sign commit.
 
+--no-gpg-sign::
+	Countermand `commit.gpgsign` configuration variable that is
+	set to force each and every commit to be signed.
+
 \--::
 	Do not interpret any more arguments as options.
 
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index 1646d5b..4bf852d 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -71,6 +71,11 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
 			continue;
 		}
 
+		if (!strcmp(arg, "--no-gpgsign")) {
+			sign_commit = NULL;
+			continue;
+		}
+
 		if (!strcmp(arg, "-m")) {
 			if (argc <= ++i)
 				usage(commit_tree_usage);
-- 
1.8.5.1-272-g523f7c4

Re: What's cooking in git.git (Dec 2013, #03; Thu, 12)

From: Nicolas Vigier <hidden>
Date: 2016-06-15 22:59:27

On Sun, 15 Dec 2013, Junio C Hamano wrote:
Junio C Hamano [off-list ref] writes:
quoted
[Stalled]

* nv/commit-gpgsign-config (2013-11-06) 1 commit
 - Add the commit.gpgsign option to sign all commits

 Introduce commit.gpgsign configuration variable to force every
 commit to be GPG signed.

 Needs tests, perhaps?
Ok, I'll add some tests.
Besides, we would need at least something like this to make sure
that people have a way to selectively disable configured default
when necessary, perhaps like this.
This looks like a good idea.
quoted hunk
-- >8 --
Subject: [PATCH] commit-tree: add and document --no-gpg-sign

Document how to override commit.gpgsign configuration that is set to
true per "git commit" invocation (parse-options machinery lets us
say "--no-gpg-sign" to do so).

"git commit-tree" does not use parse-options, so manually add the
corresponding option for now.

Signed-off-by: Junio C Hamano <redacted>
---
 Documentation/git-commit-tree.txt | 5 +++++
 Documentation/git-commit.txt      | 4 ++++
 builtin/commit-tree.c             | 5 +++++
 3 files changed, 14 insertions(+)
diff --git a/Documentation/git-commit-tree.txt b/Documentation/git-commit-tree.txt
index cafdc96..a469eab 100644
--- a/Documentation/git-commit-tree.txt
+++ b/Documentation/git-commit-tree.txt
@@ -55,8 +55,13 @@ OPTIONS
 	from the standard input.
 
 -S[<keyid>]::
+--gpg-sign[=<keyid>]::
 	GPG-sign commit.
Looking at the code, commit-tree does not currently support the
"--gpg-sign=" option, only the short one -S.

If we want to add it for consistency with the --no-gpg-sign option, it
can be added with this change :
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index 1646d5b25e4f..b380d486c89a 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -71,6 +71,11 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
 			continue;
 		}
 
+		if (!memcmp(arg, "--gpg-sign=", 11)) {
+			sign_commit = arg + 11;
+			continue;
+		}
+
 		if (!strcmp(arg, "-m")) {
 			if (argc <= ++i)
 				usage(commit_tree_usage);

[PATCH] test the commit.gpgsign config option

From: Nicolas Vigier <hidden>
Date: 2016-06-15 22:59:27

The tests are checking that :

- when commit.gpgsign is true, "git commit" creates signed commits

- when commit.gpgsign is false, "git commit" creates unsigned commits

- when commit.gpgsign is true, "git commit --no-gpg-sign" creates
  unsigned commits

- when commit.gpgsign is true, "git rebase -f" creates signed commits

Signed-off-by: Nicolas Vigier <redacted>
---
 t/t7510-signed-commit.sh | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh
index 1d3c56fe61fa..537bfba76ecf 100755
--- a/t/t7510-signed-commit.sh
+++ b/t/t7510-signed-commit.sh
@@ -25,12 +25,29 @@ test_expect_success GPG 'create signed commits' '
 	git tag fourth-unsigned &&
 
 	test_tick && git commit --amend -S -m "fourth signed" &&
-	git tag fourth-signed
+	git tag fourth-signed &&
+
+	git config commit.gpgsign true &&
+	echo 5 >file && test_tick && git commit -a -m "fifth signed" &&
+	git tag fifth-signed &&
+
+	git config commit.gpgsign false &&
+	echo 6 >file && test_tick && git commit -a -m "sixth" &&
+	git tag sixth-unsigned &&
+
+	git config commit.gpgsign true &&
+	echo 7 >file && test_tick && git commit -a -m "seventh" --no-gpg-sign &&
+	git tag seventh-unsigned &&
+
+	test_tick && git rebase -f HEAD^^ && git tag sixth-signed HEAD^ &&
+	git tag seventh-signed &&
+
+	git config --unset commit.gpgsign
 '
 
 test_expect_success GPG 'show signatures' '
 	(
-		for commit in initial second merge master
+		for commit in initial second merge fourth-signed fifth-signed sixth-signed master
 		do
 			git show --pretty=short --show-signature $commit >actual &&
 			grep "Good signature from" actual || exit 1
@@ -39,7 +56,7 @@ test_expect_success GPG 'show signatures' '
 		done
 	) &&
 	(
-		for commit in merge^2 fourth-unsigned
+		for commit in merge^2 fourth-unsigned sixth-unsigned seventh-unsigned
 		do
 			git show --pretty=short --show-signature $commit >actual &&
 			grep "Good signature from" actual && exit 1
@@ -52,7 +69,7 @@ test_expect_success GPG 'show signatures' '
 test_expect_success GPG 'detect fudged signature' '
 	git cat-file commit master >raw &&
 
-	sed -e "s/fourth signed/4th forged/" raw >forged1 &&
+	sed -e "s/seventh/7th forged/" raw >forged1 &&
 	git hash-object -w -t commit forged1 >forged1.commit &&
 	git show --pretty=short --show-signature $(cat forged1.commit) >actual1 &&
 	grep "BAD signature from" actual1 &&
-- 
1.8.4.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help