{"thread":{"id":"5696","subject":"[PATCH] Remove empty ref directories that prevent creating a ref.","startedAt":"2006-09-26T05:23:37Z","lastAt":"2006-09-26T05:27:28Z","messageCount":2,"participants":["Christian Couder","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"27658","messageId":"20060926072337.39dbb9f4.chriscool@tuxfamily.org","threadId":"5696","inReplyTo":null,"subject":"[PATCH] Remove empty ref directories that prevent creating a ref.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2006-09-26T05:23:37Z","receivedAt":"2006-09-26T05:23:37Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Junio wrote:\n\"BTW, the second issue exists without packed ref; currently we\ncannot do\n\n    git branch foo/bar\n    git branch -d foo/bar\n    git branch foo\"\n\nThis patch also add Linus and Junio test cases.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n\nThis fixed patch also applies to master, that's why it doesn't\ncontain test cases using \"git pack-refs\". I will send a separate\npatch for them latter.\n\n git-branch.sh     |   16 ++++++++++++++++\n t/t3200-branch.sh |   12 ++++++++++++\n 2 files changed, 28 insertions(+), 0 deletions(-)\n\ndiff --git a/git-branch.sh b/git-branch.sh\nindex e0501ec..834888d 100755\n--- a/git-branch.sh\n+++ b/git-branch.sh\n@@ -112,6 +112,22 @@ rev=$(git-rev-parse --verify \"$head\") ||\n git-check-ref-format \"heads/$branchname\" ||\n \tdie \"we do not like '$branchname' as a branch name.\"\n \n+LF='\n+'\n+\n+if [ -d \"$GIT_DIR/refs/heads/$branchname\" ]\n+then\n+\tOLD_IFS=\"$IFS\"\n+\tIFS=\"$LF\"\n+\tfor refdir in `find \"$GIT_DIR/refs/heads/$branchname\" -type d | sort -r`\n+\tdo\n+\t\trmdir \"$refdir\" || \\\n+\t\t    die \"Could not delete '$refdir',\" \\\n+\t\t    \"there may still be a ref there.\"\n+\tdone\n+\tIFS=\"$OLD_IFS\"\n+fi\n+\n if [ -e \"$GIT_DIR/refs/heads/$branchname\" ]\n then\n \tif test '' = \"$force\"\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex 5b04efc..6907cbc 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -61,4 +61,16 @@ test_expect_success \\\n \t test -f .git/logs/refs/heads/g/h/i &&\n \t diff expect .git/logs/refs/heads/g/h/i'\n \n+test_expect_success \\\n+    'git branch j/k should work after branch j has been deleted' \\\n+       'git-branch j &&\n+        git-branch -d j &&\n+        git-branch j/k'\n+\n+test_expect_success \\\n+    'git branch l should work after branch l/m has been deleted' \\\n+       'git-branch l/m &&\n+        git-branch -d l/m &&\n+        git-branch l'\n+\n test_done\n-- \n1.4.2.1.ged17-dirty\n"},{"id":"27660","messageId":"7vlko7rydb.fsf@assigned-by-dhcp.cox.net","threadId":"5696","inReplyTo":"20060926072337.39dbb9f4.chriscool@tuxfamily.org","subject":"Re: [PATCH] Remove empty ref directories that prevent creating a ref.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-26T05:27:28Z","receivedAt":"2006-09-26T05:27:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Couder <chriscool@tuxfamily.org> writes:\n\n> +LF='\n> +'\n> +\n> +if [ -d \"$GIT_DIR/refs/heads/$branchname\" ]\n> +then\n> +\tOLD_IFS=\"$IFS\"\n> +\tIFS=\"$LF\"\n> +\tfor refdir in `find \"$GIT_DIR/refs/heads/$branchname\" -type d | sort -r`\n> +\tdo\n> +\t\trmdir \"$refdir\" || \\\n> +\t\t    die \"Could not delete '$refdir',\" \\\n> +\t\t    \"there may still be a ref there.\"\n> +\tdone\n> +\tIFS=\"$OLD_IFS\"\n> +fi\n\nI was sort of expecting that you would do something like:\n\n\tfor refdir in `cd \"$GIT_DIR\" &&\n\t\t        find \"refs/heads/$branchname\" -type d |\n\t\t        sort -r`\n\tdo                        \n\t\trmdir \"$GIT_DIR/$refdir\" ...\n\nwihtout mucking with IFS ;-). \n"}]}