From: Christian Couder Date: Thu, 28 Sep 2006 05:00:38 +0000 (+0200) Subject: When creating branch c/d check that branch c does not already exists. X-Git-Tag: v1.4.4-rc1~43^2~10 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5be7649131379e49f27d89cb6dd5bd8d0912a3d6;p=git.git When creating branch c/d check that branch c does not already exists. 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 Signed-off-by: Junio C Hamano --- diff --git a/git-branch.sh b/git-branch.sh index bf84b3069..c61683033 100755 --- a/git-branch.sh +++ b/git-branch.sh @@ -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