2 # Copyright (c) 2005 Linus Torvalds
4 USAGE='-l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg>] <tagname> [<head>]'
16 while case "$#" in 0) break ;; esac
35 git rev-parse --symbolic --tags | sort | grep "$@"
42 if test "$#" = "0"; then
43 die "error: option -m needs an argument"
51 if test "$#" = "0"; then
52 die "error: option -F needs an argument"
69 cur=$(git-show-ref --verify --hash -- "refs/tags/$tag") || {
70 echo >&2 "Seriously, what tag are you talking about?"
74 git-update-ref -m 'tag: delete' -d "refs/tags/$tag" "$cur" || {
78 echo "Deleted tag $tag."
85 tag=$(git-show-ref --verify --hash -- "refs/tags/$tag_name") ||
86 die "Seriously, what tag are you talking about?"
87 git-verify-tag -v "$tag"
102 prev=0000000000000000000000000000000000000000
103 if git-show-ref --verify --quiet -- "refs/tags/$name"
105 test -n "$force" || die "tag '$name' already exists"
106 prev=`git rev-parse "refs/tags/$name"`
109 git-check-ref-format "tags/$name" ||
110 die "we do not like '$name' as a tag name."
112 object=$(git-rev-parse --verify --default HEAD "$@") || exit 1
113 type=$(git-cat-file -t $object) || exit 1
114 tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1
115 : ${username:=$(expr "z$tagger" : 'z\(.*>\)')}
117 trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0
119 if [ "$annotate" ]; then
120 if [ -z "$message_given" ]; then
122 echo "# Write a tag message"
123 echo "#" ) > "$GIT_DIR"/TAG_EDITMSG
124 ${VISUAL:-${EDITOR:-vi}} "$GIT_DIR"/TAG_EDITMSG || exit
126 echo "$message" >"$GIT_DIR"/TAG_EDITMSG
129 grep -v '^#' <"$GIT_DIR"/TAG_EDITMSG |
130 git-stripspace >"$GIT_DIR"/TAG_FINALMSG
132 [ -s "$GIT_DIR"/TAG_FINALMSG -o -n "$message_given" ] || {
133 echo >&2 "No tag message?"
137 ( printf 'object %s\ntype %s\ntag %s\ntagger %s\n\n' \
138 "$object" "$type" "$name" "$tagger";
139 cat "$GIT_DIR"/TAG_FINALMSG ) >"$GIT_DIR"/TAG_TMP
140 rm -f "$GIT_DIR"/TAG_TMP.asc "$GIT_DIR"/TAG_FINALMSG
141 if [ "$signed" ]; then
142 gpg -bsa -u "$username" "$GIT_DIR"/TAG_TMP &&
143 cat "$GIT_DIR"/TAG_TMP.asc >>"$GIT_DIR"/TAG_TMP ||
144 die "failed to sign the tag with GPG."
146 object=$(git-mktag < "$GIT_DIR"/TAG_TMP)
149 git update-ref "refs/tags/$name" "$object" "$prev"