mirror of
https://github.com/openai/codex.git
synced 2026-11-18 15:01:48 +00:00
Add a feature flag to preserve apply_patch line endings (#37758)
## What changed - Add the `apply_patch_preserve_line_endings` feature, disabled by default, to preserve CRLF, CR, and mixed line endings when `apply_patch` updates files. - Apply the feature consistently to built-in patch handling and patches invoked through shell, user-shell, unified-exec, and app-server command execution. - Keep the active feature configuration authoritative over inherited, shell snapshot, and client-provided environment values. ## Testing - Cover line-ending behavior with the feature enabled and disabled for custom tool calls, shell heredocs, command execution, and the `apply_patch` CLI. GitOrigin-RevId: 531a7c66761959c650270559f57941929f03e6c4
This commit is contained in:
1 parent
21aa552e87
commit
c9c6c0daa9
18 files changed
+462
-99
No files matched your search
@@ -10,6 +10,7 @@ use crate::sandboxing::SandboxPermissions;
|
||||
use crate::shell::Shell;
|
||||
use crate::shell::ShellType;
|
||||
use crate::tools::sandboxing::ToolError;
|
||||
use codex_apply_patch::CODEX_APPLY_PATCH_PRESERVE_LINE_ENDINGS_ENV_VAR;
|
||||
#[cfg(unix)]
|
||||
use codex_install_context::InstallContext;
|
||||
#[cfg(target_os = "macos")]
|
||||
@@ -267,14 +268,23 @@ pub(crate) fn maybe_wrap_shell_lc_with_snapshot(
|
||||
.map(|arg| format!(" '{}'", shell_single_quote(arg)))
|
||||
.collect::<String>();
|
||||
let mut override_env = explicit_env_overrides.clone();
|
||||
for key in [CODEX_THREAD_ID_ENV_VAR, CODEX_PERMISSION_PROFILE_ENV_VAR] {
|
||||
for key in [
|
||||
CODEX_THREAD_ID_ENV_VAR,
|
||||
CODEX_PERMISSION_PROFILE_ENV_VAR,
|
||||
CODEX_APPLY_PATCH_PRESERVE_LINE_ENDINGS_ENV_VAR,
|
||||
] {
|
||||
if let Some(value) = env.get(key) {
|
||||
override_env.insert(key.to_string(), value.clone());
|
||||
}
|
||||
}
|
||||
// Do not let a snapshot resurrect a stale profile when no named profile is active.
|
||||
let (override_captures, override_exports) =
|
||||
build_override_exports(&override_env, &[CODEX_PERMISSION_PROFILE_ENV_VAR]);
|
||||
// Do not let a snapshot resurrect stale runtime state when it is inactive.
|
||||
let (override_captures, override_exports) = build_override_exports(
|
||||
&override_env,
|
||||
&[
|
||||
CODEX_PERMISSION_PROFILE_ENV_VAR,
|
||||
CODEX_APPLY_PATCH_PRESERVE_LINE_ENDINGS_ENV_VAR,
|
||||
],
|
||||
);
|
||||
let (proxy_captures, proxy_exports) = build_proxy_env_exports();
|
||||
let runtime_path_prepend_exports =
|
||||
runtime_path_prepends.shell_exports_after_snapshot(explicit_env_overrides);
|
||||
|
||||
Reference in new issue
Block a user