Skip to content

Commit c6e19e4

Browse files
committed
Merge branch 'ab/checkout-branch-info-leakfix'
We added an unrelated sanity checking that leads to a BUG() while plugging a leak, which triggered in a repository with symrefs in the local branch namespace that point at a ref outside. Partially revert the change to avoid triggering the BUG(). * ab/checkout-branch-info-leakfix: checkout: avoid BUG() when hitting a broken repository
2 parents 7ea759c + 519947b commit c6e19e4

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

builtin/checkout.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,9 +1094,6 @@ static int switch_branches(const struct checkout_opts *opts,
10941094
const char *p;
10951095
if (skip_prefix(old_branch_info.path, prefix, &p))
10961096
old_branch_info.name = xstrdup(p);
1097-
else
1098-
BUG("should be able to skip past '%s' in '%s'!",
1099-
prefix, old_branch_info.path);
11001097
}
11011098

11021099
if (opts->new_orphan_branch && opts->orphan_from_empty_tree) {

t/t2018-checkout-branch.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ test_expect_success 'setup' '
8585
git branch -m branch1
8686
'
8787

88+
test_expect_success 'checkout a branch without refs/heads/* prefix' '
89+
git clone --no-tags . repo-odd-prefix &&
90+
(
91+
cd repo-odd-prefix &&
92+
93+
origin=$(git symbolic-ref refs/remotes/origin/HEAD) &&
94+
git symbolic-ref refs/heads/a-branch "$origin" &&
95+
96+
git checkout -f a-branch &&
97+
git checkout -f a-branch
98+
)
99+
'
100+
88101
test_expect_success 'checkout -b to a new branch, set to HEAD' '
89102
test_when_finished "
90103
git checkout branch1 &&

0 commit comments

Comments
 (0)