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

Re: [PATCH 2/2] worktree: add `relativeWorktrees` extension

From
Caleb White <cdwhite3@pm.me>
Date
Oct 28, 2024, 01:14 UTC
Message-ID
<D571HWYAD4MM.28JAS7D0Y6OI3@pm.me>
In-Reply-To
<Zx7YxLPItxvFJK62@nand.local>
On Sun Oct 27, 2024 at 7:20 PM CDT, Taylor Blau wrote:
Show 11 quoted lines
> On Fri, Oct 25, 2024 at 10:29:47PM +0000, Caleb White wrote:
>> A new extension, `relativeWorktrees`, is added to indicate that at least
>> one worktree in the repository has been linked with relative paths. This
>> extension is automatically set when a worktree is created or repaired
>> using the `--relative-paths` option, or when the
>> `worktree.useRelativePaths` config is set to `true`.
>
> This approach feels like a very heavy hammer. I wonder if writing
> worktrees with relative paths by default was too aggressive of a step,
> and if we should instead make the new behavior opt-in rather than
> opt-out.

The v4 series of the original round added the cli options and updated the relative worktrees to be opt-in. This patch keeps the git default behavior of writing worktrees with absolute paths, and users can opt-in via the `--relative-paths` cli option or the `worktree.useRelativePaths` config.

Show 12 quoted lines
> Saying that new worktrees are written with relative paths, and that
> creating a worktree with a new version of Git breaks reading the
> repository on older versions feels very unsatisfying to me.
>
>> The `relativeWorktrees` extension ensures older Git versions do not
>> attempt to automatically prune worktrees with relative paths, as they
>> would not not recognize the paths as being valid.
>
> This is the piece of information that I was missing in the earlier round
> when I merged that down. I think we need to take a step back and think
> about how to make this change safely in a way that doesn't break
> compatibility with older versions of Git.

Adding the extension was the direction suggested by Junio in the previous round. Git did not account for the possibility of the linking files containing relative paths, so there's really no way to make this change without breaking compatibility with older versions of Git. Git had to be taught how to handle files that could contain either absolute or relative paths.

Best, Caleb

Previous: Taylor BlauNext: Taylor Blau
Message 11 of 14 in “Allow relative worktree linking to be configured by the user”
  1. 0/2 Allow relative worktree linking to be configured by the userCaleb White, Oct 25, 2024
  2. 1/2 worktree: add CLI/config options for relative path linkingCaleb White, Oct 25, 2024
  3. Taylor BlauOct 28, 2024
  4. Taylor BlauOct 28, 2024
  5. Caleb WhiteOct 28, 2024
  6. Taylor BlauOct 28, 2024
  7. Caleb WhiteOct 28, 2024
  8. Caleb WhiteOct 28, 2024
  9. 2/2 worktree: add `relativeWorktrees` extensionCaleb White, Oct 25, 2024
  10. Taylor BlauOct 28, 2024
  11. Caleb WhiteOct 28, 2024
  12. Taylor BlauOct 28, 2024
  13. Caleb WhiteOct 28, 2024
  14. Taylor BlauOct 28, 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.