]> git.ipfire.org Git - thirdparty/git.git/blame - contrib/examples/git-verify-tag.sh
Merge branch 'sm/mv-dry-run-update' into maint
[thirdparty/git.git] / contrib / examples / git-verify-tag.sh
CommitLineData
f336e71f 1#!/bin/sh
d6ea70af 2
34970121
FK
3USAGE='<tag>'
4SUBDIRECTORY_OK='Yes'
5. git-sh-setup
f336e71f 6
a0f15fa5 7verbose=
822f7c73 8while test $# != 0
a0f15fa5
JH
9do
10 case "$1" in
11 -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
12 verbose=t ;;
13 *)
14 break ;;
15 esac
16 shift
17done
18
34970121
FK
19if [ "$#" != "1" ]
20then
a0f15fa5 21 usage
34970121 22fi
d165fa14 23
5be60078 24type="$(git cat-file -t "$1" 2>/dev/null)" ||
5a6850e8 25 die "$1: no such object."
f336e71f 26
5a6850e8
PBG
27test "$type" = tag ||
28 die "$1: cannot verify a non-tag object of type $type."
29
a0f15fa5
JH
30case "$verbose" in
31t)
5be60078 32 git cat-file -p "$1" |
a0f15fa5
JH
33 sed -n -e '/^-----BEGIN PGP SIGNATURE-----/q' -e p
34 ;;
35esac
36
60c0f846
JH
37trap 'rm -f "$GIT_DIR/.tmp-vtag"' 0
38
5be60078 39git cat-file tag "$1" >"$GIT_DIR/.tmp-vtag" || exit 1
bfc04bb9
SP
40sed -n -e '
41 /^-----BEGIN PGP SIGNATURE-----$/q
42 p
43' <"$GIT_DIR/.tmp-vtag" |
d6ea70af
JH
44gpg --verify "$GIT_DIR/.tmp-vtag" - || exit 1
45rm -f "$GIT_DIR/.tmp-vtag"