Skip to content

Commit 3d5854e

Browse files
Michael J Grubergitster
authored andcommitted
tag: recognize rfc1991 signatures
We have always been creating rfc1991 signatures for users with "rfc1991" in their gpg config but failed to recognize them (tag -l -n largenumber) and verify them (tag -v, verify-tag). Make good use of the refactored signature detection and let us recognize and verify those signatures also. Signed-off-by: Michael J Gruber <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 81536b2 commit 3d5854e

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

t/t7004-tag.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,19 +1048,19 @@ cp "$1" actual
10481048
EOF
10491049
chmod +x fakeeditor
10501050

1051-
test_expect_failure GPG \
1051+
test_expect_success GPG \
10521052
'reediting a signed tag body omits signature' '
10531053
echo "RFC1991 signed tag" >expect &&
10541054
GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
10551055
test_cmp expect actual
10561056
'
10571057

1058-
test_expect_failure GPG \
1058+
test_expect_success GPG \
10591059
'verifying rfc1991 signature' '
10601060
git tag -v rfc1991-signed-tag
10611061
'
10621062

1063-
test_expect_failure GPG \
1063+
test_expect_success GPG \
10641064
'list tag with rfc1991 signature' '
10651065
echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
10661066
git tag -l -n1 rfc1991-signed-tag >actual &&
@@ -1073,12 +1073,12 @@ test_expect_failure GPG \
10731073

10741074
rm -f gpghome/gpg.conf
10751075

1076-
test_expect_failure GPG \
1076+
test_expect_success GPG \
10771077
'verifying rfc1991 signature without --rfc1991' '
10781078
git tag -v rfc1991-signed-tag
10791079
'
10801080

1081-
test_expect_failure GPG \
1081+
test_expect_success GPG \
10821082
'list tag with rfc1991 signature without --rfc1991' '
10831083
echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
10841084
git tag -l -n1 rfc1991-signed-tag >actual &&
@@ -1089,7 +1089,7 @@ test_expect_failure GPG \
10891089
test_cmp expect actual
10901090
'
10911091

1092-
test_expect_failure GPG \
1092+
test_expect_success GPG \
10931093
'reediting a signed tag body omits signature' '
10941094
echo "RFC1991 signed tag" >expect &&
10951095
GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&

tag.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "blob.h"
66

77
#define PGP_SIGNATURE "-----BEGIN PGP SIGNATURE-----"
8+
#define PGP_MESSAGE "-----BEGIN PGP MESSAGE-----"
89

910
const char *tag_type = "tag";
1011

@@ -140,7 +141,8 @@ size_t parse_signature(const char *buf, unsigned long size)
140141
{
141142
char *eol;
142143
size_t len = 0;
143-
while (len < size && prefixcmp(buf + len, PGP_SIGNATURE)) {
144+
while (len < size && prefixcmp(buf + len, PGP_SIGNATURE) &&
145+
prefixcmp(buf + len, PGP_MESSAGE)) {
144146
eol = memchr(buf + len, '\n', size - len);
145147
len += eol ? eol - (buf + len) + 1 : size - len;
146148
}

0 commit comments

Comments
 (0)