1#!/bin/sh
2# Copyright (c) 2005 Linus Torvalds
3
4. git-sh-setup-script || die "Not a git archive"
5name="$1"
6[ "$name" ] || die "I need a tag-name"
7
8object=${2:-$(cat "$GIT_DIR"/HEAD)}
9type=$(git-cat-file -t $object) || exit 1
10
11( echo "#"
12 echo "# Write a tag message"
13 echo "#" ) > .editmsg
14${VISUAL:-${EDITOR:-vi}} .editmsg || exit
15
16grep -v '^#' < .editmsg | git-stripspace > .tagmsg
17
18[ -s .tagmsg ] || exit
19
20( echo -e "object $object\ntype $type\ntag $name\n"; cat .tagmsg ) > .tmp-tag
21rm -f .tmp-tag.asc .tagmsg
22gpg -bsa .tmp-tag && cat .tmp-tag.asc >> .tmp-tag
23git-mktag < .tmp-tag > "$GIT_DIR/refs/tags/$name"
24#rm .tmp-tag .tmp-tag.sig