codex - 💡(How to fix) Fix Code review includes untracked working-tree files (root cause identified but never fixed) [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#17160Fetched 2026-04-09 08:01:44
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×3unlabeled ×1

Root Cause

  • #8404 identified the exact root cause: codex-rs/core/src/review_prompts.rs runs git diff {mergeBaseSha} (compares merge-base to working tree) instead of git diff {mergeBaseSha}...HEAD (compares merge-base to branch HEAD). Closed after 3 months for "no upvotes."
  • #8548 reported that the agent commits untracked files via git add -A despite explicit repo policy. Closed same day as "model behavior."
RAW_BUFFERClick to expand / collapse

What version of Codex CLI is running?

codex-cli 0.116.0

What subscription do you have?

Pro

Which model were you using?

gpt-5.4 xhigh

What platform is your computer?

Darwin 25.4.0 arm64 arm

What terminal emulator and version are you using (if applicable)?

iTerm2

What issue are you seeing?

PR-style code review picks up untracked working-tree files (datasets, plot images, build artifacts, research notes) and reviews them as if they were part of the branch diff. This makes code review unusable in any repo that has local artifacts in the working tree.

This has been reported before

  • #8404 identified the exact root cause: codex-rs/core/src/review_prompts.rs runs git diff {mergeBaseSha} (compares merge-base to working tree) instead of git diff {mergeBaseSha}...HEAD (compares merge-base to branch HEAD). Closed after 3 months for "no upvotes."
  • #8548 reported that the agent commits untracked files via git add -A despite explicit repo policy. Closed same day as "model behavior."

The first issue is not model behavior. It is a one-line bug in the diff command. The root cause and fix were already identified in #8404.

What steps can reproduce the bug?

  1. Have any untracked files in your working tree (datasets, figures, build artifacts)
  2. Run a PR-style review against a base branch
  3. The review comments on untracked files that are not in the branch diff

What is the expected behavior?

Reviews should only cover git diff <merge-base>...HEAD, i.e. changes introduced by the branch, not the working tree.

Additional information

No response

extent analysis

TL;DR

The issue can be fixed by changing the git diff command in codex-rs/core/src/review_prompts.rs to compare the merge base to the branch HEAD instead of the working tree.

Guidance

  • The root cause of the issue is the incorrect git diff command used in the code, which compares the merge base to the working tree instead of the branch HEAD.
  • To verify the fix, run a PR-style review against a base branch with untracked files in the working tree and check if the review comments only include changes introduced by the branch.
  • The fix involves changing the git diff {mergeBaseSha} command to git diff {mergeBaseSha}...HEAD in the review_prompts.rs file.
  • The issue has been previously reported and the fix was identified, but the issue was closed without being addressed.

Example

// Before
let diff = git_diff(&format!("{}..", merge_base_sha));

// After
let diff = git_diff(&format!("{}...HEAD", merge_base_sha));

Notes

The provided information suggests that the issue is a one-line bug in the diff command, and the fix is straightforward. However, without access to the codebase, it's uncertain if there are any other dependencies or complexities that need to be considered.

Recommendation

Apply workaround: since the issue is a known bug with a identified fix, applying the workaround by changing the git diff command is the recommended course of action. This will allow users to use the PR-style review feature without commenting on untracked files.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING