Skip to content

Commit 50b26f5

Browse files
committed
Merge branch 'jc/commit-tree-ignore-commit-gpgsign'
"git commit-tree" plumbing command required the user to always sign its result when the user sets the commit.gpgsign configuration variable, which was an ancient mistake. Rework "git rebase" that relied on this mistake so that it reads commit.gpgsign and pass (or not pass) the -S option to "git commit-tree" to keep the end-user expectation the same, while teaching "git commit-tree" to ignore the configuration variable. This will stop requiring the users to sign commit objects used internally as an implementation detail of "git stash". * jc/commit-tree-ignore-commit-gpgsign: commit-tree: do not pay attention to commit.gpgsign
2 parents 17130a7 + 6694856 commit 50b26f5

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

Documentation/git-commit-tree.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ OPTIONS
6161
stuck to the option without a space.
6262

6363
--no-gpg-sign::
64-
Countermand `commit.gpgSign` configuration variable that is
65-
set to force each and every commit to be signed.
64+
Do not GPG-sign commit, to countermand a `--gpg-sign` option
65+
given earlier on the command line.
6666

6767

6868
Commit Information

builtin/commit-tree.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ static int commit_tree_config(const char *var, const char *value, void *cb)
3333
int status = git_gpg_config(var, value, NULL);
3434
if (status)
3535
return status;
36-
if (!strcmp(var, "commit.gpgsign")) {
37-
sign_commit = git_config_bool(var, value) ? "" : NULL;
38-
return 0;
39-
}
4036
return git_default_config(var, value, cb);
4137
}
4238

git-rebase.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ preserve_merges=
8787
autosquash=
8888
keep_empty=
8989
test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
90-
gpg_sign_opt=
90+
case "$(git config --bool commit.gpgsign)" in
91+
true) gpg_sign_opt=-S ;;
92+
*) gpg_sign_opt= ;;
93+
esac
9194

9295
read_basic_state () {
9396
test -f "$state_dir/head-name" &&

t/t7510-signed-commit.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,18 @@ test_expect_success GPG 'create signed commits' '
4545
git tag seventh-signed &&
4646
4747
echo 8 >file && test_tick && git commit -a -m eighth -SB7227189 &&
48-
git tag eighth-signed-alt
48+
git tag eighth-signed-alt &&
49+
50+
# commit.gpgsign is still on but this must not be signed
51+
git tag ninth-unsigned $(echo 9 | git commit-tree HEAD^{tree}) &&
52+
# explicit -S of course must sign.
53+
git tag tenth-signed $(echo 9 | git commit-tree -S HEAD^{tree})
4954
'
5055

5156
test_expect_success GPG 'verify and show signatures' '
5257
(
53-
for commit in initial second merge fourth-signed fifth-signed sixth-signed seventh-signed
58+
for commit in initial second merge fourth-signed \
59+
fifth-signed sixth-signed seventh-signed tenth-signed
5460
do
5561
git verify-commit $commit &&
5662
git show --pretty=short --show-signature $commit >actual &&
@@ -60,7 +66,8 @@ test_expect_success GPG 'verify and show signatures' '
6066
done
6167
) &&
6268
(
63-
for commit in merge^2 fourth-unsigned sixth-unsigned seventh-unsigned
69+
for commit in merge^2 fourth-unsigned sixth-unsigned \
70+
seventh-unsigned ninth-unsigned
6471
do
6572
test_must_fail git verify-commit $commit &&
6673
git show --pretty=short --show-signature $commit >actual &&

0 commit comments

Comments
 (0)