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 rm "$GIT_DIR/refs/tags/$tag_name" && \
51 echo "Deleted tag $tag_name."
66 if [ -e "$GIT_DIR/refs/tags/$name" -a -z "$force" ]; then
67 die
"tag '$name' already exists"
70 git-check-ref-format
"tags/$name" ||
71 die
"we do not like '$name' as a tag name."
73 object
=$
(git-rev-parse
--verify --default HEAD
"$@") ||
exit 1
74 type=$
(git-cat-file
-t $object) ||
exit 1
75 tagger
=$
(git-var GIT_COMMITTER_IDENT
) ||
exit 1
76 : ${username:=$(expr "z$tagger" : 'z\(.*>\)')}
78 trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0
80 if [ "$annotate" ]; then
81 if [ -z "$message" ]; then
83 echo "# Write a tag message"
84 echo "#" ) > "$GIT_DIR"/TAG_EDITMSG
85 ${VISUAL:-${EDITOR:-vi}} "$GIT_DIR"/TAG_EDITMSG ||
exit
87 echo "$message" >"$GIT_DIR"/TAG_EDITMSG
90 grep -v '^#' <"$GIT_DIR"/TAG_EDITMSG |
91 git-stripspace
>"$GIT_DIR"/TAG_FINALMSG
93 [ -s "$GIT_DIR"/TAG_FINALMSG
] ||
{
94 echo >&2 "No tag message?"
98 ( printf 'object %s\ntype %s\ntag %s\ntagger %s\n\n' \
99 "$object" "$type" "$name" "$tagger";
100 cat "$GIT_DIR"/TAG_FINALMSG
) >"$GIT_DIR"/TAG_TMP
101 rm -f "$GIT_DIR"/TAG_TMP.asc
"$GIT_DIR"/TAG_FINALMSG
102 if [ "$signed" ]; then
103 gpg
-bsa -u "$username" "$GIT_DIR"/TAG_TMP
&&
104 cat "$GIT_DIR"/TAG_TMP.asc
>>"$GIT_DIR"/TAG_TMP ||
105 die
"failed to sign the tag with GPG."
107 object
=$
(git-mktag
< "$GIT_DIR"/TAG_TMP
)
110 leading
=`expr "refs/tags/$name" : '\(.*\)/'` &&
111 mkdir
-p "$GIT_DIR/$leading" &&
112 echo $object > "$GIT_DIR/refs/tags/$name"