-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Respect gitignore for @ file completion #8787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 079e128e40
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
codex-rs/file-search/src/lib.rs
Outdated
| let output = Command::new("git") | ||
| .args(["rev-parse", "--show-toplevel", "--show-prefix"]) | ||
| .current_dir(&key) | ||
| .output() | ||
| .ok()?; | ||
| if !output.status.success() { | ||
| let mut guard = cache.lock().unwrap_or_else(|err| err.into_inner()); | ||
| guard.insert(key, None); | ||
| return None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-check repo status instead of caching None forever
Because non-repo results are cached permanently, a long-lived process that starts outside a repo and later runs git init (or otherwise turns the directory into a repo) will keep returning the cached None and skip git-based filtering, so completions never respect the new .gitignore until restart. Consider expiring or revalidating negative cache entries (e.g., TTL) so repo creation is detected.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressing in next patch
- Keep ignore filtering enabled on fallback walks when respect_gitignore=true\n- Expire negative git-repo cache entries; evict expired file lists\n- Add regression tests for non-git fallback + cache revalidation
|
If we accept this behavior change, it should also be reflected in the IDE extension and web interfaces. We're trying to keep the behavior consistent across all Codex surfaces. |
Summary
Fix
@path completion to respect git ignore rules (including nested.gitignore,.git/info/exclude, and user global excludes) while keeping tracked files visible.Behavior
gitavailable: completion candidates come from git (tracked + untracked-not-ignored).git: keep prior behavior (no filtering) so completion still works.Implementation
git ls-filesto build the corpus:git ls-files(excludinggit ls-files --deleted)git ls-files --others --exclude-standardTesting
cd codex-rs && cargo test -p codex-file-search