-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Fix: Remove --3way flag to prevent automatic staging #8549
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?
Fix: Remove --3way flag to prevent automatic staging #8549
Conversation
Fixes issue openai#8405 where Codex was automatically staging files after applying patches. The --3way flag causes git apply to stage files when patches apply cleanly, which was not the intended behavior. - Remove --3way flag from git apply command - Add test to verify files are not staged after applying patches
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
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.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // Build git args | ||
| let mut args: Vec<String> = vec!["apply".into(), "--3way".into()]; | ||
| let mut args: Vec<String> = vec!["apply".into()]; | ||
| if req.revert { |
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.
Removing --3way breaks fallback application
Dropping --3way from the git apply invocation removes the three-way merge fallback, so any patch that no longer applies cleanly to the working tree now fails outright instead of merging or emitting conflict markers. git apply -h documents that --3way attempts a three-way merge before falling back to a normal patch; without it, ApplyGitResult will return non-zero for patches that previously succeeded (or produced conflicts) when the local tree had drifted, reducing the tool’s ability to apply user patches in common workflows with local edits or slightly outdated diffs.
Useful? React with 👍 / 👎.
|
recheck |
What?
Removes the
--3wayflag fromgit applyto prevent Codex from automatically staging files after applying patches.Why?
Fixes #8405. Codex was automatically staging files after applying patches due to the
--3wayflag. According toman git-apply, when--3wayis used and a patch applies cleanly, Git automatically stages the edited file. This was not the intended behavior and made it difficult for users to distinguish which files were actually modified when iterating over changes.How?
--3wayflag from thegit applycommand incodex-rs/utils/git/src/apply.rsapply_does_not_stage_files()to verify files are not staged after applying patchesAll existing tests pass, and the new test confirms the fix works as expected.