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

Re: "git worktree repair" modifies the wrong repository

From
RSRussell Stuart <russell@stuart.id.au>
Date
Sep 25, 2024, 09:31 UTC
Message-ID
<b9f55058-354d-4a61-ac3b-92ea56026693@stuart.id.au>
In-Reply-To
<CAPig+cTop=2+k0XbqYbsCTbJVo77evY+_a+FqDV_ziKf2q+Dzw@mail.gmail.com>
Sorry, I missed this reply.
On 24/9/24 04:52, Eric Sunshine wrote:
> [1]: The discussion begins at the "Also Eric" paragraph of this email
> and continues in emails following it:
> https://lore.kernel.org/git/CACsJy8CXEKG+WNdSPOWF7JDzPXidSRWZZ5zkdMW3N3Dg8SGW_Q@mail.gmail.com/
Yes, Duh's comments pretty much sums it up.
> This intuition perhaps arises from your background with "hg", but I
> have not formed any such intuition.

Not only from hg. You can freely move the parent directory of all CVS systems I'm aware of - hg, svn, cvs, rcs, sccs and yes git too. It only breaks when you add worktrees to git.

Show 7 quoted lines
> That's a very restrictive and limiting organization. As I understand
> it, one of the design goals of Git's linked worktrees was to allow
> worktrees to be placed anywhere, including on removable media or
> not-always-mounted network drives. (Yes, you may be able to do
> something similar with "hg" and symbolic links, but that doesn't play
> well with Windows users, at least not in the era when Git's worktree
> support was implemented.)

Yes, it is far more restrictive than git worktrees are now. It simplifies the users the mental model of what is going on, but that simplification comes at a cost. I only mentioned it because relative paths in worktrees would allow you to pretend it works that way.

Show 7 quoted lines
> Can you provide more details about this "mangling"? Although the
> use-case you describe was not directly considered in the initial
> design, worktrees hanging off a bare repository became an
> explicitly-supported use-case not long after worktrees were
> introduced. So, it should work properly and we know that people use
> worktrees this way, but we haven't had any reports of mangling in this
> scenario.

Phillip's reply was spot on: https://lore.kernel.org/git/87afa860-52f4-414a-82da-09e7eeac1301@gmail.com/

> By the way, have you seen the patch recently posted[3] to explicitly
> support relative paths for worktrees?
> 
> [3]: https://lore.kernel.org/git/pull.1783.git.git.1726880551891.gitgitgadget@gmail.com/
Ahh, now I see why using both is attractive
Previous: Junio C Hamano
Message 11 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.