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

Re: [PATCH] refs: support migration with worktrees

From
Patrick Steinhardt <ps@pks.im>
Date
Oct 29, 2025, 10:10 UTC
Message-ID
<aQHoKXtrbDx6eNpH@pks.im>
In-Reply-To
<xmqqfrb3dnis.fsf@gitster.g>
On Tue, Oct 28, 2025 at 09:00:43AM -0700, Junio C Hamano wrote:
Show 25 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> 
> >>  `migrate`::
> >> -	Migrate ref store between different formats.
> >> +	Migrate ref store between different formats. Supports repositories
> >> +	with worktrees; migration must be run from the main worktree.
> >
> > It feels a bit weird to single our worktrees specifically. We don't say
> > that the tool supports bare and non-bare repositories, either, so the
> > only reason why we'd have the note about worktrees is historic legacy.
> > How about this instead:
> >
> >     Migrate ref storage between different formats. Must be run from the
> >     main worktree in case the repository uses worktrees.
> 
> Two thoughts.
> 
>  * Would it be unacceptable if the primary repository and refstore
>    uses reftable backend, and a newly attached worktree to the
>    repository uses ref-files only for its per-worktree refs?  If we
>    should allow it, then "if the ref store you are migrating is in a
>    repository with multiple worktrees, you must migrate from the
>    primary and migrate _all_ ref store for all worktrees at once,
>    into the same backend", which the design of this patch seems to
>    aim at, would contradict with it, no?

The problem we have here is backwards compatibility. Right now we assume that `extensions.refStorage` applies to all worktrees, so if we wanted to change it like you propose then we'd have to introduce a backwards incompatible change.

I agree though that it would've been great if we would have said from the beginning that the worktree-specific configuration is allowed to override the ref storage format for a worktree. If so, we could easily convert any of the worktrees (including the main one) by without having any impact on all the other worktrees.

But we do not live in such a world right now, and getting there would require some significant reworking of how we handle per-worktree references. Unfortunate, but I also don't think there's a strong enough reason to change this.

Show 8 quoted lines
>  * If "you must do so from the primary worktree and we convert all
>    the worktrees attached to the same repository" is the only mode
>    of operation we support (which by the way I have no problem
>    with---the first bullet point above was asking question, not
>    suggesting change of design), then would it be easier for the
>    user to use if the command noticed that it is not in the primary
>    worktree and switched to it for the user, instead of complaining
>    and failing?

I'm not sure. The question is whether the user recognizes that migrating references in the worktree would also migrate references in the main repository. It might be surprising behaviour if we did that without asking.

It might of course also be surprising if you do that from the main working tree. But I think there's an argument to be made that it's at least _less_ surprising.

Show 14 quoted lines
> >> @@ -95,7 +96,7 @@ KNOWN LIMITATIONS
> >>  
> >>  The ref format migration has several known limitations in its current form:
> >>  
> >> -* It is not possible to migrate repositories that have worktrees.
> >> +* Migration must be run from the main worktree.
> >>  
> >
> > I'd drop this bullet point entirely, as I don't really see this as a
> > limitation anymore.
> 
> I agree that such a limitation should be lifted, but if we have to
> say "you must do it this way, not that way", that is still a
> limitation ;-).

So with the above reasoning I'm not sure I'd call this a limitation. It's rather a mechanism to protect users from unexpected consequences.

Patrick
Previous: Junio C HamanoNext: Kristoffer Haugsbakk
Message 4 of 8 in “refs: support migration with worktrees”
  1. refs: support migration with worktreesSam Bostock via GitGitGadget, Oct 27, 2025
  2. Patrick SteinhardtOct 28, 2025
  3. Junio C HamanoOct 28, 2025
  4. Patrick SteinhardtOct 29, 2025
  5. Kristoffer HaugsbakkOct 29, 2025
  6. Ben KnobleOct 29, 2025
  7. Patrick SteinhardtOct 30, 2025
  8. Junio C HamanoOct 29, 2025

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.