2005-04-25 22:23:53 +00:00
|
|
|
#!/bin/sh
|
2005-05-10 05:57:58 +00:00
|
|
|
# Copyright (c) 2005 Linus Torvalds
|
|
|
|
|
2007-01-03 12:59:00 +00:00
|
|
|
USAGE='-l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg>] <tagname> [<head>]'
|
2005-12-13 22:30:31 +00:00
|
|
|
SUBDIRECTORY_OK='Yes'
|
|
|
|
. git-sh-setup
|
2005-11-28 07:33:54 +00:00
|
|
|
|
2006-11-26 16:42:49 +00:00
|
|
|
message_given=
|
2005-07-25 22:18:35 +00:00
|
|
|
annotate=
|
2005-07-23 22:21:22 +00:00
|
|
|
signed=
|
|
|
|
force=
|
2005-08-09 00:04:42 +00:00
|
|
|
message=
|
2005-10-06 21:10:39 +00:00
|
|
|
username=
|
2006-02-17 12:04:39 +00:00
|
|
|
list=
|
2007-01-03 12:59:00 +00:00
|
|
|
verify=
|
2005-07-23 22:21:22 +00:00
|
|
|
while case "$#" in 0) break ;; esac
|
|
|
|
do
|
|
|
|
case "$1" in
|
2005-07-25 22:18:35 +00:00
|
|
|
-a)
|
|
|
|
annotate=1
|
|
|
|
;;
|
2005-07-23 22:21:22 +00:00
|
|
|
-s)
|
2005-07-25 22:18:35 +00:00
|
|
|
annotate=1
|
2005-07-23 22:21:22 +00:00
|
|
|
signed=1
|
|
|
|
;;
|
|
|
|
-f)
|
|
|
|
force=1
|
|
|
|
;;
|
2006-02-17 12:04:39 +00:00
|
|
|
-l)
|
|
|
|
case "$#" in
|
|
|
|
1)
|
2006-05-15 00:07:39 +00:00
|
|
|
set x . ;;
|
2006-02-17 12:04:39 +00:00
|
|
|
esac
|
2006-05-15 00:07:39 +00:00
|
|
|
shift
|
|
|
|
git rev-parse --symbolic --tags | sort | grep "$@"
|
2006-02-17 12:04:39 +00:00
|
|
|
exit $?
|
|
|
|
;;
|
2005-08-09 00:04:42 +00:00
|
|
|
-m)
|
|
|
|
annotate=1
|
|
|
|
shift
|
|
|
|
message="$1"
|
2006-11-26 16:42:49 +00:00
|
|
|
if test "$#" = "0"; then
|
|
|
|
die "error: option -m needs an argument"
|
|
|
|
else
|
|
|
|
message_given=1
|
|
|
|
fi
|
2005-08-09 00:04:42 +00:00
|
|
|
;;
|
2006-12-21 14:13:02 +00:00
|
|
|
-F)
|
|
|
|
annotate=1
|
|
|
|
shift
|
|
|
|
if test "$#" = "0"; then
|
|
|
|
die "error: option -F needs an argument"
|
|
|
|
else
|
|
|
|
message="$(cat "$1")"
|
|
|
|
message_given=1
|
|
|
|
fi
|
|
|
|
;;
|
2005-10-06 21:10:39 +00:00
|
|
|
-u)
|
|
|
|
annotate=1
|
|
|
|
signed=1
|
|
|
|
shift
|
|
|
|
username="$1"
|
|
|
|
;;
|
2005-11-08 10:44:33 +00:00
|
|
|
-d)
|
|
|
|
shift
|
|
|
|
tag_name="$1"
|
2006-10-01 20:16:22 +00:00
|
|
|
tag=$(git-show-ref --verify --hash -- "refs/tags/$tag_name") ||
|
|
|
|
die "Seriously, what tag are you talking about?"
|
|
|
|
git-update-ref -m 'tag: delete' -d "refs/tags/$tag_name" "$tag" &&
|
|
|
|
echo "Deleted tag $tag_name."
|
2005-11-08 10:44:33 +00:00
|
|
|
exit $?
|
|
|
|
;;
|
2007-01-03 12:59:00 +00:00
|
|
|
-v)
|
|
|
|
shift
|
|
|
|
tag_name="$1"
|
|
|
|
tag=$(git-show-ref --verify --hash -- "refs/tags/$tag_name") ||
|
|
|
|
die "Seriously, what tag are you talking about?"
|
|
|
|
git-verify-tag -v "$tag"
|
|
|
|
exit $?
|
|
|
|
;;
|
2005-07-25 22:18:35 +00:00
|
|
|
-*)
|
|
|
|
usage
|
|
|
|
;;
|
2005-07-23 22:21:22 +00:00
|
|
|
*)
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2005-07-09 01:23:06 +00:00
|
|
|
name="$1"
|
2005-07-25 22:18:35 +00:00
|
|
|
[ "$name" ] || usage
|
2006-09-27 09:06:31 +00:00
|
|
|
prev=0000000000000000000000000000000000000000
|
2006-10-01 20:33:04 +00:00
|
|
|
if git-show-ref --verify --quiet -- "refs/tags/$name"
|
2006-09-27 09:06:31 +00:00
|
|
|
then
|
|
|
|
test -n "$force" || die "tag '$name' already exists"
|
|
|
|
prev=`git rev-parse "refs/tags/$name"`
|
2005-07-25 22:18:35 +00:00
|
|
|
fi
|
2005-07-23 22:21:22 +00:00
|
|
|
shift
|
2005-10-14 01:57:39 +00:00
|
|
|
git-check-ref-format "tags/$name" ||
|
|
|
|
die "we do not like '$name' as a tag name."
|
2005-05-10 05:57:58 +00:00
|
|
|
|
2005-08-15 22:37:37 +00:00
|
|
|
object=$(git-rev-parse --verify --default HEAD "$@") || exit 1
|
2005-04-29 23:25:05 +00:00
|
|
|
type=$(git-cat-file -t $object) || exit 1
|
2005-07-15 01:02:10 +00:00
|
|
|
tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1
|
2006-04-13 22:01:24 +00:00
|
|
|
: ${username:=$(expr "z$tagger" : 'z\(.*>\)')}
|
2005-07-09 01:23:06 +00:00
|
|
|
|
2005-11-03 23:26:43 +00:00
|
|
|
trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0
|
2005-07-25 22:18:35 +00:00
|
|
|
|
|
|
|
if [ "$annotate" ]; then
|
2006-11-26 16:42:49 +00:00
|
|
|
if [ -z "$message_given" ]; then
|
2005-08-09 00:04:42 +00:00
|
|
|
( echo "#"
|
|
|
|
echo "# Write a tag message"
|
2005-11-03 23:26:43 +00:00
|
|
|
echo "#" ) > "$GIT_DIR"/TAG_EDITMSG
|
|
|
|
${VISUAL:-${EDITOR:-vi}} "$GIT_DIR"/TAG_EDITMSG || exit
|
2005-08-09 00:04:42 +00:00
|
|
|
else
|
2005-11-03 23:26:43 +00:00
|
|
|
echo "$message" >"$GIT_DIR"/TAG_EDITMSG
|
2005-08-09 00:04:42 +00:00
|
|
|
fi
|
2005-07-23 22:21:22 +00:00
|
|
|
|
2005-11-03 23:26:43 +00:00
|
|
|
grep -v '^#' <"$GIT_DIR"/TAG_EDITMSG |
|
|
|
|
git-stripspace >"$GIT_DIR"/TAG_FINALMSG
|
2005-07-09 01:23:06 +00:00
|
|
|
|
2006-11-26 16:42:49 +00:00
|
|
|
[ -s "$GIT_DIR"/TAG_FINALMSG -o -n "$message_given" ] || {
|
2005-10-06 21:10:39 +00:00
|
|
|
echo >&2 "No tag message?"
|
|
|
|
exit 1
|
|
|
|
}
|
2005-07-09 01:23:06 +00:00
|
|
|
|
2006-02-12 18:05:34 +00:00
|
|
|
( printf 'object %s\ntype %s\ntag %s\ntagger %s\n\n' \
|
|
|
|
"$object" "$type" "$name" "$tagger";
|
2005-11-03 23:26:43 +00:00
|
|
|
cat "$GIT_DIR"/TAG_FINALMSG ) >"$GIT_DIR"/TAG_TMP
|
|
|
|
rm -f "$GIT_DIR"/TAG_TMP.asc "$GIT_DIR"/TAG_FINALMSG
|
2005-07-25 22:18:35 +00:00
|
|
|
if [ "$signed" ]; then
|
2005-11-03 23:26:43 +00:00
|
|
|
gpg -bsa -u "$username" "$GIT_DIR"/TAG_TMP &&
|
|
|
|
cat "$GIT_DIR"/TAG_TMP.asc >>"$GIT_DIR"/TAG_TMP ||
|
2005-07-25 22:18:35 +00:00
|
|
|
die "failed to sign the tag with GPG."
|
|
|
|
fi
|
2005-11-03 23:26:43 +00:00
|
|
|
object=$(git-mktag < "$GIT_DIR"/TAG_TMP)
|
2005-07-23 22:21:22 +00:00
|
|
|
fi
|
2005-07-09 01:23:06 +00:00
|
|
|
|
2006-10-02 04:36:15 +00:00
|
|
|
git update-ref "refs/tags/$name" "$object" "$prev"
|
|
|
|
|