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

Re: [PATCH v3 2/3] worktree: link worktrees with relative paths

From
Caleb White <cdwhite3@pm.me>
Date
Oct 9, 2024, 18:49 UTC
Message-ID
<18nudmdBF3K-9cMiTynl4-amBudFtwKaaZtIkF4E86BwxmjYNV_ISMihIddKiwYZBTEXSbJ2XFliyXDwaGs94pn3Xj8-V8QtggsTgFXl4to=@pm.me>
In-Reply-To
<de748e18-d3c1-4c34-a2c8-086271c208dd@gmail.com>
On Wednesday, October 9th, 2024 at 05:11, Phillip Wood <phillip.wood123@gmail.com> wrote:
> This is quite a sweeping claim, it would be helpful to describe the
> trade off that this patch is making.

Thank you for your feedback, I'll adjust the language and add some additional examples.

> but as I understand it while there are cases such as
> sharing a drive between Windows and linux or moving all the worktrees
> including the main one together where using relative paths prevents problems
This is true, there are several cases where relative paths prevent breakages.
> there are other cases such as moving a single worktree that are
> fixable by running "git worktree repair" when using absolute paths but
> not with relative paths.

This is not exactly true, if only the **repository** is moved then yes it will no longer be able to find it's worktrees without the absolute path, however, `git worktree repair` can still repair the worktree when provided the path to the worktree (or the directory containing the worktrees I believe).

> It was suggested in another thread I saw recently that storing both
> would be more resiliant.

I'm not too sure what you mean here, but storing both the absolute and relative paths in both files seems like an over-complication (not sure if that's what you were talking about or not). However, this patch series does support the linking files containing either absolute or relative paths.

Show 6 quoted lines
> Another possibility would be to store the an absolute path in the
> worktree's .git file and relative paths in worktrees/*/gitdir. That
> would enable "git worktree repair" run in a moved worktree to find the
> main worktree if the main worktree has not been moved as it does now. It
> would also allow "git worktree repair" run in the main worktree that has
> been moved to find the linked worktrees that were moved in tandam with it.

Storing the absolute path in the `.git` and relative paths in the `gitdir` will not work---it will still suffer from the same limitations that we are trying to avoid. And all the test cases related to `worktree repair` are passing with relative paths.

Best,
Previous: Phillip WoodNext: Caleb White
Message 21 of 24 in “Link worktrees with relative paths”
  1. 0/3 Link worktrees with relative pathsCaleb White via B4 Relay, Oct 8, 2024
  2. 1/3 worktree: refactor infer_backlink() to use *strbufCaleb White via B4 Relay, Oct 8, 2024
  3. shejialuoOct 10, 2024
  4. Caleb WhiteOct 10, 2024
  5. shejialuoOct 10, 2024
  6. Caleb WhiteOct 10, 2024
  7. Junio C HamanoOct 10, 2024
  8. Caleb WhiteOct 10, 2024
  9. Junio C HamanoOct 10, 2024
  10. 3/3 worktree: add test for path handling in linked worktreesCaleb White via B4 Relay, Oct 8, 2024
  11. 2/3 worktree: link worktrees with relative pathsCaleb White via B4 Relay, Oct 8, 2024
  12. Junio C HamanoOct 8, 2024
  13. Caleb WhiteOct 9, 2024
  14. Junio C HamanoOct 9, 2024
  15. Caleb WhiteOct 9, 2024
  16. Junio C HamanoOct 9, 2024
  17. Caleb WhiteOct 10, 2024
  18. Caleb WhiteOct 11, 2024
  19. Caleb WhiteOct 22, 2024
  20. Phillip WoodOct 9, 2024
  21. Caleb WhiteOct 9, 2024
  22. Caleb WhiteOct 8, 2024
  23. Junio C HamanoOct 8, 2024
  24. Caleb WhiteOct 8, 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.