fix: detect linked git worktrees when locating source-control root#18
Merged
philasmar merged 9 commits intoMay 21, 2026
Merged
Conversation
ci: improve release process using GitHub workflows
In a linked git worktree, `.git` is a file containing a `gitdir:` pointer rather than a directory. The previous root lookup only looked for `.git` as a directory, so it walked past the worktree and resolved to the main repository's root, causing change files to be written into the wrong repo and other commands to operate on the wrong tree. Treat a `.git` file as a valid root marker alongside a `.git` directory. LibGit2Sharp already handles worktree paths natively when constructing `new Repository(...)`, so no other code paths need to change. Adds a regression test that creates a real linked worktree with `git worktree add` and asserts that `autover change` writes inside the worktree, not the main repository.
philasmar
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.gitis a file containing agitdir:pointer rather than a directory.GitHandler.FindGitRootDirectoryonly checked for.gitas a directory, so it walked past the worktree and resolved to the main repository — change files were written into the wrong repo and other commands operated on the wrong tree..gitfile as a valid root marker alongside a.gitdirectory. LibGit2Sharp already resolves worktree paths natively innew Repository(path), so no other code paths required changes.Repro
Test plan
GitWorktreeTest.ChangeCommand_FromLinkedWorktree_WritesChangeFileInsideWorktreecreates a real linked worktree viagit worktree addand assertsautover changewrites inside the worktree and not in the main repository.