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

Re: "git worktree repair" modifies the wrong repository

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Sep 19, 2024, 10:47 UTC
Message-ID
<CAPig+cTkpLLoTxTa-8xfycNGFibN_M71+kkHtT-wgp6HRPi-aw@mail.gmail.com>
In-Reply-To
<3b579ddd-b386-4daa-ad63-1e75522b7462@stuart.id.au>

On Thu, Sep 19, 2024 at 6:16 AM Russell Stuart <russell+git.vger.kernel.org@stuart.id.au> wrote:

> I can't resist pointing out if "git worktree add" had of preserved the
> relative paths I gave it, it would not have happened.

The idea of relative paths has been discussed previously[*] but was never implemented; although they may help some cases, they break other cases or at least make the other cases more difficult. For instance, relative paths only help if the main and linked worktrees move together in some uniform fashion, but don't help if they move in distinct ways. Storing *both* the absolute and relative paths rather than only the absolute path was also discussed and seemed promising, but concerns were raised that doing so could break other Git-related tools or non-canonical Git implementations (or even perhaps older versions of Git itself), thus was never pursued.

FOOTNOTES

[*] The previous discussion was in the context of an earlier implementation of git-worktree, long before there was a "repair" subcommand. In fact, the very original implementation of linked worktrees (which was actually `git checkout --to=<path>` would attempt to automatically repair itself whenever any Git command discovered some sort of breakage, however, that initial implementation was buggy in some fashion (I don't have the details at hand), so the auto-repair feature was removed very early on. The "repair" subcommand came much later and took the conservative approach of addressing common problems people were reporting at the time, and was extended as new reports came in, rather than trying to tackle every possible way in which someone could wield a foot-gun.

Previous: Russell StuartNext: Russell Stuart
Message 4 of 11 in “"git worktree repair" modifies the wrong repository”
  1. Russell StuartSep 19, 2024
  2. Eric SunshineSep 19, 2024
  3. Russell StuartSep 19, 2024
  4. Eric SunshineSep 19, 2024
  5. Russell StuartSep 19, 2024
  6. Eric SunshineSep 23, 2024
  7. Phillip WoodSep 24, 2024
  8. Eric SunshineOct 3, 2024
  9. phillip.wood123@gmail.comOct 4, 2024
  10. Junio C HamanoOct 4, 2024
  11. Russell StuartSep 25, 2024

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.