2 # Copyright (c) 2005 Linus Torvalds
4 GIT_DIR
=`git-rev-parse --git-dir` ||
exit $?
7 echo >&2 "Usage: git-tag [-a | -s | -u <key-id>] [-f | -d] [-m <msg>] <tagname> [<head>]"
21 while case "$#" in 0) break ;; esac
48 rm "$GIT_DIR/refs/tags/$tag_name" && \
49 echo "Deleted tag $tag_name."
64 if [ -e "$GIT_DIR/refs/tags/$name" -a -z "$force" ]; then
65 die
"tag '$name' already exists"
68 git-check-ref-format
"tags/$name" ||
69 die
"we do not like '$name' as a tag name."
71 object
=$
(git-rev-parse
--verify --default HEAD
"$@") ||
exit 1
72 type=$
(git-cat-file
-t $object) ||
exit 1
73 tagger
=$
(git-var GIT_COMMITTER_IDENT
) ||
exit 1
74 : ${username:=$(expr "$tagger" : '\(.*>\)')}
76 trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0
78 if [ "$annotate" ]; then
79 if [ -z "$message" ]; then
81 echo "# Write a tag message"
82 echo "#" ) > "$GIT_DIR"/TAG_EDITMSG
83 ${VISUAL:-${EDITOR:-vi}} "$GIT_DIR"/TAG_EDITMSG ||
exit
85 echo "$message" >"$GIT_DIR"/TAG_EDITMSG
88 grep -v '^#' <"$GIT_DIR"/TAG_EDITMSG |
89 git-stripspace
>"$GIT_DIR"/TAG_FINALMSG
91 [ -s "$GIT_DIR"/TAG_FINALMSG
] ||
{
92 echo >&2 "No tag message?"
96 ( echo -e "object $object\ntype $type\ntag $name\ntagger $tagger\n";
97 cat "$GIT_DIR"/TAG_FINALMSG
) >"$GIT_DIR"/TAG_TMP
98 rm -f "$GIT_DIR"/TAG_TMP.asc
"$GIT_DIR"/TAG_FINALMSG
99 if [ "$signed" ]; then
100 gpg
-bsa -u "$username" "$GIT_DIR"/TAG_TMP
&&
101 cat "$GIT_DIR"/TAG_TMP.asc
>>"$GIT_DIR"/TAG_TMP ||
102 die
"failed to sign the tag with GPG."
104 object
=$
(git-mktag
< "$GIT_DIR"/TAG_TMP
)
107 leading
=`expr "refs/tags/$name" : '\(.*\)/'` &&
108 mkdir
-p "$GIT_DIR/$leading" &&
109 echo $object > "$GIT_DIR/refs/tags/$name"