Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Improve `wt switch -` history behavior

Maximilian Roos11a9b841a16b
diff --git a/src/commands/list/collect.rs b/src/commands/list/collect.rs
index b4855abcb..f09d5960b 100644
--- a/src/commands/list/collect.rs
+++ b/src/commands/list/collect.rs
@@ -397,7 +397,7 @@ pub fn collect(
.cloned()
.unwrap_or_else(|| worktrees.main().clone());
let current_worktree_path = repo.worktree_root().ok();
- let previous_branch = repo.get_switch_history().and_then(|h| h.previous);
+ let previous_branch = repo.get_switch_previous();
// Sort worktrees: current first, main second, then by timestamp descending
let sorted_worktrees = sort_worktrees(
diff --git a/src/commands/worktree.rs b/src/commands/worktree.rs
index 2ddf5eede..b5f6f436c 100644
--- a/src/commands/worktree.rs
+++ b/src/commands/worktree.rs
@@ -294,30 +294,15 @@ pub fn handle_switch(
) -> anyhow::Result<(SwitchResult, String)> {
let repo = Repository::current();
- // Get current history (current, previous) before resolving
- let history_before = repo.get_switch_history();
+ // Get the actual current branch BEFORE switching.
+ // This is what we'll record as "previous" in history for `wt switch -` support.
+ let actual_current_branch = repo.current_branch().ok().flatten();
// Resolve special branch names ("@" for current, "-" for previous)
let resolved_branch = repo.resolve_worktree_name(branch)?;
- // Calculate what to record in history after the switch
- // History stores (current_location, previous_location) for ping-pong behavior
- let (new_current, new_previous) = if branch == "-" {
- // Switching back: swap current and previous
- // history_before contains (A, B), we're switching from A to B
- // After switch, record (B, A) so we can switch back to A
- if let Some(history) = history_before {
- (resolved_branch.clone(), Some(history.current))
- } else {
- // No history - shouldn't happen since "-" requires history
- // But handle gracefully: just record where we're going
- (resolved_branch.clone(), None)
- }
- } else {
- // Normal switch: record new location as current, old current as previous
- let previous = history_before.map(|h| h.current);
- (resolved_branch.clone(), previous)
- };
+ // Record actual current branch as new "previous" for ping-pong behavior
+ let new_previous = actual_current_branch;
// Resolve base if provided
let resolved_base = if let Some(base_str) = base {
@@ -378,7 +363,7 @@ pub fn handle_switch(
// Path-first lookup: check if a worktree exists at the expected path
if let Some((existing_path, path_branch)) = repo.worktree_at_path(&expected_path)? {
// Worktree exists at expected path - switch to it regardless of its branch
- let _ = repo.record_switch_history(&new_current, new_previous.as_deref());
+ let _ = repo.record_switch_previous(new_previous.as_deref());
let actual_branch = path_branch.unwrap_or_else(|| resolved_branch.clone());
return Ok(switch_to_existing(existing_path, actual_branch));
}
@@ -386,7 +371,7 @@ pub fn handle_switch(
// Fallback: check if branch has a worktree at a different path
match repo.worktree_for_branch(&resolved_branch)? {
Some(existing_path) if existing_path.exists() => {
- let _ = repo.record_switch_history(&new_current, new_previous.as_deref());
+ let _ = repo.record_switch_previous(new_previous.as_deref());
return Ok(switch_to_existing(existing_path, resolved_branch));
}
Some(_) => {
@@ -518,7 +503,7 @@ pub fn handle_switch(
// (see main.rs switch handler for temporal locality)
// Record successful switch in history for `wt switch -` support
- let _ = repo.record_switch_history(&new_current, new_previous.as_deref());
+ let _ = repo.record_switch_previous(new_previous.as_deref());
Ok((
SwitchResult::Created {
diff --git a/src/git/mod.rs b/src/git/mod.rs
index 85e82a13e..c8743e61b 100644
--- a/src/git/mod.rs
+++ b/src/git/mod.rs
@@ -80,15 +80,6 @@ pub enum HookType {
PostMerge,
}
-/// Switch history for ping-pong behavior between branches
-#[derive(Debug, Clone, PartialEq)]
-pub struct SwitchHistory {
- /// The branch we switched to
- pub current: String,
- /// The branch we came from (for "-" to switch back)
- pub previous: Option<String>,
-}
-
/// Worktree information
#[derive(Debug, Clone, PartialEq, serde::Serialize)]
pub struct Worktree {
diff --git a/src/git/repository/mod.rs b/src/git/repository/mod.rs
index 41489b841..22e94aa88 100644
--- a/src/git/repository/mod.rs
+++ b/src/git/repository/mod.rs
@@ -6,8 +6,8 @@ use anyhow::{Context, bail};
// Import types and functions from parent module (mod.rs)
use super::{
- BranchCategory, CompletionBranch, DefaultBranchName, DiffStats, GitError, LineDiff,
- SwitchHistory, Worktree, WorktreeList,
+ BranchCategory, CompletionBranch, DefaultBranchName, DiffStats, GitError, LineDiff, Worktree,
+ WorktreeList,
};
/// Result of resolving a worktree name.
@@ -285,43 +285,25 @@ impl Repository {
branch.and_then(|branch| self.branch_keyed_status(branch))
}
- /// Record branch history in worktrunk.history for `wt switch -` support.
+ /// Record the previous branch in worktrunk.history for `wt switch -` support.
///
- /// Stores "current,previous" to enable ping-pong switching.
- /// This enables `wt switch -` to work after `wt switch` operations,
- /// which don't create git reflog entries.
- pub fn record_switch_history(
- &self,
- current: &str,
- previous: Option<&str>,
- ) -> anyhow::Result<()> {
- let value = if let Some(prev) = previous {
- format!("{},{}", current, prev)
- } else {
- current.to_string()
- };
- self.run_command(&["config", "worktrunk.history", &value])?;
+ /// Stores the branch we're switching FROM, so `wt switch -` can return to it.
+ pub fn record_switch_previous(&self, previous: Option<&str>) -> anyhow::Result<()> {
+ if let Some(prev) = previous {
+ self.run_command(&["config", "worktrunk.history", prev])?;
+ }
+ // If previous is None (detached HEAD), don't update history
Ok(())
}
- /// Get the previous branch from worktrunk.history.
+ /// Get the previous branch from worktrunk.history for `wt switch -`.
///
- /// Returns history if recorded, where `current` is the branch we switched to
- /// and `previous` is where we came from (for ping-pong "-" behavior).
- pub fn get_switch_history(&self) -> Option<SwitchHistory> {
+ /// Returns the branch we came from, enabling ping-pong switching.
+ pub fn get_switch_previous(&self) -> Option<String> {
self.run_command(&["config", "--get", "worktrunk.history"])
.ok()
- .and_then(|output| {
- let trimmed = output.trim();
- if trimmed.is_empty() {
- return None;
- }
- let parts: Vec<&str> = trimmed.splitn(2, ',').collect();
- Some(SwitchHistory {
- current: parts[0].to_string(),
- previous: parts.get(1).map(|s| s.to_string()),
- })
- })
+ .map(|s| s.trim().to_string())
+ .filter(|s| !s.is_empty())
}
/// Resolve a worktree name, expanding "@" to current, "-" to previous, and "^" to main.
@@ -350,17 +332,14 @@ impl Repository {
}),
"-" => {
// Read from worktrunk.history (recorded by wt switch operations)
- // History stores (current, previous), we want previous
- self.get_switch_history()
- .and_then(|h| h.previous)
- .ok_or_else(|| {
- GitError::Other {
- message:
- "No previous branch found in history. Use 'wt list' to see available worktrees."
- .into(),
- }
- .into()
- })
+ self.get_switch_previous().ok_or_else(|| {
+ GitError::Other {
+ message:
+ "No previous branch found in history. Use 'wt list' to see available worktrees."
+ .into(),
+ }
+ .into()
+ })
}
"^" => self.default_branch(),
_ => Ok(name.to_string()),
diff --git a/tests/integration_tests/list.rs b/tests/integration_tests/list.rs
index 87042b75b..539001530 100644
--- a/tests/integration_tests/list.rs
+++ b/tests/integration_tests/list.rs
@@ -222,7 +222,9 @@ fn test_list_multiple_worktrees() {
snapshot_list("multiple_worktrees", &repo);
}
-/// Test that the `-` gutter symbol appears for the previous worktree (target of `wt switch -`)
+/// Test that the `-` gutter symbol appears for the previous worktree (target of `wt switch -`).
+///
+/// Simulates realistic usage by running switch commands from the correct worktree directories.
#[test]
fn test_list_previous_worktree_gutter() {
let mut repo = TestRepo::new();
@@ -230,20 +232,25 @@ fn test_list_previous_worktree_gutter() {
repo.add_worktree("feature");
- // Use wt switch to establish history: main -> feature -> main
- // After this, "feature" is the previous branch
+ let feature_path = repo.root_path().parent().unwrap().join(format!(
+ "{}.feature",
+ repo.root_path().file_name().unwrap().to_str().unwrap()
+ ));
+
+ // Step 1: From main, switch to feature (history: current=feature, previous=main)
let mut cmd = wt_command();
repo.clean_cli_env(&mut cmd);
cmd.args(["switch", "feature"])
.current_dir(repo.root_path());
cmd.output().unwrap();
+ // Step 2: From feature, switch back to main (history: current=main, previous=feature)
let mut cmd = wt_command();
repo.clean_cli_env(&mut cmd);
- cmd.args(["switch", "main"]).current_dir(repo.root_path());
+ cmd.args(["switch", "main"]).current_dir(&feature_path);
cmd.output().unwrap();
- // Now list should show `-` for feature (the previous worktree)
+ // Now list should show `-` for feature (the previous worktree, target of `wt switch -`)
snapshot_list("previous_worktree_gutter", &repo);
}
diff --git a/tests/integration_tests/switch.rs b/tests/integration_tests/switch.rs
index 570f48420..2ec326c5b 100644
--- a/tests/integration_tests/switch.rs
+++ b/tests/integration_tests/switch.rs
@@ -446,35 +446,6 @@ fn test_switch_primary_on_different_branch() {
);
}
-#[test]
-fn test_switch_previous_branch() {
- use std::process::Command;
-
- let repo = setup_switch_repo();
-
- // Create two branches
- let mut cmd = Command::new("git");
- repo.configure_git_cmd(&mut cmd);
- cmd.args(["branch", "feature-a"])
- .current_dir(repo.root_path())
- .output()
- .unwrap();
-
- let mut cmd = Command::new("git");
- repo.configure_git_cmd(&mut cmd);
- cmd.args(["branch", "feature-b"])
- .current_dir(repo.root_path())
- .output()
- .unwrap();
-
- // Use wt switch to establish worktrunk.history
- snapshot_switch("switch_previous_branch_first", &repo, &["feature-a"]);
- snapshot_switch("switch_previous_branch_second", &repo, &["feature-b"]);
-
- // Now wt switch - should resolve to feature-b (the previous wt switch)
- snapshot_switch("switch_previous_branch", &repo, &["-"]);
-}
-
#[test]
fn test_switch_previous_branch_no_history() {
let repo = setup_switch_repo();
@@ -483,49 +454,6 @@ fn test_switch_previous_branch_no_history() {
snapshot_switch("switch_previous_branch_no_history", &repo, &["-"]);
}
-#[test]
-fn test_switch_previous_branch_with_worktrunk_history() {
- use std::process::Command;
-
- let repo = setup_switch_repo();
-
- // Create two branches
- let mut cmd = Command::new("git");
- repo.configure_git_cmd(&mut cmd);
- cmd.args(["branch", "feature-x"])
- .current_dir(repo.root_path())
- .output()
- .unwrap();
-
- let mut cmd = Command::new("git");
- repo.configure_git_cmd(&mut cmd);
- cmd.args(["branch", "feature-y"])
- .current_dir(repo.root_path())
- .output()
- .unwrap();
-
- // Use wt switch to switch to feature-x (this records history)
- snapshot_switch(
- "switch_previous_branch_with_worktrunk_history_first",
- &repo,
- &["feature-x"],
- );
-
- // Switch to feature-y (this records feature-x in history)
- snapshot_switch(
- "switch_previous_branch_with_worktrunk_history_second",
- &repo,
- &["feature-y"],
- );
-
- // Now wt switch - should resolve to feature-x (from worktrunk.history)
- snapshot_switch(
- "switch_previous_branch_with_worktrunk_history_back",
- &repo,
- &["-"],
- );
-}
-
#[test]
fn test_switch_main_branch() {
use std::process::Command;
@@ -636,3 +564,123 @@ fn test_switch_error_path_occupied() {
// Cleanup
std::fs::remove_dir_all(&expected_path).ok();
}
+
+/// Test that `wt switch -` uses actual current branch for recording history.
+///
+/// Bug scenario: If user changes worktrees without using `wt switch` (e.g., cd directly),
+/// history becomes stale. The fix ensures we always use the actual current branch
+/// when recording new history, not any previously stored value.
+#[test]
+fn test_switch_previous_with_stale_history() {
+ use std::process::Command;
+
+ let repo = setup_switch_repo();
+
+ // Create branches with worktrees
+ for branch in ["branch-a", "branch-b", "branch-c"] {
+ let mut cmd = Command::new("git");
+ repo.configure_git_cmd(&mut cmd);
+ cmd.args(["branch", branch])
+ .current_dir(repo.root_path())
+ .output()
+ .unwrap();
+ }
+
+ // Switch to branch-a, then branch-b to establish history
+ snapshot_switch("switch_stale_history_to_a", &repo, &["branch-a"]);
+ snapshot_switch("switch_stale_history_to_b", &repo, &["branch-b"]);
+
+ // Now manually set history to simulate user changing worktrees without wt switch.
+ // History stores just the previous branch (branch-a from the earlier switches).
+ // If user manually cd'd to branch-c's worktree, history would still say branch-a.
+ let mut cmd = Command::new("git");
+ repo.configure_git_cmd(&mut cmd);
+ cmd.args(["config", "worktrunk.history", "branch-a"])
+ .current_dir(repo.root_path())
+ .output()
+ .unwrap();
+
+ // Run wt switch - from branch-b's worktree.
+ // Should go to branch-a (what history says), and record actual current branch as new previous.
+ snapshot_switch("switch_stale_history_first_dash", &repo, &["-"]);
+
+ // Run wt switch - again.
+ // Should go back to wherever we actually were (recorded as new previous in step above)
+ snapshot_switch("switch_stale_history_second_dash", &repo, &["-"]);
+}
+
+/// Helper to run switch from a specific working directory (simulating actual worktree location)
+fn snapshot_switch_from_dir(test_name: &str, repo: &TestRepo, args: &[&str], cwd: &Path) {
+ let default_home = TempDir::new().unwrap();
+ let settings = setup_snapshot_settings(repo);
+ settings.bind(|| {
+ let mut cmd = make_snapshot_cmd_with_global_flags(repo, "switch", args, Some(cwd), &[]);
+ cmd.env("HOME", default_home.path());
+ assert_cmd_snapshot!(test_name, cmd);
+ });
+}
+
+/// Test realistic ping-pong behavior where we actually run from the correct worktree.
+///
+/// This simulates real usage with shell integration, where each `wt switch` actually
+/// changes the working directory before the next command runs.
+#[test]
+fn test_switch_ping_pong_realistic() {
+ use std::process::Command;
+
+ let repo = setup_switch_repo();
+
+ // Create feature-a branch
+ let mut cmd = Command::new("git");
+ repo.configure_git_cmd(&mut cmd);
+ cmd.args(["branch", "feature-a"])
+ .current_dir(repo.root_path())
+ .output()
+ .unwrap();
+
+ // Step 1: From main worktree, switch to feature-a (creates worktree)
+ // History: current=feature-a, previous=main
+ snapshot_switch_from_dir(
+ "ping_pong_1_main_to_feature_a",
+ &repo,
+ &["feature-a"],
+ repo.root_path(),
+ );
+
+ // Calculate feature-a worktree path
+ let feature_a_path = repo.root_path().parent().unwrap().join(format!(
+ "{}.feature-a",
+ repo.root_path().file_name().unwrap().to_str().unwrap()
+ ));
+
+ // Step 2: From feature-a worktree, switch back to main
+ // History: current=main, previous=feature-a
+ snapshot_switch_from_dir(
+ "ping_pong_2_feature_a_to_main",
+ &repo,
+ &["main"],
+ &feature_a_path,
+ );
+
+ // Step 3: From main worktree, wt switch - should go to feature-a
+ // History: current=feature-a, previous=main
+ snapshot_switch_from_dir(
+ "ping_pong_3_dash_to_feature_a",
+ &repo,
+ &["-"],
+ repo.root_path(),
+ );
+
+ // Step 4: From feature-a worktree, wt switch - should go back to main
+ // History: current=main, previous=feature-a
+ snapshot_switch_from_dir("ping_pong_4_dash_to_main", &repo, &["-"], &feature_a_path);
+
+ // Step 5: From main worktree, wt switch - should go to feature-a again (ping-pong!)
+ // History: current=feature-a, previous=main
+ snapshot_switch_from_dir(
+ "ping_pong_5_dash_to_feature_a_again",
+ &repo,
+ &["-"],
+ repo.root_path(),
+ );
+}
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_previous_branch_first.snap b/tests/snapshots/integration__integration_tests__switch__ping_pong_1_main_to_feature_a.snap
similarity index 100%
rename from tests/snapshots/integration__integration_tests__switch__switch_previous_branch_first.snap
rename to tests/snapshots/integration__integration_tests__switch__ping_pong_1_main_to_feature_a.snap
diff --git a/tests/snapshots/integration__integration_tests__switch__ping_pong_2_feature_a_to_main.snap b/tests/snapshots/integration__integration_tests__switch__ping_pong_2_feature_a_to_main.snap
new file mode 100644
index 000000000..67b56a856
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__switch__ping_pong_2_feature_a_to_main.snap
@@ -0,0 +1,29 @@
+---
+source: tests/integration_tests/switch.rs
+info:
+ program: wt
+ args:
+ - switch
+ - main
+ env:
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "150"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ SOURCE_DATE_EPOCH: "1735776000"
+ WORKTRUNK_BIN: ""
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+
+----- stderr -----
+🟑 Worktree for main at [REPO]; cannot cd (no shell integration)
+πŸ’‘ Run `wt config shell install` to enable automatic cd
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_previous_branch.snap b/tests/snapshots/integration__integration_tests__switch__ping_pong_3_dash_to_feature_a.snap
similarity index 100%
rename from tests/snapshots/integration__integration_tests__switch__switch_previous_branch.snap
rename to tests/snapshots/integration__integration_tests__switch__ping_pong_3_dash_to_feature_a.snap
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_previous_branch_with_worktrunk_history_second.snap b/tests/snapshots/integration__integration_tests__switch__ping_pong_4_dash_to_main.snap
similarity index 84%
rename from tests/snapshots/integration__integration_tests__switch__switch_previous_branch_with_worktrunk_history_second.snap
rename to tests/snapshots/integration__integration_tests__switch__ping_pong_4_dash_to_main.snap
index 68978f358..949969723 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_previous_branch_with_worktrunk_history_second.snap
+++ b/tests/snapshots/integration__integration_tests__switch__ping_pong_4_dash_to_main.snap
@@ -4,7 +4,7 @@ info:
program: wt
args:
- switch
- - feature-y
+ - "-"
env:
CLICOLOR_FORCE: "1"
COLUMNS: "150"
@@ -25,5 +25,5 @@ exit_code: 0
----- stdout -----
----- stderr -----
-βœ… Switched to worktree for feature-y at [REPO].feature-y
+🟑 Worktree for main at [REPO]; cannot cd (no shell integration)
πŸ’‘ Run `wt config shell install` to enable automatic cd
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_previous_branch_with_worktrunk_history_back.snap b/tests/snapshots/integration__integration_tests__switch__ping_pong_5_dash_to_feature_a_again.snap
similarity index 84%
rename from tests/snapshots/integration__integration_tests__switch__switch_previous_branch_with_worktrunk_history_back.snap
rename to tests/snapshots/integration__integration_tests__switch__ping_pong_5_dash_to_feature_a_again.snap
index 2874403aa..94f88b0d6 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_previous_branch_with_worktrunk_history_back.snap
+++ b/tests/snapshots/integration__integration_tests__switch__ping_pong_5_dash_to_feature_a_again.snap
@@ -25,5 +25,5 @@ exit_code: 0
----- stdout -----
----- stderr -----
-🟑 Worktree for feature-x at [REPO].feature-x; cannot cd (no shell integration)
+🟑 Worktree for feature-a at [REPO].feature-a; cannot cd (no shell integration)
πŸ’‘ Run `wt config shell install` to enable automatic cd
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_stale_history_first_dash.snap b/tests/snapshots/integration__integration_tests__switch__switch_stale_history_first_dash.snap
new file mode 100644
index 000000000..69d2324cc
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__switch__switch_stale_history_first_dash.snap
@@ -0,0 +1,29 @@
+---
+source: tests/integration_tests/switch.rs
+info:
+ program: wt
+ args:
+ - switch
+ - "-"
+ env:
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "150"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ SOURCE_DATE_EPOCH: "1735776000"
+ WORKTRUNK_BIN: ""
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+
+----- stderr -----
+🟑 Worktree for branch-a at [REPO].branch-a; cannot cd (no shell integration)
+πŸ’‘ Run `wt config shell install` to enable automatic cd
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_stale_history_second_dash.snap b/tests/snapshots/integration__integration_tests__switch__switch_stale_history_second_dash.snap
new file mode 100644
index 000000000..317f52f0c
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__switch__switch_stale_history_second_dash.snap
@@ -0,0 +1,28 @@
+---
+source: tests/integration_tests/switch.rs
+info:
+ program: wt
+ args:
+ - switch
+ - "-"
+ env:
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "150"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ SOURCE_DATE_EPOCH: "1735776000"
+ WORKTRUNK_BIN: ""
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+
+----- stderr -----
+βšͺ Already on worktree for main at [REPO]
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_previous_branch_second.snap b/tests/snapshots/integration__integration_tests__switch__switch_stale_history_to_a.snap
similarity index 84%
rename from tests/snapshots/integration__integration_tests__switch__switch_previous_branch_second.snap
rename to tests/snapshots/integration__integration_tests__switch__switch_stale_history_to_a.snap
index 59821c28a..367b77bc6 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_previous_branch_second.snap
+++ b/tests/snapshots/integration__integration_tests__switch__switch_stale_history_to_a.snap
@@ -4,7 +4,7 @@ info:
program: wt
args:
- switch
- - feature-b
+ - branch-a
env:
CLICOLOR_FORCE: "1"
COLUMNS: "150"
@@ -25,5 +25,5 @@ exit_code: 0
----- stdout -----
----- stderr -----
-βœ… Switched to worktree for feature-b at [REPO].feature-b
+βœ… Switched to worktree for branch-a at [REPO].branch-a
πŸ’‘ Run `wt config shell install` to enable automatic cd
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_previous_branch_with_worktrunk_history_first.snap b/tests/snapshots/integration__integration_tests__switch__switch_stale_history_to_b.snap
similarity index 84%
rename from tests/snapshots/integration__integration_tests__switch__switch_previous_branch_with_worktrunk_history_first.snap
rename to tests/snapshots/integration__integration_tests__switch__switch_stale_history_to_b.snap
index 934fb6ae1..779f81b9d 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_previous_branch_with_worktrunk_history_first.snap
+++ b/tests/snapshots/integration__integration_tests__switch__switch_stale_history_to_b.snap
@@ -4,7 +4,7 @@ info:
program: wt
args:
- switch
- - feature-x
+ - branch-b
env:
CLICOLOR_FORCE: "1"
COLUMNS: "150"
@@ -25,5 +25,5 @@ exit_code: 0
----- stdout -----
----- stderr -----
-βœ… Switched to worktree for feature-x at [REPO].feature-x
+βœ… Switched to worktree for branch-b at [REPO].branch-b
πŸ’‘ Run `wt config shell install` to enable automatic cd