2 # Copyright (c) 2005 Linus Torvalds
4 USAGE
='-l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d] [-m <msg>] <tagname> [<head>]'
14 while case "$#" in 0) break ;; esac
33 git rev-parse
--symbolic --tags |
sort |
grep "$@"
50 tag
=$
(git-show-ref
--verify --hash -- "refs/tags/$tag_name") ||
51 die
"Seriously, what tag are you talking about?"
52 git-update-ref
-m 'tag: delete' -d "refs/tags/$tag_name" "$tag" &&
53 echo "Deleted tag $tag_name."
68 prev
=0000000000000000000000000000000000000000
69 if git-show-ref
--verify --quiet -- "refs/tags/$name"
71 test -n "$force" || die
"tag '$name' already exists"
72 prev
=`git rev-parse "refs/tags/$name"`
75 git-check-ref-format
"tags/$name" ||
76 die
"we do not like '$name' as a tag name."
78 object
=$
(git-rev-parse
--verify --default HEAD
"$@") ||
exit 1
79 type=$
(git-cat-file
-t $object) ||
exit 1
80 tagger
=$
(git-var GIT_COMMITTER_IDENT
) ||
exit 1
81 : ${username:=$(expr "z$tagger" : 'z\(.*>\)')}
83 trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0
85 if [ "$annotate" ]; then
86 if [ -z "$message" ]; then
88 echo "# Write a tag message"
89 echo "#" ) > "$GIT_DIR"/TAG_EDITMSG
90 ${VISUAL:-${EDITOR:-vi}} "$GIT_DIR"/TAG_EDITMSG ||
exit
92 echo "$message" >"$GIT_DIR"/TAG_EDITMSG
95 grep -v '^#' <"$GIT_DIR"/TAG_EDITMSG |
96 git-stripspace
>"$GIT_DIR"/TAG_FINALMSG
98 [ -s "$GIT_DIR"/TAG_FINALMSG
] ||
{
99 echo >&2 "No tag message?"
103 ( printf 'object %s\ntype %s\ntag %s\ntagger %s\n\n' \
104 "$object" "$type" "$name" "$tagger";
105 cat "$GIT_DIR"/TAG_FINALMSG
) >"$GIT_DIR"/TAG_TMP
106 rm -f "$GIT_DIR"/TAG_TMP.asc
"$GIT_DIR"/TAG_FINALMSG
107 if [ "$signed" ]; then
108 gpg
-bsa -u "$username" "$GIT_DIR"/TAG_TMP
&&
109 cat "$GIT_DIR"/TAG_TMP.asc
>>"$GIT_DIR"/TAG_TMP ||
110 die
"failed to sign the tag with GPG."
112 object
=$
(git-mktag
< "$GIT_DIR"/TAG_TMP
)
115 git update-ref
"refs/tags/$name" "$object" "$prev"