[PATCH] git-peek-remote: show tags and heads from a remote repository.
[git.git] / git-tag-script
blobc375a840d3eb84f34bccc19ad5bb3c76dd5ca783
1 #!/bin/sh
2 # Copyright (c) 2005 Linus Torvalds
4 . git-sh-setup-script || die "Not a git archive"
6 signed=
7 force=
8 while case "$#" in 0) break ;; esac
9 do
10 case "$1" in
11 -s)
12 signed=1
14 -f)
15 force=1
18 break
20 esac
21 shift
22 done
24 name="$1"
25 [ "$name" ] || die "I need a tag-name"
26 [ -e "$GIT_DIR/refs/tags/$name" ] &&
27 [ "$force" ] || die "tag '$name' already exists"
28 shift
30 object=$(git-rev-parse --verify --revs-only --default HEAD "$@") || exit 1
31 type=$(git-cat-file -t $object) || exit 1
32 tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1
34 if [ "$signed" ]; then
35 ( echo "#"
36 echo "# Write a tag message"
37 echo "#" ) > .editmsg
38 ${VISUAL:-${EDITOR:-vi}} .editmsg || exit
40 grep -v '^#' < .editmsg | git-stripspace > .tagmsg
42 [ -s .tagmsg ] || exit
44 ( echo -e "object $object\ntype $type\ntag $name\ntagger $tagger\n"; cat .tagmsg ) > .tmp-tag
45 rm -f .tmp-tag.asc .tagmsg
46 gpg -bsa .tmp-tag && cat .tmp-tag.asc >> .tmp-tag
47 object=$(git-mktag < .tmp-tag)
48 rm -f .tmp-tag .tmp-tag.sig
51 mkdir -p "$GIT_DIR/refs/tags"
52 echo $object > "$GIT_DIR/refs/tags/$name"