git-branch -D: make it work even when on a yet-to-be-born branch
[gitweb.git] / git-tag.sh
index 6463b314c6fe19c997c2a38d8dfdc1e9bb6637cb..ac269e3277d9b8c844e8c43b95695375dd829746 100755 (executable)
@@ -66,7 +66,7 @@ done
 name="$1"
 [ "$name" ] || usage
 prev=0000000000000000000000000000000000000000
-if test -e "$GIT_DIR/refs/tags/$name"
+if git-show-ref --verify --quiet -- "refs/tags/$name"
 then
     test -n "$force" || die "tag '$name' already exists"
     prev=`git rev-parse "refs/tags/$name"`
@@ -112,6 +112,5 @@ if [ "$annotate" ]; then
     object=$(git-mktag < "$GIT_DIR"/TAG_TMP)
 fi
 
-leading=`expr "refs/tags/$name" : '\(.*\)/'` &&
-mkdir -p "$GIT_DIR/$leading" &&
-GIT_DIR="$GIT_DIR" git update-ref "refs/tags/$name" "$object" "$prev"
+git update-ref "refs/tags/$name" "$object" "$prev"
+