mirror of
https://github.com/openai/codex.git
synced 2026-11-07 20:30:33 +00:00
Reject duplicate resolved paths in apply_patch (#37867)
## What changed - Reject patches containing multiple operations whose paths resolve to the same file, such as `duplicate.txt` and `./duplicate.txt`. - Preserve support for patches that update multiple distinct files. ## Testing - Add CLI integration coverage for distinct updates and duplicate resolved paths. GitOrigin-RevId: 0fb7f69ae31acc5c677268ffd9e38ad8d8314276
This commit is contained in:
@@ -232,6 +232,13 @@ async fn try_verify_apply_patch_args(
|
||||
let mut changes = HashMap::new();
|
||||
for hunk in hunks {
|
||||
let path = hunk.resolve_path(&effective_cwd)?;
|
||||
if changes.contains_key(&path) {
|
||||
return Err(ParseError::InvalidPatchError(format!(
|
||||
"multiple operations target {}",
|
||||
path.inferred_native_path_string()
|
||||
))
|
||||
.into());
|
||||
}
|
||||
match hunk {
|
||||
Hunk::AddFile { contents, .. } => {
|
||||
changes.insert(path, ApplyPatchFileChange::Add { content: contents });
|
||||
|
||||
Reference in New Issue
Block a user