Skip to content

Gracefully handle when linked worktree .git path is outside worktree root#53443

Merged
rtfeldman merged 1 commit intomainfrom
fix-is-git-dir-for-gitfiles
Apr 8, 2026
Merged

Gracefully handle when linked worktree .git path is outside worktree root#53443
rtfeldman merged 1 commit intomainfrom
fix-is-git-dir-for-gitfiles

Conversation

@rtfeldman
Copy link
Copy Markdown
Contributor

@rtfeldman rtfeldman commented Apr 8, 2026

In update_git_repositories, a .git path outside the worktree root can occur legitimately when .git is a gitfile (as in linked worktrees and submodules) pointing to a directory in the parent repo. Previously this triggered a debug_panic!, crashing debug builds.

Now we skip the path with a debug_assert! that it is indeed a file (not a directory), so a genuine .git directory outside the worktree root would still be caught in debug builds.

(No release notes because this is extremely hard to encounter until #53215 lands)

Release Notes:

  • N/A

…e root

In update_git_repositories, a .git path outside the worktree root can
occur legitimately when .git is a gitfile (as in linked worktrees and
submodules) pointing to a directory in the parent repo. Previously this
triggered a debug_panic. Now we skip it with a debug_assert that it is
indeed a file, not a directory.
@rtfeldman rtfeldman self-assigned this Apr 8, 2026
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Apr 8, 2026
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Apr 8, 2026
@rtfeldman rtfeldman changed the title worktree: Fix panic when linked worktree .git path is outside worktree root Gracefully handle when linked worktree .git path is outside worktree root Apr 8, 2026
@rtfeldman rtfeldman marked this pull request as ready for review April 8, 2026 19:35
@rtfeldman rtfeldman merged commit fb949ae into main Apr 8, 2026
44 checks passed
@rtfeldman rtfeldman deleted the fix-is-git-dir-for-gitfiles branch April 8, 2026 19:51
@mikayla-maki
Copy link
Copy Markdown
Member

@zed-zippy approve

@rtfeldman
Copy link
Copy Markdown
Contributor Author

/cherry-pick preview

github-actions bot pushed a commit that referenced this pull request Apr 9, 2026
…root (#53443)

In `update_git_repositories`, a `.git` path outside the worktree root
can occur legitimately when `.git` is a gitfile (as in linked worktrees
and submodules) pointing to a directory in the parent repo. Previously
this triggered a `debug_panic!`, crashing debug builds.

Now we skip the path with a `debug_assert!` that it is indeed a file
(not a directory), so a genuine `.git` directory outside the worktree
root would still be caught in debug builds.

(No release notes because this is extremely hard to encounter until
#53215 lands)

Release Notes:

- N/A
zed-zippy bot added a commit that referenced this pull request Apr 9, 2026
…root (#53443) (cherry-pick to preview) (#53565)

Cherry-pick of #53443 to preview

----
In `update_git_repositories`, a `.git` path outside the worktree root
can occur legitimately when `.git` is a gitfile (as in linked worktrees
and submodules) pointing to a directory in the parent repo. Previously
this triggered a `debug_panic!`, crashing debug builds.

Now we skip the path with a `debug_assert!` that it is indeed a file
(not a directory), so a genuine `.git` directory outside the worktree
root would still be caught in debug builds.

(No release notes because this is extremely hard to encounter until
#53215 lands)

Release Notes:

- N/A

Co-authored-by: Richard Feldman <richard@zed.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants