2 # Copyright (c) 2005 Linus Torvalds
4 USAGE
='[-a | -s | -u <key-id>] [-f | -d] [-m <msg>] <tagname> [<head>]'
13 while case "$#" in 0) break ;; esac
40 rm "$GIT_DIR/refs/tags/$tag_name" && \
41 echo "Deleted tag $tag_name."
56 if [ -e "$GIT_DIR/refs/tags/$name" -a -z "$force" ]; then
57 die
"tag '$name' already exists"
60 git-check-ref-format
"tags/$name" ||
61 die
"we do not like '$name' as a tag name."
63 object
=$
(git-rev-parse
--verify --default HEAD
"$@") ||
exit 1
64 type=$
(git-cat-file
-t $object) ||
exit 1
65 tagger
=$
(git-var GIT_COMMITTER_IDENT
) ||
exit 1
66 : ${username:=$(expr "$tagger" : '\(.*>\)')}
68 trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0
70 if [ "$annotate" ]; then
71 if [ -z "$message" ]; then
73 echo "# Write a tag message"
74 echo "#" ) > "$GIT_DIR"/TAG_EDITMSG
75 ${VISUAL:-${EDITOR:-vi}} "$GIT_DIR"/TAG_EDITMSG ||
exit
77 echo "$message" >"$GIT_DIR"/TAG_EDITMSG
80 grep -v '^#' <"$GIT_DIR"/TAG_EDITMSG |
81 git-stripspace
>"$GIT_DIR"/TAG_FINALMSG
83 [ -s "$GIT_DIR"/TAG_FINALMSG
] ||
{
84 echo >&2 "No tag message?"
88 ( echo -e "object $object\ntype $type\ntag $name\ntagger $tagger\n";
89 cat "$GIT_DIR"/TAG_FINALMSG
) >"$GIT_DIR"/TAG_TMP
90 rm -f "$GIT_DIR"/TAG_TMP.asc
"$GIT_DIR"/TAG_FINALMSG
91 if [ "$signed" ]; then
92 gpg
-bsa -u "$username" "$GIT_DIR"/TAG_TMP
&&
93 cat "$GIT_DIR"/TAG_TMP.asc
>>"$GIT_DIR"/TAG_TMP ||
94 die
"failed to sign the tag with GPG."
96 object
=$
(git-mktag
< "$GIT_DIR"/TAG_TMP
)
99 leading
=`expr "refs/tags/$name" : '\(.*\)/'` &&
100 mkdir
-p "$GIT_DIR/$leading" &&
101 echo $object > "$GIT_DIR/refs/tags/$name"