Skip to content

Preserve descendant restrictions in explicit trailing globstar patterns - #155

Closed
sricharanreddycheruku wants to merge 1 commit into
cpburnz:masterfrom
sricharanreddycheruku:fix-trailing-globstar-directory-patterns
Closed

sricharanreddycheruku wants to merge 1 commit into
cpburnz:masterfrom
sricharanreddycheruku:fix-trailing-globstar-directory-patterns

Conversation

@sricharanreddycheruku

Copy link
Copy Markdown

An explicit trailing // is currently normalized like an ordinary directory
pattern: folder/
/ becomes a regex matching folder/ itself. As a result, the
parent and its immediate files are incorrectly ignored. Git leaves those paths
available and excludes only descendant directories and their contents.

Preserve whether the source pattern contains an explicit final **/ segment before
normalization. Require a descendant directory during translation, and avoid the
match-all shortcut when /*// carries this restriction. The explicit /*/
contents pattern also avoids the ordinary */ shortcut, which incorrectly matches
its parent directory. Keep ordinary folder/,
**/ and collapsed // behavior unchanged. Apply the correction to both
GitIgnoreBasicPattern and GitIgnoreSpecPattern without changing public signatures.

Validation:

  • Six new test methods cover literal/anchored/wildcard prefixes, duplicate globstars,
    byte patterns, newline directory names, compatibility shortcuts and all eight
    backend/order configurations. Original source reports 42 failures, including
    subtests, with ten passing compatibility controls.
  • Complete Python 3.12.14 and 3.14.7 suites: 238 passed, 1 skipped, 954 subtests
    passed on each; simple, RE2 and Hyperscan installed.
  • Minimum Python 3.9.25: 177 passed, 62 optional-backend skips.
  • Python 3.14-targeted mypy/pyright and warning-as-error Sphinx HTML build pass.
  • Discrepancy discovered through comparisons against git check-ignore --no-index
    on real file trees. Expected parent/immediate-file behavior verified separately.

Update the README and change history. This translation fix is independent of the
prepared ancestor-resolution fix and passes on the current upstream base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant