Repository navigation
Conversation
pjbgf
requested changes
Jun 19, 2026
pjbgf
left a comment
Member
There was a problem hiding this comment.
@Abiggj thanks for looking into this. Please re-phrase the commit so that it matches our contributing guide: plumbing: format/ignore, Ensure inclusion patterns match full paths.
Add the tests below into plumbing/format/gitignore/conformance_test.go so that we avoid future regression:
func (s *ConformanceSuite) TestIgnoreNegation_ancestorMatch() {
tests := []struct {
patterns []string
path string
isDir bool
ignored bool
desc string
}{
{
[]string{"*.log", "!important"},
"dir/important/app.log", false, true,
"!important matches ancestor dir, must not re-include app.log",
},
{
[]string{"*.log", "!important"},
"important/app.log", false, true,
"!important is ancestor-only; *.log still ignores the file",
},
{
[]string{"*.log", "!important"},
"important", true, false,
"!important re-includes the dir itself (basename match)",
},
{
[]string{"*", "!value/vul?ano"},
"value/vulkano/tail", false, true,
"!value/vul?ano matches an ancestor only; * keeps the file ignored",
},
}
for _, tt := range tests {
m := s.createMatcher(tt.patterns)
s.assertIgnore(m, tt.patterns, tt.path, tt.isDir, tt.ignored, tt.desc)
}
}
Contributor
I would add a further 2 more: |
Abiggj
force-pushed
the
bug-fix/issue-2112
branch
from
June 22, 2026 05:37
9f074ba to
1fe5d15
Compare
Author
|
Updated the commit message to follow the contributing guide and added the requested regression tests (including the extra !dir/ cases). All tests are passing. |
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.
This PR fixes issue #2112 where
.gitignoreinclusion patterns (e.g.,!dir/) incorrectly matched files inside those directories when a parent directory match was found.Changes
simpleNameMatch: Updated logic to require that inclusion patterns match the final component of the path. Parent directory matches are now ignored for inclusions, preventing them from overriding wildcard ignores for nested files.globMatch: Enforced full path consumption (or trailing**matches) for inclusion patterns to be considered a match.TestSimpleMatch_inclusion: Adjusted existing tests to reflect standard Git behavior, where an inclusion pattern for a directory does not automatically include its contents.These changes ensure that configurations like:
*!my-dir/correctly ignore files inside
my-dir/, matching the behavior of standard Git.