fix(walk): match git when trimming a gitfile path - #18
Merged
Merged
Conversation
A gitfile's path was trimmed of ALL trailing whitespace. Git trims exactly `\n` and `\r`, so a git directory whose NAME ends in a space is reachable through a gitfile — verified against real git, which resolves `gitdir: <dir >` and rejects the same path trimmed. Trimming whitespace silently pointed such a repo at a different directory, and its `info/exclude` was then never found. Also replaces the size-cap test's body. It used 200 KB of `x`, which is not a gitfile at any size, so the assertion held with or without the cap and proved nothing about reading. An oversized but WELL-FORMED gitfile is the case the cap actually decides; the test now pairs one over the cap (kept, subtree walked) with the same body under it (a boundary), and fails if the cap is removed. Claude-Session: https://claude.ai/code/session_01YDMVcJNo7WZh9xFAGWs2F8
github-actions Bot
pushed a commit
that referenced
this pull request
Sep 3, 2026
## [2.28.4](v2.28.3...v2.28.4) (2026-09-03) ### Bug Fixes * **walk:** match git when trimming a gitfile path ([#18](#18)) ([847010f](847010f))
Contributor
|
🎉 This PR is included in version 2.28.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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
Two nits from a follow-up review of #17, both confirmed against real git before changing anything.
1. The gitfile path was over-trimmed
gitDirOfstripped all trailing whitespace from a gitfile's path. Git strips exactly\nand\r— so a git directory whose name ends in a space is reachable through a gitfile, and trimming silently resolved it to a different directory whoseinfo/excludewas then never read.Probed against real git (a repo whose git dir is named
store␠):.gitbodygitdir: <…/store␠>\ngitdir: <…/store>\n(path trimmed)fatal: not a git repositorygitdir: <…/store␠>\r\ngitdir: <…/store␠>␠␠␠\n(extra spaces)fatal: not a git repositorySo git trims the line ending and nothing else.
.replace(/\s+$/, "")→.replace(/[\r\n]+$/, "").2. The size-cap test asserted nothing about the cap
Its body was 200 KB of
x, which is not a gitfile at any size — so the subtree was kept with or without the cap and the test passed either way. The cap is only observable on a marker that would otherwise parse. The test now pairs an oversized well-formed gitfile (kept, subtree walked) with the same body under the cap (a boundary), and fails when the cap is raised.Verification
pnpm typecheck,pnpm test(1 291 passed, 50 skipped),pnpm run check:buildall pass.main: the trailing-space case yields['dropped.ts', 'kept.ts']instead of['kept.ts'], and the cap case fails whenMAX_GITFILE_BYTESis raised.graph.json/symbols.jsonbyte-identical on a real 2 924-file repo; the nested-repo fixture still resolves to the same 5 files.🤖 Generated with Claude Code
https://claude.ai/code/session_01YDMVcJNo7WZh9xFAGWs2F8