Skip to content

Commit 5a6850e

Browse files
Paolo 'Blaisorblade' GiarrussoJunio C Hamano
authored andcommitted
Fix git-verify-tag for light-weight tags
It currently exits printing "git-cat-file SHA1: bad file", while instead we must just abort the verification for light-weight tags (e.g. referring to commit objects). [jc: tag objects can tag anything not just commits, so I fixed up the original patch slightly. you should be able to validate a signed tag that points at a blob object. ] Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 8c51242 commit 5a6850e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

git-verify-tag.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#!/bin/sh
22
. git-sh-setup || die "Not a git archive"
33

4-
tag=$(git-rev-parse $1) || exit 1
4+
type="$(git-cat-file -t "$1" 2>/dev/null)" ||
5+
die "$1: no such object."
56

6-
git-cat-file tag $tag > .tmp-vtag || exit 1
7+
test "$type" = tag ||
8+
die "$1: cannot verify a non-tag object of type $type."
9+
10+
git-cat-file tag "$1" > .tmp-vtag || exit 1
711
cat .tmp-vtag | sed '/-----BEGIN PGP/Q' | gpg --verify .tmp-vtag - || exit 1
812
rm -f .tmp-vtag

0 commit comments

Comments
 (0)