Repository navigation
worktree: status, Preserve re-included files below /** - #2386
znnnnnnn-wil wants to merge 2 commits into
Conversation
…2369 Track when a trailing /** matches an empty directory remainder so Status can traverse the directory without changing Pattern.Match semantics. Keep pruning directories that are explicitly excluded or are descendants matched by /**. Assisted-by: Codex GPT-5 <[email protected]> Signed-off-by: 唐僧洗发用飘柔 <[email protected]>
|
I opened #2369, so read this as an interested party's measurement rather than a review.
The four share one shape — a negation that re-includes a directory now leaks into that directory's contents, which git doesn't do. Two lines are enough to see it (the real ones come from
Worth one line: an independent patch for the same bug in another project (treeverse/dvc#11096, Python, different author) breaks those same four paths. Whatever is wrong is in the approach, not in this code. Bench and adapter: https://github.com/KaizenShogun/gitignore-conformance |
Keep trailing /** from excluding its parent, and evaluate rules against the current entry so re-including a directory does not re-include its contents. Continue looking at earlier rules when /** does not match the parent itself. Preserve public Pattern.Match and Matcher.Match behavior. Add reference-Git regressions for directory negations, nested ignore files, and an explicitly excluded parent followed by a contents wildcard. Assisted-by: Codex GPT-6 <[email protected]> Signed-off-by: 唐僧洗发用飘柔 <[email protected]>
|
Re-measured against the new head. The four paths I flagged are gone, and nothing else moved. Method:
Compared as sets rather than counts: The two-line repro from my earlier comment now agrees with git on both lines: One framing note, since it's easy to read the other way: the |
|
Thanks for re-running the comparison and for pointing out the framing. I've updated the description to compare against |
Summary
Fixes #2369.
Worktree.Status()prunesvolumes/functionsfor a rule ending involumes/functions/**, so a later!volumes/functions/deno.json*cannot expose a matching file. Git's trailing/**excludes the contents, not the parent itself.Evaluate built-in ignore patterns against the current entry in
Scope; excluded ancestors remain handled byDescend. This lets the walk reach re-included files without applying a directory's negation to its descendants. For example, withf/**and!f/deno.json*, a file namedf/deno.jsonsampleis visible, butf/deno.jsonsample/keepremains ignored whendeno.jsonsampleis a directory. Earlier explicit exclusions such asf/still take effect.Public
Pattern.MatchandMatcher.Matchbehavior stays unchanged. No filesystem-walker special case is needed.Reference behavior
https://git-scm.com/docs/gitignore#_pattern_format documents trailing
/**and the restriction on re-including files below excluded directories. The regression tests compare complete untracked sets withgit ls-files --others --exclude-standard, including the reported directory-negation cases and nested.gitignorefiles.Validation
On Windows, Go 1.26.5:
go test . -run 'TestStatus|TestWorktree.*Status' -count=1: passed.go test ./utils/merkletrie/filesystem -count=1: passed.go test ./plumbing/format/gitignore ./utils/merkletrie/filesystem -short -skip 'TestMatcherSuite/TestDir_ReadRelativeGlobalGitIgnore' -count=1: passed.golangci-lint run: 0 issues.git diff --check: passed.The unfiltered gitignore package run has two failures also reproduced on the unchanged PR commit:
TestDir_ReadRelativeGlobalGitIgnoreon this Windows environment, andTestIgnoreDoubleStarPrefixwith the installed Git 2.38.1 (the test documents the upstream Git fix in 2.52.0). These are not reported as passing.Paired runs of gitignore-conformance at
8d202f238ff3827e6e58bdb39a7cee5285f6317b, using its adapter with v6 imports and repository cleanup:Status(): 6,714 file queries across 33 repositories, 5 → 4 divergences compared withmain: one existing divergence fixed, with no new regressions. The remaining fourapps/docs/.../generated/.gitkeepdivergences are pre-existing, identical tomain, and untouched by this PR.ReadPatterns+Matcher.Match: 8,953 queries, the same 12 divergences before and after (the same paths, not just the same count).AI disclosure
Parts of the implementation and tests were assisted by Codex GPT-5 and GPT-6. The validation results above were obtained by running the tests and paired conformance measurements.