When creating branch c/d check that branch c does not already exists.
authorChristian Couder <chriscool@tuxfamily.org>
Thu, 28 Sep 2006 05:00:38 +0000 (07:00 +0200)
committerJunio C Hamano <junkio@cox.net>
Thu, 28 Sep 2006 05:26:31 +0000 (22:26 -0700)
With packed refs, there may not be a ".git/refs/heads/c" file
when branch c exists. And currently in this case, there is no check
to prevent creation of branch c/d.

This should probably be rewritten in C and done after the ref lock
has been taken to make sure no race exists though.

This is mainly to make all test cases in "t3210-pack-refs.sh" work.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
git-branch.sh

index bf84b30695fdeda5d5e18456813e0b3cc3d11275..c61683033da84b6630aff7451f829040be9d5a37 100755 (executable)
@@ -121,6 +121,16 @@ then
        done
 fi
 
+branchdir=$(dirname $branchname)
+while test "$branchdir" != "."
+do
+       if git-show-ref --verify --quiet -- "refs/heads/$branchdir"
+       then
+               die "$branchdir already exists."
+       fi
+       branchdir=$(dirname $branchdir)
+done
+
 prev=''
 if git-show-ref --verify --quiet -- "refs/heads/$branchname"
 then