2005-04-26 00:23:53 +02:00
|
|
|
#!/bin/sh
|
2005-05-10 07:57:58 +02:00
|
|
|
# Copyright (c) 2005 Linus Torvalds
|
|
|
|
|
2005-07-09 03:23:06 +02:00
|
|
|
. git-sh-setup-script || die "Not a git archive"
|
2005-07-24 00:21:22 +02:00
|
|
|
|
2005-07-26 00:18:35 +02:00
|
|
|
usage () {
|
|
|
|
echo >&2 "Usage: git-tag-script [-a | -s] [-f] tagname"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
annotate=
|
2005-07-24 00:21:22 +02:00
|
|
|
signed=
|
|
|
|
force=
|
|
|
|
while case "$#" in 0) break ;; esac
|
|
|
|
do
|
|
|
|
case "$1" in
|
2005-07-26 00:18:35 +02:00
|
|
|
-a)
|
|
|
|
annotate=1
|
|
|
|
;;
|
2005-07-24 00:21:22 +02:00
|
|
|
-s)
|
2005-07-26 00:18:35 +02:00
|
|
|
annotate=1
|
2005-07-24 00:21:22 +02:00
|
|
|
signed=1
|
|
|
|
;;
|
|
|
|
-f)
|
|
|
|
force=1
|
|
|
|
;;
|
2005-07-26 00:18:35 +02:00
|
|
|
-*)
|
|
|
|
usage
|
|
|
|
;;
|
2005-07-24 00:21:22 +02:00
|
|
|
*)
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2005-07-09 03:23:06 +02:00
|
|
|
name="$1"
|
2005-07-26 00:18:35 +02:00
|
|
|
[ "$name" ] || usage
|
|
|
|
if [ -e "$GIT_DIR/refs/tags/$name" -a -z "$force" ]; then
|
|
|
|
die "tag '$name' already exists"
|
|
|
|
fi
|
2005-07-24 00:21:22 +02:00
|
|
|
shift
|
2005-05-10 07:57:58 +02:00
|
|
|
|
2005-07-24 00:21:22 +02:00
|
|
|
object=$(git-rev-parse --verify --revs-only --default HEAD "$@") || exit 1
|
2005-04-30 01:25:05 +02:00
|
|
|
type=$(git-cat-file -t $object) || exit 1
|
2005-07-15 03:02:10 +02:00
|
|
|
tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1
|
2005-07-09 03:23:06 +02:00
|
|
|
|
2005-07-26 00:18:35 +02:00
|
|
|
trap 'rm -f .tmp-tag* .tagmsg .editmsg' 0
|
|
|
|
|
|
|
|
if [ "$annotate" ]; then
|
2005-07-24 00:21:22 +02:00
|
|
|
( echo "#"
|
|
|
|
echo "# Write a tag message"
|
|
|
|
echo "#" ) > .editmsg
|
|
|
|
${VISUAL:-${EDITOR:-vi}} .editmsg || exit
|
|
|
|
|
|
|
|
grep -v '^#' < .editmsg | git-stripspace > .tagmsg
|
2005-07-09 03:23:06 +02:00
|
|
|
|
2005-07-24 00:21:22 +02:00
|
|
|
[ -s .tagmsg ] || exit
|
2005-07-09 03:23:06 +02:00
|
|
|
|
2005-07-24 00:21:22 +02:00
|
|
|
( echo -e "object $object\ntype $type\ntag $name\ntagger $tagger\n"; cat .tagmsg ) > .tmp-tag
|
|
|
|
rm -f .tmp-tag.asc .tagmsg
|
2005-07-26 00:18:35 +02:00
|
|
|
if [ "$signed" ]; then
|
|
|
|
me=$(expr "$tagger" : '\(.*>\)') &&
|
|
|
|
gpg -bsa -u "$me" .tmp-tag &&
|
|
|
|
cat .tmp-tag.asc >>.tmp-tag ||
|
|
|
|
die "failed to sign the tag with GPG."
|
|
|
|
fi
|
2005-07-24 00:21:22 +02:00
|
|
|
object=$(git-mktag < .tmp-tag)
|
|
|
|
fi
|
2005-07-09 03:23:06 +02:00
|
|
|
|
2005-07-15 03:00:15 +02:00
|
|
|
mkdir -p "$GIT_DIR/refs/tags"
|
2005-07-24 00:21:22 +02:00
|
|
|
echo $object > "$GIT_DIR/refs/tags/$name"
|