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

Re: [PATCH 3/5] worktree: teach "repair" to fix outgoing links to worktrees

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 27, 2020, 17:14 UTC
Message-ID
<xmqqh7soqady.fsf@gitster.c.googlers.com>
In-Reply-To
<20200827082129.56149-4-sunshine@sunshineco.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 18 quoted lines
> The .git/worktrees/<id>/gitdir file points at the location of a linked
> worktree's .git file. Its content must be of the form
> /path/to/worktree/.git (from which the location of the worktree itself
> can be derived by stripping the "/.git" suffix). If the gitdir file is
> deleted or becomes corrupted or outdated, then Git will be unable to
> find the linked worktree. An easy way for the gitdir file to become
> outdated is for the user to move the worktree manually (without using
> "git worktree move"). Although it is possible to manually update the
> gitdir file to reflect the new linked worktree location, doing so
> requires a level of knowledge about worktree internals beyond what a
> user should be expected to know offhand.
>
> Therefore, teach "git worktree repair" how to repair broken or outdated
> .git/worktrees/<id>/gitdir files automatically. (For this to work, the
> command must either be invoked from within the worktree whose gitdir
> file requires repair, or from within the main or any linked worktree by
> providing the path of the broken worktree as an argument to "git
> worktree repair".)

Would git "work" in a corrupt worktree whose gitfile is broken, in the sense that it notices that the cwd is the top of the working tree of a secondary worktree? I can imagine how it would work, starting in one of the functioning worktrees so that git can locate where the primary copy is, with end-user supplied path to a directory that is supposed to be the top of the working tree of a secondary worktree.

Hmph, if the secondary is _moved_, how would "worktree repair $path" would know which <id> the $path corresponds to? Would we just cull all the <id> that do not point at working secondary worktrees and add the $path as if it were a new one by allocating a new <id>, or reusing a randomly chosen <id> that points at a non-existing location?

Previous: Eric SunshineNext: Eric Sunshine
Message 11 of 22 in “add "git worktree repair" command”
  1. 0/5 add "git worktree repair" commandEric Sunshine, Aug 27, 2020
  2. 1/5 worktree: add skeleton "repair" commandEric Sunshine, Aug 27, 2020
  3. Junio C HamanoAug 27, 2020
  4. Eric SunshineAug 27, 2020
  5. 5/5 init: make --separate-git-dir work from within linked worktreeEric Sunshine, Aug 27, 2020
  6. 4/5 init: teach --separate-git-dir to repair linked worktreesEric Sunshine, Aug 27, 2020
  7. 2/5 worktree: teach "repair" to fix worktree back-links to main worktreeEric Sunshine, Aug 27, 2020
  8. Junio C HamanoAug 27, 2020
  9. Eric SunshineAug 30, 2020
  10. 3/5 worktree: teach "repair" to fix outgoing links to worktreesEric Sunshine, Aug 27, 2020
  11. Junio C HamanoAug 27, 2020
  12. Eric SunshineAug 30, 2020
  13. Junio C HamanoAug 31, 2020
  14. Johannes SchindelinAug 28, 2020
  15. Eric SunshineAug 28, 2020
  16. 0/5 add "git worktree repair" commandEric Sunshine, Aug 31, 2020
  17. 1/5 worktree: add skeleton "repair" commandEric Sunshine, Aug 31, 2020
  18. 3/5 worktree: teach "repair" to fix outgoing links to worktreesEric Sunshine, Aug 31, 2020
  19. 5/5 init: make --separate-git-dir work from within linked worktreeEric Sunshine, Aug 31, 2020
  20. 2/5 worktree: teach "repair" to fix worktree back-links to main worktreeEric Sunshine, Aug 31, 2020
  21. 4/5 init: teach --separate-git-dir to repair linked worktreesEric Sunshine, Aug 31, 2020
  22. Junio C HamanoAug 31, 2020

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.