2 # Copyright (c) 2005 Linus Torvalds
4 . git-sh-setup-script || die
"Not a git archive"
7 echo >&2 "Usage: git-tag-script [-a | -s] [-f] [-m "tag message
"] tagname"
15 while case "$#" in 0) break ;; esac
45 if [ -e "$GIT_DIR/refs/tags/$name" -a -z "$force" ]; then
46 die
"tag '$name' already exists"
50 object
=$
(git-rev-parse
--verify --default HEAD
"$@") ||
exit 1
51 type=$
(git-cat-file
-t $object) ||
exit 1
52 tagger
=$
(git-var GIT_COMMITTER_IDENT
) ||
exit 1
54 trap 'rm -f .tmp-tag* .tagmsg .editmsg' 0
56 if [ "$annotate" ]; then
57 if [ -z "$message" ]; then
59 echo "# Write a tag message"
61 ${VISUAL:-${EDITOR:-vi}} .editmsg ||
exit
63 echo "$message" > .editmsg
66 grep -v '^#' < .editmsg | git-stripspace
> .tagmsg
68 [ -s .tagmsg
] ||
exit
70 ( echo -e "object $object\ntype $type\ntag $name\ntagger $tagger\n"; cat .tagmsg
) > .tmp-tag
71 rm -f .tmp-tag.asc .tagmsg
72 if [ "$signed" ]; then
73 me
=$
(expr "$tagger" : '\(.*>\)') &&
74 gpg
-bsa -u "$me" .tmp-tag
&&
75 cat .tmp-tag.asc
>>.tmp-tag ||
76 die
"failed to sign the tag with GPG."
78 object
=$
(git-mktag
< .tmp-tag
)
81 mkdir
-p "$GIT_DIR/refs/tags"
82 echo $object > "$GIT_DIR/refs/tags/$name"