{"thread":{"id":"5730","subject":"[PATCH 2/3] When creating branch c/d check that branch c does not already exists.","startedAt":"2006-09-28T05:00:38Z","lastAt":"2006-09-28T05:00:38Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"27872","messageId":"20060928070038.fd28ff39.chriscool@tuxfamily.org","threadId":"5730","inReplyTo":null,"subject":"[PATCH 2/3] When creating branch c/d check that branch c does not already exists.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2006-09-28T05:00:38Z","receivedAt":"2006-09-28T05:00:38Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"With packed refs, there may not be a \".git/refs/heads/c\" file\nwhen branch c exists. And currently in this case, there is no check\nto prevent creation of branch c/d.\n\nThis should probably be rewritten in C and done after the ref lock\nhas been taken to make sure no race exists though.\n\nThis is mainly to make all test cases in \"t3210-pack-refs.sh\" work.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n git-branch.sh |   10 ++++++++++\n 1 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/git-branch.sh b/git-branch.sh\nindex 4826c75..4a1e7d9 100755\n--- a/git-branch.sh\n+++ b/git-branch.sh\n@@ -122,6 +122,16 @@ then\n \tdone\n fi\n \n+branchdir=$(dirname $branchname)\n+while test \"$branchdir\" != \".\"\n+do\n+\tif git-show-ref --verify --quiet -- \"refs/heads/$branchdir\"\n+\tthen\n+\t\tdie \"$branchdir already exists.\"\n+\tfi\n+\tbranchdir=$(dirname $branchdir)\n+done\n+\n if git-show-ref --verify --quiet -- \"refs/heads/$branchname\"\n then\n \tif test '' = \"$force\"\n-- \n1.4.2.1.g3bab\n"}]}