#!/bin/sh
# Copyright (c) 2005 Linus Torvalds
-. git-sh-setup || die "Not a git archive"
-
-usage () {
- echo >&2 "Usage: git-tag [-a | -s | -u <key-id>] [-f] [-m <msg>] <tagname> [<head>]"
- exit 1
-}
+USAGE='-l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d] [-m <msg>] <tagname> [<head>]'
+SUBDIRECTORY_OK='Yes'
+. git-sh-setup
annotate=
signed=
force=
message=
username=
+list=
while case "$#" in 0) break ;; esac
do
case "$1" in
-f)
force=1
;;
+ -l)
+ case "$#" in
+ 1)
+ set x . ;;
+ esac
+ shift
+ git rev-parse --symbolic --tags | sort | grep "$@"
+ exit $?
+ ;;
-m)
annotate=1
shift
shift
username="$1"
;;
+ -d)
+ shift
+ tag_name="$1"
+ rm "$GIT_DIR/refs/tags/$tag_name" && \
+ echo "Deleted tag $tag_name."
+ exit $?
+ ;;
-*)
usage
;;
object=$(git-rev-parse --verify --default HEAD "$@") || exit 1
type=$(git-cat-file -t $object) || exit 1
tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1
-: ${username:=$(expr "$tagger" : '\(.*>\)')}
+: ${username:=$(expr "z$tagger" : 'z\(.*>\)')}
trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0
exit 1
}
- ( echo -e "object $object\ntype $type\ntag $name\ntagger $tagger\n";
+ ( printf 'object %s\ntype %s\ntag %s\ntagger %s\n\n' \
+ "$object" "$type" "$name" "$tagger";
cat "$GIT_DIR"/TAG_FINALMSG ) >"$GIT_DIR"/TAG_TMP
rm -f "$GIT_DIR"/TAG_TMP.asc "$GIT_DIR"/TAG_FINALMSG
if [ "$signed" ]; then