2 # Copyright (c) 2005 Linus Torvalds
4 USAGE
='[-n [<num>]] -l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg>] <tagname> [<head>]'
17 while case "$#" in 0) break ;; esac
32 -*) LINES
=1 # no argument
35 LINES
=$
(expr "$1" : '\([0-9]*\)')
36 [ -z "$LINES" ] && LINES
=1 # 1 line is default when -n is used
43 PATTERN
="$1" # select tags by shell pattern, not re
44 git rev-parse
--symbolic --tags |
sort |
51 [ "$LINES" -le 0 ] && { echo "$TAG"; continue ;}
52 OBJTYPE
=$
(git cat-file
-t "$TAG")
55 ANNOTATION
=$
(git cat-file tag
"$TAG" |
58 /^-----BEGIN PGP SIGNATURE-----\$/q
63 printf "%-15s %s\n" "$TAG" "$ANNOTATION"
74 if test "$#" = "0"; then
75 die
"error: option -m needs an argument"
83 if test "$#" = "0"; then
84 die
"error: option -F needs an argument"
101 cur
=$
(git-show-ref
--verify --hash -- "refs/tags/$tag") ||
{
102 echo >&2 "Seriously, what tag are you talking about?"
106 git-update-ref
-m 'tag: delete' -d "refs/tags/$tag" "$cur" ||
{
110 echo "Deleted tag $tag."
117 tag
=$
(git-show-ref
--verify --hash -- "refs/tags/$tag_name") ||
118 die
"Seriously, what tag are you talking about?"
119 git-verify-tag
-v "$tag"
132 [ -n "$list" ] && exit 0
136 prev
=0000000000000000000000000000000000000000
137 if git-show-ref
--verify --quiet -- "refs/tags/$name"
139 test -n "$force" || die
"tag '$name' already exists"
140 prev
=`git rev-parse "refs/tags/$name"`
143 git-check-ref-format
"tags/$name" ||
144 die
"we do not like '$name' as a tag name."
146 object
=$
(git-rev-parse
--verify --default HEAD
"$@") ||
exit 1
147 type=$
(git-cat-file
-t $object) ||
exit 1
148 tagger
=$
(git-var GIT_COMMITTER_IDENT
) ||
exit 1
150 test -n "$username" ||
151 username
=$
(git-repo-config user.signingkey
) ||
152 username
=$
(expr "z$tagger" : 'z\(.*>\)')
154 trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0
156 if [ "$annotate" ]; then
157 if [ -z "$message_given" ]; then
159 echo "# Write a tag message"
160 echo "#" ) > "$GIT_DIR"/TAG_EDITMSG
161 ${VISUAL:-${EDITOR:-vi}} "$GIT_DIR"/TAG_EDITMSG ||
exit
163 printf '%s\n' "$message" >"$GIT_DIR"/TAG_EDITMSG
166 grep -v '^#' <"$GIT_DIR"/TAG_EDITMSG |
167 git-stripspace
>"$GIT_DIR"/TAG_FINALMSG
169 [ -s "$GIT_DIR"/TAG_FINALMSG
-o -n "$message_given" ] ||
{
170 echo >&2 "No tag message?"
174 ( printf 'object %s\ntype %s\ntag %s\ntagger %s\n\n' \
175 "$object" "$type" "$name" "$tagger";
176 cat "$GIT_DIR"/TAG_FINALMSG
) >"$GIT_DIR"/TAG_TMP
177 rm -f "$GIT_DIR"/TAG_TMP.asc
"$GIT_DIR"/TAG_FINALMSG
178 if [ "$signed" ]; then
179 gpg
-bsa -u "$username" "$GIT_DIR"/TAG_TMP
&&
180 cat "$GIT_DIR"/TAG_TMP.asc
>>"$GIT_DIR"/TAG_TMP ||
181 die
"failed to sign the tag with GPG."
183 object
=$
(git-mktag
< "$GIT_DIR"/TAG_TMP
)
186 git update-ref
"refs/tags/$name" "$object" "$prev"