@@ -43,31 +43,44 @@ test_expect_success GPG 'create signed commits' '
4343
4444 test_tick && git rebase -f HEAD^^ && git tag sixth-signed HEAD^ &&
4545 git tag seventh-signed
46+
47+ echo 8 >file && test_tick && git commit -a -m eighth -SB7227189 &&
48+ git tag eighth-signed-alt
4649'
4750
4851test_expect_success GPG ' show signatures' '
4952 (
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
5154 do
5255 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
5659 done
5760 ) &&
5861 (
5962 for commit in merge^2 fourth-unsigned sixth-unsigned seventh-unsigned
6063 do
6164 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
6578 done
6679 )
6780'
6881
6982test_expect_success GPG ' detect fudged signature' '
70- git cat-file commit master >raw &&
83+ git cat-file commit seventh-signed >raw &&
7184
7285 sed -e "s/seventh/7th forged/" raw >forged1 &&
7386 git hash-object -w -t commit forged1 >forged1.commit &&
@@ -77,7 +90,7 @@ test_expect_success GPG 'detect fudged signature' '
7790'
7891
7992test_expect_success GPG ' detect fudged signature with NUL' '
80- git cat-file commit master >raw &&
93+ git cat-file commit seventh-signed >raw &&
8194 cat raw >forged2 &&
8295 echo Qwik | tr "Q" "\000" >>forged2 &&
8396 git hash-object -w -t commit forged2 >forged2.commit &&
@@ -94,4 +107,44 @@ test_expect_success GPG 'amending already signed commit' '
94107 ! grep "BAD signature from" actual
95108'
96109
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+
97150test_done
0 commit comments