@matheusbsbs / matheus-bagliano / commits / 9c7b0b3fc4
Fork 0

Remove empty ref directories that prevent creating a ref.

This patch also adds test cases from Linus and Junio. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Christian Couder committed Sep 26, 2006 at 07:23 UTC 9c7b0b3fc46e552bde1a65cd1950c3634854332b
2 files changed +22
git-branch.sh
+10
@@ -112,6 +112,16 @@ rev=$(git-rev-parse --verify "$head") || exit
112 git-check-ref-format "heads/$branchname" ||
113 die "we do not like '$branchname' as a branch name."
114
115 +if [ -d "$GIT_DIR/refs/heads/$branchname" ]
116 +then
117 + for refdir in `cd "$GIT_DIR" && \
118 + find "refs/heads/$branchname" -type d | sort -r`
119 + do
120 + rmdir "$GIT_DIR/$refdir" || \
121 + die "Could not delete '$refdir', there may still be a ref there."
122 + done
123 +fi
124 +
125 if [ -e "$GIT_DIR/refs/heads/$branchname" ]
126 then
127 if test '' = "$force"
t/t3200-branch.sh
+12
@@ -61,4 +61,16 @@ test_expect_success \
61 test -f .git/logs/refs/heads/g/h/i &&
62 diff expect .git/logs/refs/heads/g/h/i'
63
64 +test_expect_success \
65 + 'git branch j/k should work after branch j has been deleted' \
66 + 'git-branch j &&
67 + git-branch -d j &&
68 + git-branch j/k'
69 +
70 +test_expect_success \
71 + 'git branch l should work after branch l/m has been deleted' \
72 + 'git-branch l/m &&
73 + git-branch -d l/m &&
74 + git-branch l'
75 +
76 test_done