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"
50 if test "$#" = "0"; then
51 die "error: option -F needs an argument"
66 tag=$(git-show-ref --verify --hash -- "refs/tags/$tag_name") ||
67 die "Seriously, what tag are you talking about?"
68 git-update-ref -m 'tag: delete' -d "refs/tags/$tag_name" "$tag" &&
69 echo "Deleted tag $tag_name."
84 prev=0000000000000000000000000000000000000000
85 if git-show-ref --verify --quiet -- "refs/tags/$name"
87 test -n "$force" || die "tag '$name' already exists"
88 prev=`git rev-parse "refs/tags/$name"`
91 git-check-ref-format "tags/$name" ||
92 die "we do not like '$name' as a tag name."
94 object=$(git-rev-parse --verify --default HEAD "$@") || exit 1
95 type=$(git-cat-file -t $object) || exit 1
96 tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1
97 : ${username:=$(expr "z$tagger" : 'z\(.*>\)')}
99 trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0
101 if [ "$annotate" ]; then
102 if [ -z "$message_given" ]; then
104 echo "# Write a tag message"
105 echo "#" ) > "$GIT_DIR"/TAG_EDITMSG
106 ${VISUAL:-${EDITOR:-vi}} "$GIT_DIR"/TAG_EDITMSG || exit
108 echo "$message" >"$GIT_DIR"/TAG_EDITMSG
111 grep -v '^#' <"$GIT_DIR"/TAG_EDITMSG |
112 git-stripspace >"$GIT_DIR"/TAG_FINALMSG
114 [ -s "$GIT_DIR"/TAG_FINALMSG -o -n "$message_given" ] || {
115 echo >&2 "No tag message?"
119 ( printf 'object %s\ntype %s\ntag %s\ntagger %s\n\n' \
120 "$object" "$type" "$name" "$tagger";
121 cat "$GIT_DIR"/TAG_FINALMSG ) >"$GIT_DIR"/TAG_TMP
122 rm -f "$GIT_DIR"/TAG_TMP.asc "$GIT_DIR"/TAG_FINALMSG
123 if [ "$signed" ]; then
124 gpg -bsa -u "$username" "$GIT_DIR"/TAG_TMP &&
125 cat "$GIT_DIR"/TAG_TMP.asc >>"$GIT_DIR"/TAG_TMP ||
126 die "failed to sign the tag with GPG."
128 object=$(git-mktag < "$GIT_DIR"/TAG_TMP)
131 git update-ref "refs/tags/$name" "$object" "$prev"