Skip to content

Commit

Permalink
Merge branch 'cc/branch-test'
Browse files Browse the repository at this point in the history
* cc/branch-test:
  Remove empty ref directories that prevent creating a ref.
  • Loading branch information
Junio C Hamano committed Sep 28, 2006
2 parents 2b83ade + 9c7b0b3 commit 51b2dd4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions git-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ rev=$(git-rev-parse --verify "$head") || exit
git-check-ref-format "heads/$branchname" ||
die "we do not like '$branchname' as a branch name."

if [ -d "$GIT_DIR/refs/heads/$branchname" ]
then
for refdir in `cd "$GIT_DIR" && \
find "refs/heads/$branchname" -type d | sort -r`
do
rmdir "$GIT_DIR/$refdir" || \
die "Could not delete '$refdir', there may still be a ref there."
done
fi

if [ -e "$GIT_DIR/refs/heads/$branchname" ]
then
if test '' = "$force"
Expand Down
12 changes: 12 additions & 0 deletions t/t3200-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,16 @@ test_expect_success \
test -f .git/logs/refs/heads/g/h/i &&
diff expect .git/logs/refs/heads/g/h/i'

test_expect_success \
'git branch j/k should work after branch j has been deleted' \
'git-branch j &&
git-branch -d j &&
git-branch j/k'

test_expect_success \
'git branch l should work after branch l/m has been deleted' \
'git-branch l/m &&
git-branch -d l/m &&
git-branch l'

test_done

0 comments on commit 51b2dd4

Please sign in to comment.