Match git check-ignore for tracked ignored paths#2564
Open
Sebastian Thiel (Byron) wants to merge 1 commit into
Open
Match git check-ignore for tracked ignored paths#2564Sebastian Thiel (Byron) wants to merge 1 commit into
Sebastian Thiel (Byron) wants to merge 1 commit into
Conversation
Fix gix exclude query so ignore matches are suppressed for paths that are present in the index, matching git check-ignore behavior for tracked files under ignored directories. The issue reproduces with a root ignore rule like bin/ and a force-added tracked file such as src/bin/stub_gen.rs. Git reports no ignore pattern for src/bin, src/bin/, or src/bin/stub_gen.rs, but still reports the bin/ rule for untracked paths like src/bin/extra.txt and other/bin/file.txt. gix status already matched this behavior through the dirwalk, so the fix is in the exclude query command path. The query implementation now checks the index before printing exclude matches, preserves stdin paths relative to the caller current directory, and keeps pathspec expansion semantics for tracked entries, exclusions, top magic, and attribute-qualified pathspecs. Tests cover both gix exclude query input modes against git check-ignore -vn --stdin, subdirectory stdin handling, pathspec expansion behavior, and the gix-worktree ignore baseline case for tracked files under ignored directories. Validation: - cargo test -p gitoxide-core --lib --quiet - GIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix-worktree-tests worktree::stack::ignore --quiet Fixes #2562
a9232e6 to
66f8bc3
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates ignore/exclude querying to match git check-ignore semantics for paths that are ignored but tracked (or contain tracked entries), and extends the fixture baseline to cover the “tracked under ignored directory” scenario described in #2562.
Changes:
- Update the
gitoxide-coreexclude query implementation to suppress ignore matches for tracked paths (and tracked directories) based on index presence, aligning output withgit check-ignore. - Extend the
gix-worktreeignore baseline fixture to include ignored directories containing tracked files, and adjust the test harness to read baseline inputs/outputs from the fixture execution directory. - Add targeted unit tests in
gitoxide-coreto lock in expected behavior (tracked paths suppression, stdin path relativity, and pathspec expansion preservation).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| gix-worktree/tests/worktree/stack/ignore.rs | Adjusts baseline test logic to suppress ignore matches when the index indicates the path is tracked (or a tracked directory). |
| gix-worktree/tests/fixtures/make_ignore_and_attributes_setup.sh | Updates fixture repo setup and baseline generation to include the tracked-under-ignored-directory case and to emit baseline files in the fixture execution dir. |
| gitoxide-core/src/repository/exclude.rs | Implements index-based suppression of ignore matches and adds tests to verify parity with git check-ignore and preserve pathspec-related behavior. |
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.
Codex created this PR on behalf of Byron. Byron will review it.
Fixes #2562
Summary
gix exclude queryignore matches for paths that are present in the index, matchinggit check-ignoreGit baseline
For a repository with
.gitignorecontainingbin/and force-addedsrc/bin/stub_gen.rs,git check-ignore -vn --stdinreports no ignore pattern for:src/binsrc/bin/src/bin/stub_gen.rsIt still reports
.gitignore:1:bin/for untracked ignored paths:src/bin/extra.txtother/binother/bin/file.txtgix status --ignored matching --no-writealready matched Git for this repro, so the fix is scoped togix exclude queryrather than dirwalk.Validation
cargo test -p gitoxide-core --lib --quietGIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix-worktree-tests worktree::stack::ignore --quiet