Commit 171c646f authored by Dennis Kaarsemaker's avatar Dennis Kaarsemaker Committed by Junio C Hamano

worktree: allow the main brach of a bare repository to be checked out

In bare repositories, get_worktrees() still returns the main repository,
so git worktree list can show it. ignore it in find_shared_symref so we
can still check out the main branch.
Signed-off-by: Dennis Kaarsemaker's avatarDennis Kaarsemaker <dennis@kaarsemaker.net>
Acked-by: Duy Nguyen's avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
parent 74eeaf7b
......@@ -138,6 +138,14 @@ test_expect_success 'checkout from a bare repo without "add"' '
)
'
test_expect_success '"add" default branch of a bare repo' '
(
git clone --bare . bare2 &&
cd bare2 &&
git worktree add ../there3 master
)
'
test_expect_success 'checkout with grafts' '
test_when_finished rm .git/info/grafts &&
test_commit abc &&
......
......@@ -345,6 +345,8 @@ const struct worktree *find_shared_symref(const char *symref,
for (i = 0; worktrees[i]; i++) {
struct worktree *wt = worktrees[i];
if (wt->is_bare)
continue;
if (wt->is_detached && !strcmp(symref, "HEAD")) {
if (is_worktree_being_rebased(wt, target)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment