Repository navigation
fix(review): resolve repo root for untracked file discovery - #450
Merged
backnotprop merged 1 commit intoMar 31, 2026
Merged
Conversation
git ls-files scopes to the CWD subtree and returns CWD-relative paths, unlike git diff HEAD which covers the full repo with root-relative paths. When the hook process inherits a subdirectory CWD, untracked files outside that subtree are silently dropped and paths for files inside it are wrong. Resolve the repo root via rev-parse --show-toplevel and use it as the CWD for both git ls-files and git diff --no-index in getUntrackedFileDiffs. Fixes backnotprop#449
Owner
|
looks good thanks! |
backnotprop
pushed a commit
that referenced
this pull request
Apr 1, 2026
git ls-files scopes to the CWD subtree and returns CWD-relative paths, unlike git diff HEAD which covers the full repo with root-relative paths. When the hook process inherits a subdirectory CWD, untracked files outside that subtree are silently dropped and paths for files inside it are wrong. Resolve the repo root via rev-parse --show-toplevel and use it as the CWD for both git ls-files and git diff --no-index in getUntrackedFileDiffs. Fixes #449
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
getUntrackedFileDiffssogit ls-fileslists all untracked files, not just those under the process CWDgit diff --no-indexso paths are root-relative, matching tracked-diff outputrunGitDifffrom a subdirectoryProblem
git ls-files --others --exclude-standardscopes to the CWD subtree and returns CWD-relative paths.git diff HEADalways covers the full repo with root-relative paths. When the hook process inherits a subdirectory CWD (e.g., an agent thatcd'd intopackages/foo/), untracked files outside that subtree are silently dropped and the one that is found gets a wrong relative path in the diff header.AI
Note that I used Opus 4.6 to assist with identifying, filing the GitHub issue, and the TDD-resolution of this bug.
Fixes #449