merge: add config option for verifySignatures
git merge --verify-signatures can be used to verify that the tip commit of the branch being merged in is properly signed, but it's cumbersome to have to specify that every time. Add a configuration option that enables this behaviour by default, which can be overridden by --no-verify-signatures. Signed-off-by: Hans Jerry Illikainen <hji@dyntopia.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Hans Jerry Illikainen committed
Dec 10, 2017 at 06:53 UTC
ca779e82c9f263dfdea2a73a4f5494b37bc8aae7
3 files changed
+45
Documentation/merge-config.txt
+4
@@ -26,6 +26,10 @@ merge.ff::
26
allowed (equivalent to giving the `--ff-only` option from the
27
command line).
28
29
+merge.verifySignatures::
30
+ If true, this is equivalent to the --verify-signatures command
31
+ line option. See linkgit:git-merge[1] for details.
32
+
33
include::fmt-merge-msg-config.txt[]
34
35
merge.renameLimit::
builtin/merge.c
+2
@@ -567,6 +567,8 @@ static int git_merge_config(const char *k, const char *v, void *cb)
567
568
if (!strcmp(k, "merge.diffstat") || !strcmp(k, "merge.stat"))
569
show_diffstat = git_config_bool(k, v);
570
+ else if (!strcmp(k, "merge.verifysignatures"))
571
+ verify_signatures = git_config_bool(k, v);
572
else if (!strcmp(k, "pull.twohead"))
573
return git_config_string(&pull_twohead, k, v);
574
else if (!strcmp(k, "pull.octopus"))
t/t7612-merge-verify-signatures.sh
+39
@@ -39,23 +39,62 @@ test_expect_success GPG 'merge unsigned commit with verification' '
39
test_i18ngrep "does not have a GPG signature" mergeerror
40
'
41
42
+test_expect_success GPG 'merge unsigned commit with merge.verifySignatures=true' '
43
+ test_config merge.verifySignatures true &&
44
+ test_must_fail git merge --ff-only side-unsigned 2>mergeerror &&
45
+ test_i18ngrep "does not have a GPG signature" mergeerror
46
+'
47
+
48
test_expect_success GPG 'merge commit with bad signature with verification' '
49
test_must_fail git merge --ff-only --verify-signatures $(cat forged.commit) 2>mergeerror &&
50
test_i18ngrep "has a bad GPG signature" mergeerror
51
'
52
53
+test_expect_success GPG 'merge commit with bad signature with merge.verifySignatures=true' '
54
+ test_config merge.verifySignatures true &&
55
+ test_must_fail git merge --ff-only $(cat forged.commit) 2>mergeerror &&
56
+ test_i18ngrep "has a bad GPG signature" mergeerror
57
+'
58
+
59
test_expect_success GPG 'merge commit with untrusted signature with verification' '
60
test_must_fail git merge --ff-only --verify-signatures side-untrusted 2>mergeerror &&
61
test_i18ngrep "has an untrusted GPG signature" mergeerror
62
'
63
64
+test_expect_success GPG 'merge commit with untrusted signature with merge.verifySignatures=true' '
65
+ test_config merge.verifySignatures true &&
66
+ test_must_fail git merge --ff-only side-untrusted 2>mergeerror &&
67
+ test_i18ngrep "has an untrusted GPG signature" mergeerror
68
+'
69
+
70
test_expect_success GPG 'merge signed commit with verification' '
71
+ test_when_finished "git checkout initial" &&
72
git merge --verbose --ff-only --verify-signatures side-signed >mergeoutput &&
73
test_i18ngrep "has a good GPG signature" mergeoutput
74
'
75
76
+test_expect_success GPG 'merge signed commit with merge.verifySignatures=true' '
77
+ test_when_finished "git checkout initial" &&
78
+ test_config merge.verifySignatures true &&
79
+ git merge --verbose --ff-only side-signed >mergeoutput &&
80
+ test_i18ngrep "has a good GPG signature" mergeoutput
81
+'
82
+
83
test_expect_success GPG 'merge commit with bad signature without verification' '
84
+ test_when_finished "git checkout initial" &&
85
+ git merge $(cat forged.commit)
86
+'
87
+
88
+test_expect_success GPG 'merge commit with bad signature with merge.verifySignatures=false' '
89
+ test_when_finished "git checkout initial" &&
90
+ test_config merge.verifySignatures false &&
91
git merge $(cat forged.commit)
92
'
93
94
+test_expect_success GPG 'merge commit with bad signature with merge.verifySignatures=true and --no-verify-signatures' '
95
+ test_when_finished "git checkout initial" &&
96
+ test_config merge.verifySignatures true &&
97
+ git merge --no-verify-signatures $(cat forged.commit)
98
+'
99
+
100
test_done