@@ -43,31 +43,44 @@ test_expect_success GPG 'create signed commits' '
43
43
44
44
test_tick && git rebase -f HEAD^^ && git tag sixth-signed HEAD^ &&
45
45
git tag seventh-signed
46
+
47
+ echo 8 >file && test_tick && git commit -a -m eighth -SB7227189 &&
48
+ git tag eighth-signed-alt
46
49
'
47
50
48
51
test_expect_success GPG ' show signatures' '
49
52
(
50
- for commit in initial second merge fourth-signed fifth-signed sixth-signed master
53
+ for commit in initial second merge fourth-signed fifth-signed sixth-signed seventh-signed
51
54
do
52
55
git show --pretty=short --show-signature $commit >actual &&
53
- grep "Good signature from" actual || exit 1
54
- ! grep "BAD signature from" actual || exit 1
55
- echo $commit OK
56
+ grep "Good signature from" actual &&
57
+ ! grep "BAD signature from" actual &&
58
+ echo $commit OK || exit 1
56
59
done
57
60
) &&
58
61
(
59
62
for commit in merge^2 fourth-unsigned sixth-unsigned seventh-unsigned
60
63
do
61
64
git show --pretty=short --show-signature $commit >actual &&
62
- grep "Good signature from" actual && exit 1
63
- ! grep "BAD signature from" actual || exit 1
64
- echo $commit OK
65
+ ! grep "Good signature from" actual &&
66
+ ! grep "BAD signature from" actual &&
67
+ echo $commit OK || exit 1
68
+ done
69
+ ) &&
70
+ (
71
+ for commit in eighth-signed-alt
72
+ do
73
+ git show --pretty=short --show-signature $commit >actual &&
74
+ grep "Good signature from" actual &&
75
+ ! grep "BAD signature from" actual &&
76
+ grep "not certified" actual &&
77
+ echo $commit OK || exit 1
65
78
done
66
79
)
67
80
'
68
81
69
82
test_expect_success GPG ' detect fudged signature' '
70
- git cat-file commit master >raw &&
83
+ git cat-file commit seventh-signed >raw &&
71
84
72
85
sed -e "s/seventh/7th forged/" raw >forged1 &&
73
86
git hash-object -w -t commit forged1 >forged1.commit &&
@@ -77,7 +90,7 @@ test_expect_success GPG 'detect fudged signature' '
77
90
'
78
91
79
92
test_expect_success GPG ' detect fudged signature with NUL' '
80
- git cat-file commit master >raw &&
93
+ git cat-file commit seventh-signed >raw &&
81
94
cat raw >forged2 &&
82
95
echo Qwik | tr "Q" "\000" >>forged2 &&
83
96
git hash-object -w -t commit forged2 >forged2.commit &&
@@ -94,4 +107,44 @@ test_expect_success GPG 'amending already signed commit' '
94
107
! grep "BAD signature from" actual
95
108
'
96
109
110
+ test_expect_success GPG ' show good signature with custom format' '
111
+ cat >expect <<-\EOF &&
112
+ G
113
+ 13B6F51ECDDE430D
114
+
115
+ EOF
116
+ git log -1 --format="%G?%n%GK%n%GS" sixth-signed >actual &&
117
+ test_cmp expect actual
118
+ '
119
+
120
+ test_expect_success GPG ' show bad signature with custom format' '
121
+ cat >expect <<-\EOF &&
122
+ B
123
+ 13B6F51ECDDE430D
124
+
125
+ EOF
126
+ git log -1 --format="%G?%n%GK%n%GS" $(cat forged1.commit) >actual &&
127
+ test_cmp expect actual
128
+ '
129
+
130
+ test_expect_success GPG ' show unknown signature with custom format' '
131
+ cat >expect <<-\EOF &&
132
+ U
133
+ 61092E85B7227189
134
+ Eris Discordia <[email protected] >
135
+ EOF
136
+ git log -1 --format="%G?%n%GK%n%GS" eighth-signed-alt >actual &&
137
+ test_cmp expect actual
138
+ '
139
+
140
+ test_expect_success GPG ' show lack of signature with custom format' '
141
+ cat >expect <<-\EOF &&
142
+ N
143
+
144
+
145
+ EOF
146
+ git log -1 --format="%G?%n%GK%n%GS" seventh-unsigned >actual &&
147
+ test_cmp expect actual
148
+ '
149
+
97
150
test_done
0 commit comments