Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix(switch): atomic no-overwrite backup for `--clobber` (#2849)
Maximilian Roos0aff8a824870
diff --git a/Cargo.lock b/Cargo.lockindex fd0eeeb52..0d90a12e1 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1919,6 +1919,16 @@ version = "1.9.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2"+[[package]]+name = "renamore"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0f5bced8a18df26d088a61a8f314d853ad18705b0aee59b43ccc088ca4bc3670"+dependencies = [+ "cc",+ "tempfile",+]+[[package]]name = "rstest"version = "0.26.1"@@ -3211,6 +3221,7 @@ dependencies = ["rayon","reflink-copy","regex",+ "renamore","rstest","sanitize-filename","schemars",diff --git a/Cargo.toml b/Cargo.tomlindex 6108d8e3c..b858594a5 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -127,6 +127,10 @@ urlencoding = "2.1"regex = "1.12"ignore = "0.4"reflink-copy = "0.1"+# Atomic, no-overwrite rename (renameat2 / renamex_np / MoveFileExW) for+# `--clobber` backups — closes the check-then-rename TOCTOU. Keeps the FFI+# (and its `unsafe`) out of this crate, which is `unsafe_code = "forbid"`.+renamore = "0.3"dashmap = "6.2.1"fs2 = "0.4.3"sanitize-filename = "0.6.0"diff --git a/src/commands/worktree/resolve.rs b/src/commands/worktree/resolve.rsindex 1b4ca127a..95aa7f9d9 100644--- a/src/commands/worktree/resolve.rs+++ b/src/commands/worktree/resolve.rs@@ -233,42 +233,40 @@ pub(super) fn generate_backup_path(}}-/// Compute the backup path for clobber operations.+/// Move a stale path aside so `wt switch --clobber` can take its place.///-/// Returns `Ok(None)` if path doesn't exist.-/// Returns `Ok(Some(backup_path))` if clobber is true and path exists.-/// Returns `Err(GitError::WorktreePathExists)` if clobber is false and path exists.-pub(super) fn compute_clobber_backup(- path: &Path,- branch: &str,- clobber: bool,- create: bool,-) -> anyhow::Result<Option<PathBuf>> {- if !path.exists() {- return Ok(None);- }-- if clobber {- let timestamp = worktrunk::utils::epoch_now() as i64;- let datetime =- chrono::DateTime::from_timestamp(timestamp, 0).unwrap_or_else(chrono::Utc::now);- let suffix = datetime.format("%Y%m%d-%H%M%S").to_string();- let backup_path = generate_backup_path(path, &suffix)?;-- if backup_path.exists() {- anyhow::bail!(- "Backup path already exists: {}",- worktrunk::path::format_path_for_display(&backup_path)- );- }- Ok(Some(backup_path))- } else {- Err(GitError::WorktreePathExists {- branch: branch.to_string(),- path: path.to_path_buf(),- create,+/// Renames `worktree_path` to a `.bak.<base_suffix>` sibling. If that name is+/// already taken — a same-second clobber, or a path that raced in after+/// planning — it counts up (`…-2`, `…-3`, …) until it finds a free name.+/// Every attempt is an atomic no-overwrite rename ([`renamore::rename_exclusive`]),+/// so an existing backup is never overwritten; the move just lands on the next+/// free name. Returns the path the stale directory was moved to.+pub(super) fn back_up_clobbered_path(+ worktree_path: &Path,+ base_suffix: &str,+) -> anyhow::Result<PathBuf> {+ // Count up until a free name is found. This cannot spin forever: a+ // directory holds finitely many entries, so some `-N` is always unused.+ let mut n: u64 = 1;+ loop {+ // First attempt uses the bare suffix; later ones disambiguate with -N.+ let suffix = if n == 1 {+ base_suffix.to_string()+ } else {+ format!("{base_suffix}-{n}")+ };+ let candidate = generate_backup_path(worktree_path, &suffix)?;+ match renamore::rename_exclusive(worktree_path, &candidate) {+ Ok(()) => return Ok(candidate),+ Err(err) if err.kind() == std::io::ErrorKind::AlreadyExists => n += 1,+ Err(err) => {+ return Err(anyhow::Error::new(err).context(format!(+ "Failed to move {} to {}",+ format_path_for_display(worktree_path),+ format_path_for_display(&candidate),+ )));+ }}- .into())}}@@ -466,6 +464,75 @@ mod tests {assert!(generate_backup_path(&path, "20250101-000000").is_err());}+ #[test]+ fn test_back_up_clobbered_path_moves_to_fresh_suffix() {+ let temp = tempfile::tempdir().unwrap();+ let stale = temp.path().join("feature");+ std::fs::create_dir(&stale).unwrap();+ std::fs::write(stale.join("file"), "content").unwrap();++ let used = back_up_clobbered_path(&stale, "20250101-000000").unwrap();++ assert_eq!(used, temp.path().join("feature.bak.20250101-000000"));+ assert!(!stale.exists(), "stale path should be moved away");+ assert_eq!(+ std::fs::read_to_string(used.join("file")).unwrap(),+ "content"+ );+ }++ #[test]+ fn test_back_up_clobbered_path_falls_back_when_suffix_taken() {+ let temp = tempfile::tempdir().unwrap();+ let stale = temp.path().join("feature");+ std::fs::create_dir(&stale).unwrap();++ // The preferred backup name and its first -N variant are both taken.+ let taken = temp.path().join("feature.bak.20250101-000000");+ std::fs::create_dir(&taken).unwrap();+ std::fs::write(taken.join("keep"), "pre-existing").unwrap();+ std::fs::create_dir(temp.path().join("feature.bak.20250101-000000-2")).unwrap();++ let used = back_up_clobbered_path(&stale, "20250101-000000").unwrap();++ // Lands on -3; neither pre-existing backup is overwritten.+ assert_eq!(used, temp.path().join("feature.bak.20250101-000000-3"));+ assert!(!stale.exists());+ assert_eq!(+ std::fs::read_to_string(taken.join("keep")).unwrap(),+ "pre-existing"+ );+ }++ #[test]+ fn test_back_up_clobbered_path_errors_when_source_missing() {+ // A missing source fails the rename with a non-AlreadyExists error,+ // which surfaces rather than being retried.+ let temp = tempfile::tempdir().unwrap();+ let missing = temp.path().join("does-not-exist");+ assert!(back_up_clobbered_path(&missing, "20250101-000000").is_err());+ }++ #[test]+ fn test_back_up_clobbered_path_keeps_incrementing_past_many_collisions() {+ // There is no attempt cap: the move keeps counting up until a free+ // name is found, however many backups already exist.+ let temp = tempfile::tempdir().unwrap();+ let stale = temp.path().join("feature");+ std::fs::create_dir(&stale).unwrap();++ // Occupy the preferred name and the first 49 -N fallbacks (suffix "S").+ std::fs::create_dir(temp.path().join("feature.bak.S")).unwrap();+ for n in 2..=50 {+ std::fs::create_dir(temp.path().join(format!("feature.bak.S-{n}"))).unwrap();+ }++ let used = back_up_clobbered_path(&stale, "S").unwrap();++ assert_eq!(used, temp.path().join("feature.bak.S-51"));+ assert!(!stale.exists(), "stale path should be moved away");+ }+#[test]fn test_template_references_repo_name_default() {// Default template uses {{ repo }}diff --git a/src/commands/worktree/switch.rs b/src/commands/worktree/switch.rsindex 49ae2b965..0586f3f06 100644--- a/src/commands/worktree/switch.rs+++ b/src/commands/worktree/switch.rs@@ -31,7 +31,7 @@ use worktrunk::styling::{};use super::resolve::{- compute_clobber_backup, compute_worktree_path, offer_bare_repo_worktree_path_fix, path_mismatch,+ back_up_clobbered_path, compute_worktree_path, offer_bare_repo_worktree_path_fix, path_mismatch,};use super::types::{CreationMethod, SwitchBranchInfo, SwitchPlan, SwitchResult};use crate::cli::SwitchFormat;@@ -652,7 +652,7 @@ fn validate_worktree_creation(path: &Path,clobber: bool,method: &CreationMethod,-) -> anyhow::Result<Option<std::path::PathBuf>> {+) -> anyhow::Result<bool> {// For regular switches without --create, validate branch existsif let CreationMethod::Regular {create_branch: false,@@ -686,7 +686,17 @@ fn validate_worktree_creation(.into());}- // Handle clobber for stale directories+ // Handle clobber for stale directories. Returns whether `execute_switch`+ // must back up a path occupying `worktree_path` before creating the+ // worktree; the backup itself happens at execution time so a path that+ // races in after planning is still moved atomically (see+ // `back_up_clobbered_path`).+ if !path.exists() {+ return Ok(false);+ }+ if clobber {+ return Ok(true);+ }let is_create = matches!(method,CreationMethod::Regular {@@ -694,7 +704,12 @@ fn validate_worktree_creation(..});- compute_clobber_backup(path, branch, clobber, is_create)+ Err(GitError::WorktreePathExists {+ branch: branch.to_string(),+ path: path.to_path_buf(),+ create: is_create,+ }+ .into())}/// Set up a local branch for a fork PR or MR.@@ -831,7 +846,7 @@ pub fn plan_switch(let expected_path = compute_worktree_path(repo, &target.branch, config)?;// Phase 4: Validate we can create at this path- let clobber_backup = validate_worktree_creation(+ let needs_clobber_backup = validate_worktree_creation(repo,&target.branch,&expected_path,@@ -844,7 +859,7 @@ pub fn plan_switch(branch: target.branch,worktree_path: expected_path,method: target.method,- clobber_backup,+ needs_clobber_backup,new_previous,})}@@ -906,23 +921,32 @@ pub fn execute_switch(branch,worktree_path,method,- clobber_backup,+ needs_clobber_backup,new_previous,} => {// Handle --clobber backup if needed (shared for all creation methods)- if let Some(backup_path) = &clobber_backup {+ if needs_clobber_backup {+ // Timestamped backup name, computed here at move time so the+ // suffix reflects when the path is actually set aside.+ let timestamp = worktrunk::utils::epoch_now() as i64;+ let datetime =+ chrono::DateTime::from_timestamp(timestamp, 0).unwrap_or_else(chrono::Utc::now);+ let base_suffix = datetime.format("%Y%m%d-%H%M%S").to_string();++ // Atomically move the stale path aside. A backup name that is+ // already taken (a same-second clobber, or one that raced in+ // after planning) is never overwritten — the move falls back+ // to the next free `-N` name.+ let backup_path = back_up_clobbered_path(&worktree_path, &base_suffix)?;+let path_display = worktrunk::path::format_path_for_display(&worktree_path);- let backup_display = worktrunk::path::format_path_for_display(backup_path);+ let backup_display = worktrunk::path::format_path_for_display(&backup_path);eprintln!("{}",warning_message(cformat!(- "Moving <bold>{path_display}</> to <bold>{backup_display}</> (--clobber)"+ "Moved <bold>{path_display}</> to <bold>{backup_display}</> (--clobber)")));-- std::fs::rename(&worktree_path, backup_path).with_context(|| {- format!("Failed to move {path_display} to {backup_display}")- })?;}// Execute based on creation methoddiff --git a/src/commands/worktree/types.rs b/src/commands/worktree/types.rsindex fac5558bb..ef0cf75e1 100644--- a/src/commands/worktree/types.rs+++ b/src/commands/worktree/types.rs@@ -122,8 +122,9 @@ pub enum SwitchPlan {worktree_path: PathBuf,/// How to create the worktreemethod: CreationMethod,- /// If path exists and --clobber, this is the backup path to move it to- clobber_backup: Option<PathBuf>,+ /// True when a stale path occupies `worktree_path` and `--clobber` was+ /// given — `execute_switch` backs it up before creating the worktree.+ needs_clobber_backup: bool,/// Branch to record as "previous" for `wt switch -`new_previous: Option<String>,},diff --git a/tests/integration_tests/switch.rs b/tests/integration_tests/switch.rsindex 86b0e60a2..b76662581 100644--- a/tests/integration_tests/switch.rs+++ b/tests/integration_tests/switch.rs@@ -1864,37 +1864,56 @@ fn test_switch_clobber_backs_up_stale_file(repo: TestRepo) {);}-#[rstest]-fn test_switch_clobber_error_backup_exists(repo: TestRepo) {- // Calculate where the worktree would be created+/// When the computed backup path is already taken, `wt switch --clobber` does+/// not fail — it moves the stale path to the next free `-N` variant via an+/// atomic no-overwrite rename, leaving the pre-existing backup untouched. This+/// is the time-of-check/time-of-use safe path: a colliding backup name (a+/// same-second clobber, or one that raced in after planning) is never+/// overwritten the way `std::fs::rename` would.+#[rstest]+fn test_switch_clobber_falls_back_when_backup_taken(repo: TestRepo) {let repo_name = repo.root_path().file_name().unwrap().to_str().unwrap();- let expected_path = repo- .root_path()- .parent()- .unwrap()- .join(format!("{}.clobber-backup-exists", repo_name));+ let parent = repo.root_path().parent().unwrap();+ let expected_path = parent.join(format!("{}.clobber-backup-taken", repo_name));- // Create a stale directory at the target path+ // Stale directory at the target path, with content that must survive.std::fs::create_dir_all(&expected_path).unwrap();+ std::fs::write(expected_path.join("stale.txt"), "stale content").unwrap();- // Also create the backup path that would be generated- // TEST_EPOCH=1735776000 -> 2025-01-02 00:00:00 UTC- let backup_path = repo.root_path().parent().unwrap().join(format!(- "{}.clobber-backup-exists.bak.20250102-000000",+ // Pre-create the backup path the timestamp would produce, so the move has+ // to fall back. TEST_EPOCH=1735776000 -> 2025-01-02 00:00:00 UTC+ let taken = parent.join(format!(+ "{}.clobber-backup-taken.bak.20250102-000000",repo_name));- std::fs::create_dir_all(&backup_path).unwrap();+ std::fs::create_dir_all(&taken).unwrap();+ std::fs::write(taken.join("pre-existing.txt"), "do not touch").unwrap();- // With --clobber, should error because backup path existssnapshot_switch(- "switch_clobber_error_backup_exists",+ "switch_clobber_falls_back_when_backup_taken",&repo,- &["--create", "--clobber", "clobber-backup-exists"],+ &["--create", "--clobber", "clobber-backup-taken"],);- // Both paths should still exist (nothing was moved)- assert!(expected_path.exists());- assert!(backup_path.exists());+ // The worktree was created.+ assert!(expected_path.is_dir());++ // The pre-existing backup is untouched.+ assert_eq!(+ std::fs::read_to_string(taken.join("pre-existing.txt")).unwrap(),+ "do not touch"+ );++ // The stale content was moved to the -2 fallback name.+ let fallback = parent.join(format!(+ "{}.clobber-backup-taken.bak.20250102-000000-2",+ repo_name+ ));+ assert!(fallback.is_dir());+ assert_eq!(+ std::fs::read_to_string(fallback.join("stale.txt")).unwrap(),+ "stale content"+ );}///diff --git a/tests/snapshots/integration__integration_tests__switch__switch_clobber_error_backup_exists.snap b/tests/snapshots/integration__integration_tests__switch__switch_clobber_falls_back_when_backup_taken.snapsimilarity index 55%rename from tests/snapshots/integration__integration_tests__switch__switch_clobber_error_backup_exists.snaprename to tests/snapshots/integration__integration_tests__switch__switch_clobber_falls_back_when_backup_taken.snapindex a1e517a59..f207025d0 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_clobber_error_backup_exists.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_clobber_falls_back_when_backup_taken.snap@@ -6,20 +6,26 @@ info:- switch- "--create"- "--clobber"- - clobber-backup-exists+ - clobber-backup-takenenv:APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"COLUMNS: "500"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"+ GIT_COMMON_DIR: ""GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"GIT_CONFIG_SYSTEM: /dev/null+ GIT_DIR: ""GIT_EDITOR: ""+ GIT_INDEX_FILE: ""+ GIT_OBJECT_DIRECTORY: ""GIT_TERMINAL_PROMPT: "0"+ GIT_WORK_TREE: ""HOME: "[TEST_HOME]"LANG: CLC_ALL: C+ LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"NO_COLOR: ""OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"@@ -32,18 +38,28 @@ info:WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"+ WORKTRUNK_TEST_BASH_INSTALLED: "0"WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"+ WORKTRUNK_TEST_CODEX_INSTALLED: "0"WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"WORKTRUNK_TEST_EPOCH: "1735776000"+ WORKTRUNK_TEST_FISH_INSTALLED: "0"+ WORKTRUNK_TEST_GEMINI_INSTALLED: "0"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"WORKTRUNK_TEST_POWERSHELL_ENV: "0"+ WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"+ WORKTRUNK_TEST_ZSH_INSTALLED: "0"XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"----success: false-exit_code: 1+success: true+exit_code: 0----- stdout ---------- stderr ------[31m✗[39m [31mBackup path already exists: _REPO_.clobber-backup-exists.bak.20250102-000000[39m+[33m▲[39m [33mMoved [1m_REPO_.clobber-backup-taken[22m to [1m_REPO_.clobber-backup-taken.bak.20250102-000000-2[22m (--clobber)[39m+[32m✓[39m [32mCreated branch [1mclobber-backup-taken[22m from [1mmain[22m and worktree @ [1m_REPO_.clobber-backup-taken[22m[39m+[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m+[33m▲[39m [33mCannot change directory — shell integration not installed[39m+[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_clobber_path_with_extension.snap b/tests/snapshots/integration__integration_tests__switch__switch_clobber_path_with_extension.snapindex a590574bb..10bdfadbb 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_clobber_path_with_extension.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_clobber_path_with_extension.snap@@ -13,13 +13,19 @@ info:COLUMNS: "500"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"+ GIT_COMMON_DIR: ""GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"GIT_CONFIG_SYSTEM: /dev/null+ GIT_DIR: ""GIT_EDITOR: ""+ GIT_INDEX_FILE: ""+ GIT_OBJECT_DIRECTORY: ""GIT_TERMINAL_PROMPT: "0"+ GIT_WORK_TREE: ""HOME: "[TEST_HOME]"LANG: CLC_ALL: C+ LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"NO_COLOR: ""OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"@@ -32,13 +38,19 @@ info:WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"+ WORKTRUNK_TEST_BASH_INSTALLED: "0"WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"+ WORKTRUNK_TEST_CODEX_INSTALLED: "0"WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"WORKTRUNK_TEST_EPOCH: "1735776000"+ WORKTRUNK_TEST_FISH_INSTALLED: "0"+ WORKTRUNK_TEST_GEMINI_INSTALLED: "0"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"WORKTRUNK_TEST_POWERSHELL_ENV: "0"+ WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"+ WORKTRUNK_TEST_ZSH_INSTALLED: "0"XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"---success: true@@ -46,7 +58,7 @@ exit_code: 0----- stdout ---------- stderr ------[33m▲[39m [33mMoving [1m_REPO_.clobber-ext.txt[22m to [1m_REPO_.clobber-ext.txt.bak.20250102-000000[22m (--clobber)[39m+[33m▲[39m [33mMoved [1m_REPO_.clobber-ext.txt[22m to [1m_REPO_.clobber-ext.txt.bak.20250102-000000[22m (--clobber)[39m[32m✓[39m [32mCreated branch [1mclobber-ext.txt[22m from [1mmain[22m and worktree @ [1m_REPO_.clobber-ext.txt[22m[39m[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39mdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_clobber_removes_stale_dir.snap b/tests/snapshots/integration__integration_tests__switch__switch_clobber_removes_stale_dir.snapindex b4fb9bd09..8c722e298 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_clobber_removes_stale_dir.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_clobber_removes_stale_dir.snap@@ -13,13 +13,19 @@ info:COLUMNS: "500"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"+ GIT_COMMON_DIR: ""GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"GIT_CONFIG_SYSTEM: /dev/null+ GIT_DIR: ""GIT_EDITOR: ""+ GIT_INDEX_FILE: ""+ GIT_OBJECT_DIRECTORY: ""GIT_TERMINAL_PROMPT: "0"+ GIT_WORK_TREE: ""HOME: "[TEST_HOME]"LANG: CLC_ALL: C+ LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"NO_COLOR: ""OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"@@ -32,13 +38,19 @@ info:WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"+ WORKTRUNK_TEST_BASH_INSTALLED: "0"WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"+ WORKTRUNK_TEST_CODEX_INSTALLED: "0"WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"WORKTRUNK_TEST_EPOCH: "1735776000"+ WORKTRUNK_TEST_FISH_INSTALLED: "0"+ WORKTRUNK_TEST_GEMINI_INSTALLED: "0"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"WORKTRUNK_TEST_POWERSHELL_ENV: "0"+ WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"+ WORKTRUNK_TEST_ZSH_INSTALLED: "0"XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"---success: true@@ -46,7 +58,7 @@ exit_code: 0----- stdout ---------- stderr ------[33m▲[39m [33mMoving [1m_REPO_.clobber-dir-test[22m to [1m_REPO_.clobber-dir-test.bak.20250102-000000[22m (--clobber)[39m+[33m▲[39m [33mMoved [1m_REPO_.clobber-dir-test[22m to [1m_REPO_.clobber-dir-test.bak.20250102-000000[22m (--clobber)[39m[32m✓[39m [32mCreated branch [1mclobber-dir-test[22m from [1mmain[22m and worktree @ [1m_REPO_.clobber-dir-test[22m[39m[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39mdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_clobber_removes_stale_file.snap b/tests/snapshots/integration__integration_tests__switch__switch_clobber_removes_stale_file.snapindex b02f40b48..27707ff09 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_clobber_removes_stale_file.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_clobber_removes_stale_file.snap@@ -13,13 +13,19 @@ info:COLUMNS: "500"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"+ GIT_COMMON_DIR: ""GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"GIT_CONFIG_SYSTEM: /dev/null+ GIT_DIR: ""GIT_EDITOR: ""+ GIT_INDEX_FILE: ""+ GIT_OBJECT_DIRECTORY: ""GIT_TERMINAL_PROMPT: "0"+ GIT_WORK_TREE: ""HOME: "[TEST_HOME]"LANG: CLC_ALL: C+ LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"NO_COLOR: ""OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"@@ -32,13 +38,19 @@ info:WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"+ WORKTRUNK_TEST_BASH_INSTALLED: "0"WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"+ WORKTRUNK_TEST_CODEX_INSTALLED: "0"WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"WORKTRUNK_TEST_EPOCH: "1735776000"+ WORKTRUNK_TEST_FISH_INSTALLED: "0"+ WORKTRUNK_TEST_GEMINI_INSTALLED: "0"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"WORKTRUNK_TEST_POWERSHELL_ENV: "0"+ WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"+ WORKTRUNK_TEST_ZSH_INSTALLED: "0"XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"---success: true@@ -46,7 +58,7 @@ exit_code: 0----- stdout ---------- stderr ------[33m▲[39m [33mMoving [1m_REPO_.clobber-file-test[22m to [1m_REPO_.clobber-file-test.bak.20250102-000000[22m (--clobber)[39m+[33m▲[39m [33mMoved [1m_REPO_.clobber-file-test[22m to [1m_REPO_.clobber-file-test.bak.20250102-000000[22m (--clobber)[39m[32m✓[39m [32mCreated branch [1mclobber-file-test[22m from [1mmain[22m and worktree @ [1m_REPO_.clobber-file-test[22m[39m[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m