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
Junio C Hamano <gitster@pobox.com>
Date
Oct 8, 2024, 23:09 UTC
Message-ID
<xmqqmsjexkcg.fsf@gitster.g>
In-Reply-To
<20241007-wt_relative_paths-v3-2-622cf18c45eb@pm.me>
Caleb White via B4 Relay <devnull+cdwhite3.pm.me@kernel.org> writes:
> From: Caleb White <cdwhite3@pm.me>
>
> Git currently stores absolute paths to both the main repository and
As always, drop "currently".
The usual way to compose a log message of this project is to
 - Give an observation on how the current system work in the present
   tense (so no need to say "Currently X is Y", just "X is Y"), and
   discuss what you perceive as a problem in it.
 - Propose a solution (optional---often, problem description
   trivially leads to an obvious solution in reader's minds).
 - Give commands to the codebase to "become like so".
in this order.
> linked worktrees. However, this causes problems when moving repositories

The above claim is way too strong. When relative references are used, you can move directories without problems only if you move all the worktrees and the repository in unison without breaking their relative locations, which is an exception and not the norm.

    The repository knows where its extra worktrees are by their
    absolute paths (and vice versa) to allow discovery of each
    other.  When a directory is moved, "git worktree repair" must be
    used to adjust these references.
    It however becomes possible, in a narrow special case, to do
    without "git worktree repair".  When the repository and the
    worktrees move in parallel without breaking their relative
    location, the repair operation becomes unneeded if we made them
    refer to each other using relative paths (think: tarring up both
    the reposity and the worktrees at the same time, and then
    untarring the result at a different place).
or something, perhaps.
> Although Git now writes relative paths, existing repositories with
> absolute paths are still supported. There are no breaking changes
> to workflows based on absolute paths, ensuring backward compatibility.

Good. Being able to work with existing repositories is an absolute requirement. Are there good test cases? I would imagine that you would need to force a worktree and its repository to refer to each other using absolute paths and then try to access with the updated code, perhaps moving one of such "old-style" directory and then using the updated "git worktree repair" and observing the result. To allow such a test possible, you might even need an option to "git worktree" to allow it to create these linkages using absolute paths, not relative (and if you need to keep both possibilities anyway, you might make the newer "relative" layout an optional feature, triggered by a command line option given to "git worktree add" and friends).

Have we considered how badly existing third-party tools, that has learned to assume that the paths are aboslute, may break with this change, though? Or is this "we won't know until we inflict it on real users and see who screams"?

Thanks.
Previous: Caleb White via B4 RelayNext: Caleb White
Message 12 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.