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,