fix(scan): preserve whitespace in Git paths - #868
Closed
RerankerGuo wants to merge 1 commit into
Closed
Conversation
Keep NUL-delimited git ls-files entries exact so valid filenames with leading or trailing whitespace remain scannable. Add a real-repository regression test for both cases. Test: make check && make test && make build && make coverage
Contributor
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). |
wu21-web
approved these changes
Aug 13, 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.
Description
ocr scanalready asksgit ls-filesfor NUL-delimited paths, but thenapplies
strings.TrimSpaceto every returned filename. Valid tracked fileswhose names begin or end with whitespace are therefore changed before the
scanner opens them.
For example, Git returns these exact paths:
The scanner previously attempted to stat
leading.goandtrailing.goinstead. Both lookups failed and the files silently disappeared from the scan.
This change keeps each NUL-delimited Git path exact while continuing to ignore
genuinely empty records. User-supplied
ocr scanpath filters retain theirexisting whitespace normalization.
Type of Change
How Has This Been Tested?
make checkmake testmake buildmake coverage- 90.2%, meeting the 90% thresholdBefore the fix, the regression test logged two
cannot statwarnings andreturned no scan items. After the fix, both files are enumerated under their
exact names. The focused test and full suite pass with the race detector.
The trailing-space fixture is skipped on Windows because the filesystem cannot
represent that filename; Windows cross-compilation remains covered by CI.
Self-review used OCR Delegation Mode with the host agent:
2/2changed files reviewed,0skipped,0findings.Checklist
go fmt,go vet)Related Issues
No existing issue found. All open issues, pull request text, and open pull
request changed files were checked before implementation; no competing scan
path-enumeration change was found.