contrib / examples / git-verify-tag.shon commit Merge branch 'sb/http-flaky-test-fix' (c92df72)
   1#!/bin/sh
   2
   3USAGE='<tag>'
   4SUBDIRECTORY_OK='Yes'
   5. git-sh-setup
   6
   7verbose=
   8while test $# != 0
   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
  19if [ "$#" != "1" ]
  20then
  21        usage
  22fi
  23
  24type="$(git cat-file -t "$1" 2>/dev/null)" ||
  25        die "$1: no such object."
  26
  27test "$type" = tag ||
  28        die "$1: cannot verify a non-tag object of type $type."
  29
  30case "$verbose" in
  31t)
  32        git cat-file -p "$1" |
  33        sed -n -e '/^-----BEGIN PGP SIGNATURE-----/q' -e p
  34        ;;
  35esac
  36
  37trap 'rm -f "$GIT_DIR/.tmp-vtag"' 0
  38
  39git cat-file tag "$1" >"$GIT_DIR/.tmp-vtag" || exit 1
  40sed -n -e '
  41        /^-----BEGIN PGP SIGNATURE-----$/q
  42        p
  43' <"$GIT_DIR/.tmp-vtag" |
  44gpg --verify "$GIT_DIR/.tmp-vtag" - || exit 1
  45rm -f "$GIT_DIR/.tmp-vtag"