2 # Copyright (c) 2005 Linus Torvalds
4 USAGE='-l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d] [-m <msg>] <tagname> [<head>]'
15 while case "$#" in 0) break ;; esac
34 git rev-parse --symbolic --tags | sort | grep "$@"
41 if test "$#" = "0"; then
42 die "error: option -m needs an argument"
57 tag=$(git-show-ref --verify --hash -- "refs/tags/$tag_name") ||
58 die "Seriously, what tag are you talking about?"
59 git-update-ref -m 'tag: delete' -d "refs/tags/$tag_name" "$tag" &&
60 echo "Deleted tag $tag_name."
75 prev=0000000000000000000000000000000000000000
76 if git-show-ref --verify --quiet -- "refs/tags/$name"
78 test -n "$force" || die "tag '$name' already exists"
79 prev=`git rev-parse "refs/tags/$name"`
82 git-check-ref-format "tags/$name" ||
83 die "we do not like '$name' as a tag name."
85 object=$(git-rev-parse --verify --default HEAD "$@") || exit 1
86 type=$(git-cat-file -t $object) || exit 1
87 tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1
88 : ${username:=$(expr "z$tagger" : 'z\(.*>\)')}
90 trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0
92 if [ "$annotate" ]; then
93 if [ -z "$message_given" ]; then
95 echo "# Write a tag message"
96 echo "#" ) > "$GIT_DIR"/TAG_EDITMSG
97 ${VISUAL:-${EDITOR:-vi}} "$GIT_DIR"/TAG_EDITMSG || exit
99 echo "$message" >"$GIT_DIR"/TAG_EDITMSG
102 grep -v '^#' <"$GIT_DIR"/TAG_EDITMSG |
103 git-stripspace >"$GIT_DIR"/TAG_FINALMSG
105 [ -s "$GIT_DIR"/TAG_FINALMSG -o -n "$message_given" ] || {
106 echo >&2 "No tag message?"
110 ( printf 'object %s\ntype %s\ntag %s\ntagger %s\n\n' \
111 "$object" "$type" "$name" "$tagger";
112 cat "$GIT_DIR"/TAG_FINALMSG ) >"$GIT_DIR"/TAG_TMP
113 rm -f "$GIT_DIR"/TAG_TMP.asc "$GIT_DIR"/TAG_FINALMSG
114 if [ "$signed" ]; then
115 gpg -bsa -u "$username" "$GIT_DIR"/TAG_TMP &&
116 cat "$GIT_DIR"/TAG_TMP.asc >>"$GIT_DIR"/TAG_TMP ||
117 die "failed to sign the tag with GPG."
119 object=$(git-mktag < "$GIT_DIR"/TAG_TMP)
122 git update-ref "refs/tags/$name" "$object" "$prev"