rev-parse lstat() workaround cleanup.
[gitweb.git] / git-tag.sh
index bd9275367405fa0b8c10a2e1394195cdbcfc632c..6d0c973239a1b72bbef43aa430f1ee534b7ab458 100755 (executable)
@@ -1,12 +1,9 @@
 #!/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='[-a | -s | -u <key-id>] [-f | -d] [-m <msg>] <tagname> [<head>]'
+SUBDIRECTORY_OK='Yes'
+. git-sh-setup
 
 annotate=
 signed=
@@ -37,6 +34,13 @@ do
        shift
        username="$1"
        ;;
+    -d)
+       shift
+       tag_name="$1"
+       rm "$GIT_DIR/refs/tags/$tag_name" && \
+               echo "Deleted tag $tag_name."
+       exit $?
+       ;;
     -*)
         usage
        ;;
@@ -92,5 +96,6 @@ if [ "$annotate" ]; then
     object=$(git-mktag < "$GIT_DIR"/TAG_TMP)
 fi
 
-mkdir -p "$GIT_DIR/refs/tags"
+leading=`expr "refs/tags/$name" : '\(.*\)/'` &&
+mkdir -p "$GIT_DIR/$leading" &&
 echo $object > "$GIT_DIR/refs/tags/$name"