public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Dennis Kaarsemaker <dennis@kaarsemaker•net>
Cc: git@vger•kernel.org, pclouds@gmail•com, mtutty@gforgegroup•com,
	rappazzo@gmail•com
Subject: Re: [PATCH] worktree: allow the main brach of a bare repository to be checked out
Date: Wed, 12 Oct 2016 11:50:07 -0700	[thread overview]
Message-ID: <xmqqbmyp4d28.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <xmqqfuo14dnr.fsf@gitster.mtv.corp.google.com> (Junio C. Hamano's message of "Wed, 12 Oct 2016 11:37:12 -0700")

Junio C Hamano <gitster@pobox•com> writes:

> Dennis Kaarsemaker <dennis@kaarsemaker•net> writes:
>
>> OK, so here it is as a proper patch.

Here is what I queued.  Duy, what do you think?  It seems OK to me.

Thanks.

-- >8 --
From: Dennis Kaarsemaker <dennis@kaarsemaker•net>
Date: Wed, 12 Oct 2016 18:41:07 +0200
Subject: [PATCH] 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 <dennis@kaarsemaker•net>
Signed-off-by: Junio C Hamano <gitster@pobox•com>
---
 t/t2025-worktree-add.sh | 8 ++++++++
 worktree.c              | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh
index 4bcc335a19..b618d6be21 100755
--- a/t/t2025-worktree-add.sh
+++ b/t/t2025-worktree-add.sh
@@ -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 &&
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)) {
-- 
2.10.1-591-g271c03b70f


  reply	other threads:[~2016-10-12 18:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-09  0:30 Bug? git worktree fails with master on bare repo Michael Tutty
2016-10-09  6:50 ` Kevin Daudt
2016-10-09  7:51 ` Dennis Kaarsemaker
2016-10-09 10:52   ` Duy Nguyen
2016-10-09 13:42     ` Michael Tutty
2016-10-10  9:45       ` Duy Nguyen
2016-10-10 13:06         ` Michael Tutty
2016-10-11 15:41           ` Kevin Daudt
2016-10-12 16:41     ` [PATCH] worktree: allow the main brach of a bare repository to be checked out Dennis Kaarsemaker
2016-10-12 17:35       ` Michael Tutty
2016-10-12 18:37       ` Junio C Hamano
2016-10-12 18:50         ` Junio C Hamano [this message]
2016-10-13 10:31           ` Duy Nguyen
2016-10-12 19:23         ` Dennis Kaarsemaker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqbmyp4d28.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=dennis@kaarsemaker$(echo .)net \
    --cc=git@vger$(echo .)kernel.org \
    --cc=mtutty@gforgegroup$(echo .)com \
    --cc=pclouds@gmail$(echo .)com \
    --cc=rappazzo@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox