git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] fetch: Protect branches checked out in all worktrees

From
Anders Kaseorg <andersk@mit.edu>
Date
Nov 8, 2021, 20:12 UTC
Message-ID
<2e925989-d435-0355-d26d-e79a0a99929f@mit.edu>
In-Reply-To
<YYUbQqyYQDD5QEAz@coredump.intra.peff.net>
On 11/5/21 04:53, Jeff King wrote:
> +			       wt->is_current ?
> +			       _("can't fetch in current branch") :
> +			       _("branch checked out in worktree"),

Sure, I’ll go ahead and add this. We can make further improvements here if we proceed with removing the other error path, which seems to have enough complications that we should consider it after merging this bug fix.

Show 9 quoted lines
> Hmm. That is the same check that is on the fetch side, isn't it? In a
> bare repository, we will not do any of these current-branch checks. What
> is weird in your example is that you are adding a worktree to a bare
> repository. Is that a supported workflow? Should that make it non-bare?
> 
> I notice that there is a worktree->is_bare flag, and that
> find_shared_symref() would not report such a bare entry to us. But I'm
> really unclear how any of that is supposed to work (how do you have a
> bare worktree, and what does it mean?).

worktree->is_bare is only ever potentially set for the main working tree (.git/..). Although a bare repository doesn’t have a main working tree, it can still have other working trees created with git worktree. Making a temporary working tree can be useful to quickly inspect or change a bare repository. It’s also useful for sharing refs, remotes, and object storage between several working trees where any of them might be created or deleted, and there isn’t one that should be considered primary.

The Zulip installer works this way to save some disk space and re-cloning time while allowing for simple rollbacks to a previous deployment directory (https://github.com/zulip/zulip/pull/18487), which is how my team stumbled on the issue.

> I think that's all orthogonal to the main purpose of your patch here.
> You may want to post about it separately with a different subject to get
> the attention of folks who work on worktrees.

I expect this subject line will have already caught the attention of those folks, but I’ll add a patch 2/2 with a more specific subject line for this issue.

Anders
Previous: Junio C Hamano
Message 7 of 7 in “fetch: Protect branches checked out in all worktrees”
  1. fetch: Protect branches checked out in all worktreesAnders Kaseorg, Nov 4, 2021
  2. fetch: Protect branches checked out in all worktreesAnders Kaseorg, Nov 4, 2021
  3. Jeff KingNov 5, 2021
  4. Anders KaseorgNov 5, 2021
  5. Jeff KingNov 5, 2021
  6. Junio C HamanoNov 5, 2021
  7. Anders KaseorgNov 8, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.