From 171c646f8c6484cca76933ebe8a6af52df47277d Mon Sep 17 00:00:00 2001 From: Dennis Kaarsemaker Date: Wed, 12 Oct 2016 18:41:07 +0200 Subject: worktree: allow the main brach of a bare repository to be checked out MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Acked-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- worktree.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'worktree.c') diff --git a/worktree.c b/worktree.c index 5acfe4cd64..f7869f8d60 100644 --- a/worktree.c +++ b/worktree.c @@ -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)) { -- cgit v1.2.3