Skip to content

fix(find): include force-tracked files under gitignored directories - #4253

Open
BeeKnown wants to merge 1 commit into
rtk-ai:developfrom
BeeKnown:fix/find-force-tracked-ignored
Open

BeeKnown wants to merge 1 commit into
rtk-ai:developfrom
BeeKnown:fix/find-force-tracked-ignored

Conversation

@BeeKnown

@BeeKnown BeeKnown commented Sep 26, 2026 •

Copy link
Copy Markdown

Refs #2995 (force-tracked subcase)

Summary

  • .gitignore never applies to tracked files, but the ignore-crate walker in native_walk can't see git's index, so a file force-added (git add -f) inside an ignored directory was pruned along with that directory and silently missing from rtk find results.
  • After the walk, native_walk now runs git ls-files -z --cached --ignored --exclude-standard (only tracked files that match ignore rules, so the output stays small) and adds entries that match the pattern and weren't already found. It honors max_depth and the hidden-entry rule, and skips deleted-but-tracked files and submodule gitlinks. It does nothing outside a git repo or when git fails.
  • Out of scope: the (N filtered) tee log still lists ignored directory names rather than the paths inside them (the second half of rtk find -iname silently drops matches inside a gitignored-but-tracked directory #4244). With this fix, the issue's repro still reports data/ as filtered, because the directory holds an untracked file, which is correct.

Test plan

  • cargo fmt --all --check: clean. cargo clippy --all-targets: no warnings.
  • cargo test --no-fail-fast: 3968 passed, 2 failed. Both failures (guard_integration_test::git_diff_dash_dash_stat_pathspec_after_double_dash_is_not_stat_flag and git_log_malformed_digit_run_propagates_real_git_error) also fail on unmodified develop @ f3d4d9b on this machine (macOS, git 2.39.5 Apple Git-154), so they aren't caused by this change.
  • New test force_tracked_files_under_ignored_dirs_are_found, which covers a case-insensitive match, excluding untracked files in the ignored dir, max_depth, and -type d. It fails without the fix (left: ["src/target.py"]) and passes with it.
  • Manual: the issue's repro script now prints data/subdir/target.py and src/target.py, the same as rtk proxy find. On a real repo that gitignores data/ and force-tracks scripts inside it, find . -iname '*.py' went from 32 to 53 files. The 21 extra files are exactly the tracked-but-ignored .py files git ls-files -ci --exclude-standard reports.

Performance note

This adds one git subprocess per native rtk find. Measured on macOS (release build, 20 runs, a 377-file repo): about 30 ms to 40 ms per invocation, so about 10 ms added. If that's too much for the startup budget, the call could be gated, for example to run only when the walk actually pruned something because of an ignore rule. That's your call.

🤖 Generated with Claude Code

@CLAassistant

CLAassistant commented Sep 26, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working find git labels Sep 26, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes native rtk find so it no longer silently omits force-tracked files (git add -f) that live inside gitignored directories, since the ignore-crate walker prunes those directories entirely. After the normal walk, it runs git ls-files -z --cached --ignored --exclude-standard and merges in any matching tracked files not already found, respecting max_depth and hidden-entry rules.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4244


Analyzed automatically by wshm · This is an automated analysis, not a human review.

`.gitignore` never applies to tracked files, but the ignore-crate walker
cannot see git's index, so a file force-added (`git add -f`) inside an
ignored directory was pruned along with that directory and silently
missing from `rtk find` results. After the walk, ask git for tracked
files matching ignore rules and add those that match the pattern,
honoring max depth and the hidden-entry rule.

Fixes rtk-ai#4244

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@BeeKnown

BeeKnown commented Nov 3, 2026

Copy link
Copy Markdown
Author

Hi, following up on this PR. The CI workflow expired while waiting for approval, so no CI jobs ran. Could a maintainer take a look and let me know whether the checks can be restarted? Thanks!

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

Labels

bug Something isn't working find git

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants