git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Link worktrees with relative paths
@ 2024-10-06  4:59 Caleb White
  2024-10-06  4:59 ` [PATCH 1/4] worktree: refactor infer_backlink() to use *strbuf Caleb White
                   ` (4 more replies)
  0 siblings, 5 replies; 23+ messages in thread
From: Caleb White @ 2024-10-06  4:59 UTC (permalink / raw)
  To: git; +Cc: Caleb White

[-- Attachment #1: Type: text/plain, Size: 2305 bytes --]

Hello,

This patch series modifies Git's handling of worktree linking to use
relative paths instead of absolute paths. The motivation behind this
change is to enhance the robustness of worktree links when the main
repository is moved, or when used in environments like containerized
development where absolute paths differ across systems.

Currently, Git stores absolute paths to both the main repository and
the linked worktrees. This causes issues when the repository is moved
because the hardcoded paths become invalid, leading to broken worktree
links. Developers are then required to manually repair the links by
running `git worktree repair`, which can be cumbersome.

By switching to relative paths for worktrees, this patch improves the
resilience of worktree links. For self-contained repositories (e.g.,
bare repositories with worktrees), the links will continue to function
properly when the repository is moved or mapped inside a containerized
environment. While relativ
e paths do not completely eliminate the need
for repairs (as links external to the repository can still break), the
likelihood is reduced, and Git continues to provide mechanisms to repair
broken links when needed.

I have included tests to verify that:
- worktree links are created with relative paths.
- moving the repository does not break worktree links.

Note that absolute paths are still supported, and the code handles both
types of paths. There should be no breaking changes introduced with this
patch. I considered adding a configuration option
(e.g., `worktree.useRelativePaths`) to control path type, but decided to
keep it simple. However, if there is interest, I can add this feature.

This series is based on top of 111e864d69.

Thanks!

Caleb

Caleb White (4):
  worktree: refactor infer_backlink() to use *strbuf
  worktree: link worktrees with relative paths
  worktree: sync worktree paths after gitdir move
  worktree: prevent null pointer dereference


 builtin/worktree.c           |  17 +--
 setup.c                      |   2 +-
 t/t2408-worktree-relative.sh |  39 ++++++
 worktree.c                   | 235 +++++++++++++++++++++++++++--------
 worktree.h                   |  10 ++
 5 files changed, 240 insertions(+), 63 deletions(-)
 create mode 100755 t/t2408-worktree-relative.sh

-- 
2.46.2


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 509 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2024-10-06 22:32 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-06  4:59 [PATCH 0/4] Link worktrees with relative paths Caleb White
2024-10-06  4:59 ` [PATCH 1/4] worktree: refactor infer_backlink() to use *strbuf Caleb White
2024-10-06  4:59 ` [PATCH 2/4] worktree: link worktrees with relative paths Caleb White
2024-10-06  4:59 ` [PATCH 3/4] worktree: sync worktree paths after gitdir move Caleb White
2024-10-06  4:59 ` [PATCH 4/4] worktree: prevent null pointer dereference Caleb White
2024-10-06  5:04 ` [PATCH 0/4] Link worktrees with relative paths Eric Sunshine
2024-10-06  5:11   ` Caleb White
2024-10-06  5:14     ` Eric Sunshine
2024-10-06  5:16       ` Eric Sunshine
     [not found]         ` <TEfKiit-RYyr0ZuiQszaKaM64iSonfaQwWRqExOgXyPR1tVWyAzR3kVKmCd3aREZwDGuS5VXcHjCvneY-gCg2OuZyv2N2EkfARlZu4AVSsU=@pm.me>
     [not found]           ` <CAPig+cTE0gaD=7dwSqY4S+7AqRoU9yOrS4sdBoybj0Pfyk9vxA@mail.gmail.com>
2024-10-06  5:41             ` Caleb White
2024-10-06  5:50               ` Eric Sunshine
2024-10-06  6:05                 ` Caleb White
2024-10-06  6:16                   ` Eric Sunshine
2024-10-06  6:23                     ` Caleb White
2024-10-06  7:45                       ` Eric Sunshine
2024-10-06  9:00                         ` Kristoffer Haugsbakk
2024-10-06 22:10                           ` Caleb White
2024-10-06 22:08                         ` Caleb White
2024-10-06 22:24                           ` Eric Sunshine
2024-10-06 22:32                             ` Caleb White
2024-10-06  5:11   ` Eric Sunshine
2024-10-06 22:01     ` Caleb White
2024-10-06 22:19       ` Eric Sunshine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).