Skip to content

Commit e7b120b

Browse files
committed
Merge branch 'br/commit-tree-fully-spelled-gpg-sign-option'
The documentation of "git commit-tree" said that the command understands "--gpg-sign" in addition to "-S", but the command line parser did not know about the longhand, which has been corrected. * br/commit-tree-fully-spelled-gpg-sign-option: commit-tree: add missing --gpg-sign flag t7510: invoke git as part of &&-chain
2 parents e524e44 + 70ddbd7 commit e7b120b

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

builtin/commit-tree.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
6666
continue;
6767
}
6868

69-
if (skip_prefix(arg, "-S", &sign_commit))
69+
if (!strcmp(arg, "--gpg-sign")) {
70+
sign_commit = "";
71+
continue;
72+
}
73+
74+
if (skip_prefix(arg, "-S", &sign_commit) ||
75+
skip_prefix(arg, "--gpg-sign=", &sign_commit))
7076
continue;
7177

7278
if (!strcmp(arg, "--no-gpg-sign")) {

t/t7510-signed-commit.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,28 @@ test_expect_success GPG 'create signed commits' '
4949
git tag eighth-signed-alt &&
5050
5151
# commit.gpgsign is still on but this must not be signed
52-
git tag ninth-unsigned $(echo 9 | git commit-tree HEAD^{tree}) &&
52+
echo 9 | git commit-tree HEAD^{tree} >oid &&
53+
test_line_count = 1 oid &&
54+
git tag ninth-unsigned $(cat oid) &&
5355
# explicit -S of course must sign.
54-
git tag tenth-signed $(echo 9 | git commit-tree -S HEAD^{tree})
56+
echo 10 | git commit-tree -S HEAD^{tree} >oid &&
57+
test_line_count = 1 oid &&
58+
git tag tenth-signed $(cat oid) &&
59+
60+
# --gpg-sign[=<key-id>] must sign.
61+
echo 11 | git commit-tree --gpg-sign HEAD^{tree} >oid &&
62+
test_line_count = 1 oid &&
63+
git tag eleventh-signed $(cat oid) &&
64+
echo 12 | git commit-tree --gpg-sign=B7227189 HEAD^{tree} >oid &&
65+
test_line_count = 1 oid &&
66+
git tag twelfth-signed-alt $(cat oid)
5567
'
5668

5769
test_expect_success GPG 'verify and show signatures' '
5870
(
5971
for commit in initial second merge fourth-signed \
60-
fifth-signed sixth-signed seventh-signed tenth-signed
72+
fifth-signed sixth-signed seventh-signed tenth-signed \
73+
eleventh-signed
6174
do
6275
git verify-commit $commit &&
6376
git show --pretty=short --show-signature $commit >actual &&
@@ -78,7 +91,7 @@ test_expect_success GPG 'verify and show signatures' '
7891
done
7992
) &&
8093
(
81-
for commit in eighth-signed-alt
94+
for commit in eighth-signed-alt twelfth-signed-alt
8295
do
8396
git show --pretty=short --show-signature $commit >actual &&
8497
grep "Good signature from" actual &&

0 commit comments

Comments
 (0)