Skip to content

Conversation

@prateek
Copy link

@prateek prateek commented Jan 6, 2026

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

  • In git repos with git available: completion candidates come from git (tracked + untracked-not-ignored).
  • Outside git repos / without git: keep prior behavior (no filtering) so completion still works.

Implementation

  • Use git ls-files to build the corpus:
    • tracked: git ls-files (excluding git ls-files --deleted)
    • untracked-not-ignored: git ls-files --others --exclude-standard
  • Cache repo info + file list for a short TTL (1s) to avoid spawning git on every keypress.

Testing

  • cd codex-rs && cargo test -p codex-file-search

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@prateek-oai
Copy link

I have read the CLA Document and I hereby sign the CLA

@prateek
Copy link
Author

prateek commented Jan 6, 2026

recheck

github-actions bot added a commit that referenced this pull request Jan 6, 2026
Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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".

Comment on lines 75 to 83
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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
@etraut-openai
Copy link
Collaborator

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.

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.

3 participants