Skip to content

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

Cache remaining expensive tasks, unify wt list and picker (#2098)

Maximilian Roosd50bdfcde0f8
diff --git a/benches/CLAUDE.md b/benches/CLAUDE.md
index 4ef2f2086..40c05bb34 100644
--- a/benches/CLAUDE.md
+++ b/benches/CLAUDE.md
@@ -209,6 +209,10 @@ This command walks the commit graph to compute divergence. On rust-lang/rust:
- Only way to avoid it is to not enumerate branches at all
**Branch enumeration costs** (rust-lang/rust with 50 branches):
-- No optimization: ~15-18s (expensive merge-base/merge-tree per branch)
-- With skip_expensive_for_stale: ~2-3s (skips expensive ops for stale branches)
+- First run (cold persistent cache): ~15-18s (expensive merge-base/merge-tree per branch)
+- Subsequent runs (warm persistent cache): ~2-3s (cache hits on merge-tree / integration probes / diff stats / ancestry)
- Worktrees only: ~600ms (no branch enumeration)
+
+The persistent SHA-keyed cache (`.git/wt/cache/`) amortizes the first-run cost across
+subsequent invocations. Cache entries are eternally valid since they're keyed on commit
+SHAs.
diff --git a/benches/list.rs b/benches/list.rs
index ad66d5e7b..091ad3c78 100644
--- a/benches/list.rs
+++ b/benches/list.rs
@@ -8,8 +8,7 @@
// - many_branches: 100 branches (warm + cold)
// - divergent_branches: 200 branches × 20 commits on synthetic repo (warm + cold)
// - real_repo_many_branches: 50 branches at different history depths / GH #461
-// - warm: baseline (~15-18s)
-// - warm_optimized: with skip_expensive_for_stale (~2-3s)
+// - warm: all branches (first run expensive; subsequent runs hit persistent cache)
// - warm_worktrees_only: no branch enumeration (~600ms)
// - timeout_effect: Compare with/without 500ms command timeout on rust repo / GH #461 fix
//
@@ -290,9 +289,8 @@ fn setup_rust_workspace_with_branches(temp: &tempfile::TempDir, num_branches: us
/// This reproduces the `wt switch` interactive picker delay reported in #461. The key factor
/// is NOT commits per branch, but rather how far back in history branches diverge from each other.
///
-/// Benchmarks three modes:
-/// - `warm`: baseline with all branches, no optimization (~15-18s)
-/// - `warm_optimized`: with skip_expensive_for_stale (what `wt switch` picker uses, ~2-3s)
+/// Benchmarks two modes:
+/// - `warm`: with all branches (first run expensive, subsequent runs hit the persistent cache)
/// - `warm_worktrees_only`: no branch enumeration (~600ms)
///
/// Key insight: `git for-each-ref %(ahead-behind:BASE)` is O(commits), not O(refs).
@@ -328,7 +326,7 @@ fn bench_real_repo_many_branches(c: &mut Criterion) {
(temp, workspace_main)
};
- // Baseline: all branches, no optimization
+ // Baseline: all branches
group.bench_function("warm", |b| {
let (_temp, workspace_main) = setup_workspace();
b.iter(|| {
@@ -340,19 +338,6 @@ fn bench_real_repo_many_branches(c: &mut Criterion) {
});
});
- // With skip_expensive_for_stale optimization (simulates wt switch picker behavior)
- group.bench_function("warm_optimized", |b| {
- let (_temp, workspace_main) = setup_workspace();
- b.iter(|| {
- let mut cmd = Command::new(binary);
- cmd.args(["list", "--branches"])
- .current_dir(&workspace_main);
- isolate_cmd(&mut cmd, None);
- cmd.env("WORKTRUNK_TEST_SKIP_EXPENSIVE_THRESHOLD", "1");
- cmd.output().unwrap();
- });
- });
-
// Worktrees only: no branch enumeration, skips expensive %(ahead-behind) batch
group.bench_function("warm_worktrees_only", |b| {
let (_temp, workspace_main) = setup_workspace();
diff --git a/docs/content/faq.md b/docs/content/faq.md
index cc9297efc..984db21ad 100644
--- a/docs/content/faq.md
+++ b/docs/content/faq.md
@@ -114,7 +114,7 @@ Worktrunk stores small amounts of cache and log data in the repository's `.git/`
| Location | Purpose | Created by |
|----------|---------|------------|
| `git config worktrunk.*` | Cached default branch, switch history, branch markers, custom variables | Various commands |
-| `.git/wt/cache/{kind}/*.json` | Cached CI status, merge-tree, and integration probe results | `wt list`, `wt merge`, `wt remove` |
+| `.git/wt/cache/{kind}/*.json` | Cached CI status and git command results (merge-tree, integration probes, diff stats, ancestry checks) | `wt list`, `wt merge`, `wt remove` |
| `.git/wt/logs/{branch}/**/*.log` | Background hook output (nested per branch) | Hooks, background `wt remove` |
| `.git/wt/logs/commands.jsonl` | Command audit log (~2MB max) | Hooks, LLM commands |
| `.git/wt/logs/verbose.log` | Debug log for issue reporting | Running with `-vv` |
diff --git a/skills/worktrunk/reference/faq.md b/skills/worktrunk/reference/faq.md
index b66b430ec..9b4ee5549 100644
--- a/skills/worktrunk/reference/faq.md
+++ b/skills/worktrunk/reference/faq.md
@@ -107,7 +107,7 @@ Worktrunk stores small amounts of cache and log data in the repository's `.git/`
| Location | Purpose | Created by |
|----------|---------|------------|
| `git config worktrunk.*` | Cached default branch, switch history, branch markers, custom variables | Various commands |
-| `.git/wt/cache/{kind}/*.json` | Cached CI status, merge-tree, and integration probe results | `wt list`, `wt merge`, `wt remove` |
+| `.git/wt/cache/{kind}/*.json` | Cached CI status and git command results (merge-tree, integration probes, diff stats, ancestry checks) | `wt list`, `wt merge`, `wt remove` |
| `.git/wt/logs/{branch}/**/*.log` | Background hook output (nested per branch) | Hooks, background `wt remove` |
| `.git/wt/logs/commands.jsonl` | Command audit log (~2MB max) | Hooks, LLM commands |
| `.git/wt/logs/verbose.log` | Debug log for issue reporting | Running with `-vv` |
diff --git a/src/commands/config/state.rs b/src/commands/config/state.rs
index ccd6d1074..343c33db8 100644
--- a/src/commands/config/state.rs
+++ b/src/commands/config/state.rs
@@ -886,7 +886,7 @@ pub fn handle_state_clear_all() -> anyhow::Result<()> {
cleared_any = true;
}
- // Clear git commands cache (merge-tree, patch-id results)
+ // Clear git commands cache (merge-tree, ancestry, diff results)
let probe_cleared = repo.clear_git_commands_cache();
if probe_cleared > 0 {
eprintln!(
diff --git a/src/commands/list/collect/execution.rs b/src/commands/list/collect/execution.rs
index 4c69e110f..9f2cdfd66 100644
--- a/src/commands/list/collect/execution.rs
+++ b/src/commands/list/collect/execution.rs
@@ -35,18 +35,6 @@ use super::tasks::{
};
use super::types::{TaskError, TaskKind, TaskResult};
-// Tasks that are expensive because they require merge-base computation or merge simulation.
-// These are skipped for branches that are far behind the default branch (in `wt switch` interactive picker).
-// AheadBehind is NOT here - we use batch data for it instead of skipping.
-// CommittedTreesMatch is NOT here - it's a cheap tree comparison that aids integration detection.
-// WouldMergeAdd and MergeTreeConflicts are NOT here - they use the persistent SHA-keyed
-// probe cache, so they're instant on cache hits (only slow on the first invocation).
-const EXPENSIVE_TASKS: &[TaskKind] = &[
- TaskKind::HasFileChanges, // git diff with three-dot range
- TaskKind::IsAncestor, // git merge-base --is-ancestor
- TaskKind::BranchDiff, // git diff with three-dot range
-];
-
/// Tasks that require a valid commit SHA. Skipped for unborn branches (no commits yet).
/// Without this, these tasks would fail on the null OID and show as errors in the table.
const COMMIT_TASKS: &[TaskKind] = &[
@@ -372,12 +360,6 @@ pub fn work_items_for_worktree(
llm_command: options.llm_command.clone(),
};
- // Check if this branch is stale and should skip expensive tasks.
- let is_stale = wt
- .branch
- .as_deref()
- .is_some_and(|b| options.stale_branches.contains(b));
-
let has_commits = wt.has_commits();
let mut items = Vec::with_capacity(15);
@@ -405,7 +387,6 @@ pub fn work_items_for_worktree(
TaskKind::SummaryGenerate,
] {
let will_skip = skip.contains(&kind)
- || (is_stale && EXPENSIVE_TASKS.contains(&kind))
|| (!has_commits && COMMIT_TASKS.contains(&kind))
|| (kind == TaskKind::SummaryGenerate && options.llm_command.is_none());
if will_skip {
@@ -490,9 +471,6 @@ pub fn work_items_for_branch(
llm_command: options.llm_command.clone(),
};
- // Check if this branch is stale and should skip expensive tasks.
- let is_stale = options.stale_branches.contains(branch_name);
-
let mut items = Vec::with_capacity(11);
for kind in [
@@ -509,7 +487,6 @@ pub fn work_items_for_branch(
TaskKind::SummaryGenerate,
] {
let will_skip = skip.contains(&kind)
- || (is_stale && EXPENSIVE_TASKS.contains(&kind))
|| (kind == TaskKind::SummaryGenerate && options.llm_command.is_none());
if will_skip {
seed_skipped_task_defaults(item, kind);
@@ -568,7 +545,6 @@ mod tests {
skip_tasks,
url_template: Some("http://localhost/{{ branch }}".to_string()),
llm_command: None,
- stale_branches: HashSet::new(),
};
let expected_results = Arc::new(ExpectedResults::default());
@@ -610,8 +586,7 @@ mod tests {
let options = CollectOptions {
skip_tasks: HashSet::new(),
llm_command: None,
- stale_branches: HashSet::new(),
- ..Default::default()
+ url_template: None,
};
let expected_results = Arc::new(ExpectedResults::default());
diff --git a/src/commands/list/collect/mod.rs b/src/commands/list/collect/mod.rs
index 5c3bd00eb..b09b4fe56 100644
--- a/src/commands/list/collect/mod.rs
+++ b/src/commands/list/collect/mod.rs
@@ -95,20 +95,24 @@
//!
//! ## Caching
//!
-//! Four sibling caches live under `.git/wt/cache/`. Each uses a different key scheme because
+//! Sibling caches live under `.git/wt/cache/`. Each uses a different key scheme because
//! the underlying operations differ in what their output depends on.
//!
//! | Directory | Module | Key | Staleness |
//! |-----------|--------|-----|-----------|
//! | `merge-tree-conflicts/` | `git::repository::probe_cache` | `{sha1}-{sha2}.json` (sorted) | Never — content-addressed |
//! | `merge-add-probe/` | `git::repository::probe_cache` | `{branch_sha}-{target_sha}.json` | Never — content-addressed |
+//! | `is-ancestor/` | `git::repository::probe_cache` | `{base_sha}-{head_sha}.json` | Never — content-addressed |
+//! | `has-added-changes/` | `git::repository::probe_cache` | `{branch_sha}-{target_sha}.json` | Never — content-addressed |
+//! | `diff-stats/` | `git::repository::probe_cache` | `{base_sha}-{head_sha}.json` | Never — content-addressed |
//! | `ci-status/` | `commands::list::ci_status::cache` | `{branch}.json` | TTL 30–60s + HEAD SHA check |
//! | `summaries/` | `summary` | `{branch}.json` | `diff_hash` mismatch |
//!
//! ### Key schemes
//!
//! - **SHA-pair**: pure function of two commit SHAs. Never stale, no TTL, no invalidation.
-//! Used by merge-tree conflict checks and merge-add probes.
+//! Used by all `probe_cache` kinds (merge-tree conflicts, merge-add probes, ancestry
+//! checks, file-change probes, diff stats).
//! - **Branch + TTL + HEAD**: external mutable state (CI API, remote refs). TTL bounds
//! staleness; the HEAD check invalidates early when the branch moves.
//! - **Branch + content hash**: deterministic function of a mutable input (e.g. an LLM call
@@ -120,6 +124,9 @@
//! |------|-------|
//! | `MergeTreeConflicts` | `probe_cache` (merge-tree-conflicts) |
//! | `WouldMergeAdd` | `probe_cache` (merge-add-probe) |
+//! | `IsAncestor` | `probe_cache` (is-ancestor) |
+//! | `HasFileChanges` | `probe_cache` (has-added-changes) |
+//! | `BranchDiff` | `probe_cache` (diff-stats, skipped when sparse checkout is active) |
//! | `CiStatus` | `ci_status::cache` |
//! | `SummaryGenerate` | `summary` |
//!
@@ -127,21 +134,14 @@
//!
//! ### Cacheable but uncached
//!
-//! Several tasks compute a pure function of a commit SHA pair and slot into `probe_cache`
-//! without a new scheme:
-//!
-//! - `IsAncestor` — `merge-base --is-ancestor base head`
-//! - `HasFileChanges` — three-dot diff `target...branch`
-//! - `BranchDiff` — diff stats `base...branch`
-//!
-//! A second group takes ref *names*, but reduces to a SHA pair once the refs are resolved.
-//! Same pattern, same cache:
+//! A few tasks take ref *names* and reduce to a SHA pair once the refs are resolved. Same
+//! SHA-pair pattern as `probe_cache`, just not wired up yet:
//!
//! - `AheadBehind` — counts against the default branch
//! - `CommittedTreesMatch` — tree equality against the integration target
//! - `Upstream` — ahead/behind counts against the tracking branch
//!
-//! Reuse `probe_cache` for any of these rather than inventing a fourth scheme.
+//! Reuse `probe_cache` for any of these rather than inventing a new scheme.
//!
//! ### Fundamentally uncacheable
//!
@@ -243,47 +243,6 @@ pub struct CollectOptions {
/// LLM command for summary generation (from commit.generation config).
/// None if not configured — SummaryGenerate task will be skipped.
pub llm_command: Option<String>,
-
- /// Branches to skip expensive tasks for (behind > threshold).
- ///
- /// Presence in set = skip expensive tasks for this branch (HasFileChanges,
- /// IsAncestor, WouldMergeAdd, BranchDiff, MergeTreeConflicts).
- ///
- /// ## Why "commits behind" as the heuristic
- ///
- /// The expensive operations (`git merge-tree`, `git diff`) scale with:
- /// - **Files changed on both sides** — each needs 3-way merge or diff
- /// - **Size of those files** — content loading and merge algorithm
- ///
- /// Commit count isn't directly in the algorithm, but "commits behind" is a
- /// cheap proxy: more commits on main since divergence → more files main has
- /// touched → more potential overlap with the branch's changes.
- ///
- /// We use "behind" rather than "ahead" because feature branches typically
- /// have small ahead counts, so behind dominates. A more accurate heuristic
- /// would be `min(files_changed_on_main, files_changed_on_branch)`, but
- /// computing that requires per-branch git commands, defeating the optimization.
- ///
- /// The batch `git for-each-ref --format='%(ahead-behind:...)'` gives us all
- /// counts in a single command, making this heuristic essentially free.
- ///
- /// ## Implementation
- ///
- /// Built by filtering `batch_ahead_behind()` results on local branches only.
- /// Remote-only branches are never in this set (they use individual git commands).
- /// The threshold (default 50) is applied at construction time. Ahead/behind
- /// counts are cached in Repository and looked up by AheadBehindTask.
- ///
- /// **Display implications:** When tasks are skipped:
- /// - BranchDiff column shows `…` instead of diff stats
- /// - Status symbols (conflict `✗`, integrated `⊂`) may be missing or incorrect
- /// since they depend on skipped tasks
- ///
- /// Note: `wt switch` interactive picker doesn't show the BranchDiff column, so `…` isn't visible there.
- ///
- /// TODO: Consider adding a visible indicator in Status column when integration
- /// checks are skipped, so users know the `⊂` symbol may be incomplete.
- pub stale_branches: std::collections::HashSet<String>,
}
fn worktree_branch_set(worktrees: &[WorktreeInfo]) -> HashSet<&str> {
@@ -322,17 +281,11 @@ pub enum ShowConfig {
/// When false, behavior depends on `render_table`:
/// - If `render_table` is true: renders final table (buffered mode)
/// - If `render_table` is false: returns data without rendering (JSON mode)
-///
-/// The `skip_expensive_for_stale` parameter enables batch-fetching ahead/behind counts and
-/// skipping expensive merge-base operations for branches far behind the default branch.
-/// This dramatically improves performance for repos with many stale branches.
-///
pub fn collect(
repo: &Repository,
show_config: ShowConfig,
show_progress: bool,
render_table: bool,
- skip_expensive_for_stale: bool,
) -> anyhow::Result<Option<super::model::ListData>> {
worktrunk::shell_exec::trace_instant("List collect started");
@@ -667,11 +620,10 @@ pub fn collect(
// Create collection options from skip set
let returned_skip_tasks = effective_skip_tasks.clone();
- let mut options = CollectOptions {
+ let options = CollectOptions {
skip_tasks: effective_skip_tasks,
url_template: url_template.clone(),
llm_command,
- ..Default::default()
};
// Track expected results per item - populated as spawns are queued
@@ -792,34 +744,15 @@ pub fn collect(
}
}
- // Batch-fetch ahead/behind counts to identify branches that are far behind.
- // This allows skipping expensive merge-base operations for diverged branches, dramatically
- // improving performance on repos with many stale branches (e.g., `wt switch` interactive picker).
+ // Batch-fetch ahead/behind counts for all local branches in a single
+ // `git for-each-ref` call. Primes the Repository cache so each
+ // `AheadBehindTask` hits the cache instead of spawning its own
+ // `git rev-list --count`. One git call replaces N.
//
- // Uses `git for-each-ref --format='%(ahead-behind:...)'` (git 2.36+) which gets all
- // counts in a single command. On older git versions, returns empty and all tasks run.
- // Skip if default_branch is unknown.
- if skip_expensive_for_stale && let Some(ref db) = default_branch {
- // Branches more than 50 commits behind skip expensive operations.
- // 50 is low enough to catch truly stale branches while keeping info for
- // recently-diverged ones.
- //
- // "Behind" is a proxy for the actual cost driver: files changed on both
- // sides since the merge-base. More commits on main → more files touched →
- // more overlap with the branch. See `CollectOptions::stale_branches` for
- // detailed rationale.
- let threshold: usize = std::env::var("WORKTRUNK_TEST_SKIP_EXPENSIVE_THRESHOLD")
- .ok()
- .and_then(|s| s.parse().ok())
- .unwrap_or(50);
- // batch_ahead_behind populates the Repository cache with all counts
- let ahead_behind = repo.batch_ahead_behind(db);
- // Filter to stale branches (behind > threshold). The set indicates which
- // branches should skip expensive tasks; counts come from the cache.
- options.stale_branches = ahead_behind
- .into_iter()
- .filter_map(|(branch, (_, behind))| (behind > threshold).then_some(branch))
- .collect();
+ // On git < 2.36 (no `%(ahead-behind:)` support) or if default_branch is
+ // unknown, skip the batch — individual tasks fall back to direct calls.
+ if let Some(ref db) = default_branch {
+ repo.batch_ahead_behind(db);
}
// Note: URL template expansion is deferred to task spawning (in collect_worktree_progressive
diff --git a/src/commands/list/collect/tasks.rs b/src/commands/list/collect/tasks.rs
index a6fec5e56..4faada360 100644
--- a/src/commands/list/collect/tasks.rs
+++ b/src/commands/list/collect/tasks.rs
@@ -162,11 +162,18 @@ impl Task for AheadBehindTask {
// Check cache first (populated by batch_ahead_behind if it ran).
// Cache lookup has minor overhead (rev-parse for cache key + allocations),
// but saves the expensive ahead_behind computation on cache hit.
+ //
+ // When the ref has a branch name, compute counts against the branch — not
+ // the worktree's current HEAD sha. During rebase/merge conflicts, HEAD is
+ // transiently at a different commit than the branch tip, so using the sha
+ // would report misleading counts (e.g., `0/0 same_commit` when the branch
+ // is actually diverged). The batch path already uses branch names, so this
+ // keeps both paths consistent.
let (ahead, behind) = if let Some(branch) = ctx.branch_ref.branch.as_deref() {
if let Some(counts) = repo.cached_ahead_behind(&base, branch) {
counts
} else {
- repo.ahead_behind(&base, &ctx.branch_ref.commit_sha)
+ repo.ahead_behind(&base, branch)
.map_err(|e| ctx.error(Self::KIND, &e))?
}
} else {
@@ -199,10 +206,17 @@ impl Task for CommittedTreesMatchTask {
});
};
let repo = &ctx.repo;
- // Use the item's commit instead of HEAD, since for branches without
- // worktrees, HEAD is the main worktree's HEAD.
+ // Prefer the branch name when present: during a rebase-in-progress, the
+ // worktree's HEAD is at a transient replayed commit, so using commit_sha
+ // would compare the wrong tree. For branch-only items the two are
+ // equivalent; for detached HEAD, commit_sha is the only option.
+ let ref_to_check = ctx
+ .branch_ref
+ .branch
+ .as_deref()
+ .unwrap_or(&ctx.branch_ref.commit_sha);
let committed_trees_match = repo
- .trees_match(&ctx.branch_ref.commit_sha, &base)
+ .trees_match(ref_to_check, &base)
.map_err(|e| ctx.error(Self::KIND, &e))?;
Ok(TaskResult::CommittedTreesMatch {
item_idx: ctx.item_idx,
@@ -325,8 +339,15 @@ impl Task for IsAncestorTask {
});
};
let repo = &ctx.repo;
+ // Prefer the branch name when present — see `CommittedTreesMatchTask`
+ // for rationale (rebase-in-progress transient HEAD).
+ let ref_to_check = ctx
+ .branch_ref
+ .branch
+ .as_deref()
+ .unwrap_or(&ctx.branch_ref.commit_sha);
let is_ancestor = repo
- .is_ancestor(&ctx.branch_ref.commit_sha, &base)
+ .is_ancestor(ref_to_check, &base)
.map_err(|e| ctx.error(Self::KIND, &e))?;
Ok(TaskResult::IsAncestor {
@@ -351,8 +372,15 @@ impl Task for BranchDiffTask {
});
};
let repo = &ctx.repo;
+ // Prefer the branch name when present — see `CommittedTreesMatchTask`
+ // for rationale (rebase-in-progress transient HEAD).
+ let ref_to_check = ctx
+ .branch_ref
+ .branch
+ .as_deref()
+ .unwrap_or(&ctx.branch_ref.commit_sha);
let diff = repo
- .branch_diff_stats(&base, &ctx.branch_ref.commit_sha)
+ .branch_diff_stats(&base, ref_to_check)
.map_err(|e| ctx.error(Self::KIND, &e))?;
Ok(TaskResult::BranchDiff {
@@ -420,8 +448,15 @@ impl Task for MergeTreeConflictsTask {
});
};
let repo = &ctx.repo;
+ // Prefer the branch name when present — see `CommittedTreesMatchTask`
+ // for rationale (rebase-in-progress transient HEAD).
+ let ref_to_check = ctx
+ .branch_ref
+ .branch
+ .as_deref()
+ .unwrap_or(&ctx.branch_ref.commit_sha);
let has_merge_tree_conflicts = repo
- .has_merge_conflicts(&base, &ctx.branch_ref.commit_sha)
+ .has_merge_conflicts(&base, ref_to_check)
.map_err(|e| ctx.error(Self::KIND, &e))?;
Ok(TaskResult::MergeTreeConflicts {
item_idx: ctx.item_idx,
diff --git a/src/commands/list/mod.rs b/src/commands/list/mod.rs
index 1efdd9ac1..552939b63 100644
--- a/src/commands/list/mod.rs
+++ b/src/commands/list/mod.rs
@@ -165,9 +165,6 @@ pub fn handle_list(
crate::OutputFormat::Table | crate::OutputFormat::ClaudeCode
);
- // For testing: allow enabling skip_expensive_for_stale via env var
- let skip_expensive_for_stale = std::env::var("WORKTRUNK_TEST_SKIP_EXPENSIVE_THRESHOLD").is_ok();
-
let list_data = collect::collect(
&repo,
collect::ShowConfig::DeferredToParallel {
@@ -177,7 +174,6 @@ pub fn handle_list(
},
show_progress,
render_table,
- skip_expensive_for_stale,
)?;
let Some(ListData { items, .. }) = list_data else {
diff --git a/src/commands/picker/mod.rs b/src/commands/picker/mod.rs
index ff9009f2b..d27272ab8 100644
--- a/src/commands/picker/mod.rs
+++ b/src/commands/picker/mod.rs
@@ -322,7 +322,6 @@ pub fn handle_picker(
},
false, // show_progress (no progress bars)
false, // render_table (picker renders its own UI)
- true, // skip_expensive_for_stale (faster for repos with many stale branches)
)?
else {
return Ok(());
diff --git a/src/git/diff.rs b/src/git/diff.rs
index efb888f96..cb3601615 100644
--- a/src/git/diff.rs
+++ b/src/git/diff.rs
@@ -4,7 +4,7 @@ use ansi_str::AnsiStr;
use color_print::cformat;
/// Line-level diff totals (added/deleted counts) used across git operations.
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, serde::Serialize)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)]
pub struct LineDiff {
pub added: usize,
pub deleted: usize,
diff --git a/src/git/repository/diff.rs b/src/git/repository/diff.rs
index 50006870d..9c7b574e0 100644
--- a/src/git/repository/diff.rs
+++ b/src/git/repository/diff.rs
@@ -286,26 +286,47 @@ impl Repository {
///
/// For orphan branches with no common ancestor, returns zeros.
pub fn branch_diff_stats(&self, base: &str, head: &str) -> anyhow::Result<LineDiff> {
- // Limit concurrent diff operations to reduce mmap thrash on pack files
+ let base_sha = self.rev_parse_commit(base)?;
+ let head_sha = self.rev_parse_commit(head)?;
+
+ // Sparse checkout filters the diff by path, making the result
+ // environment-dependent rather than purely SHA-determined. Skip the
+ // persistent cache when sparse checkout is active.
+ let sparse_paths = self.sparse_checkout_paths();
+ let use_cache = sparse_paths.is_empty();
+
+ if use_cache
+ && let Some(cached) = super::probe_cache::get_diff_stats(self, &base_sha, &head_sha)
+ {
+ return Ok(cached);
+ }
+
+ // Limit concurrent diff operations to reduce mmap thrash on pack files.
+ // Acquired after cache check to avoid holding the semaphore on cache hits.
let _guard = super::super::HEAVY_OPS_SEMAPHORE.acquire();
// Get merge-base (cached in shared repo cache)
- let Some(merge_base) = self.merge_base(base, head)? else {
+ let Some(merge_base) = self.merge_base(&base_sha, &head_sha)? else {
+ if use_cache {
+ super::probe_cache::put_diff_stats(self, &base_sha, &head_sha, LineDiff::default());
+ }
return Ok(LineDiff::default());
};
- // Use two-dot syntax with the cached merge-base
- let range = format!("{}..{}", merge_base, head);
+ let range = format!("{}..{}", merge_base, head_sha);
let mut args = vec!["diff", "--shortstat", &range];
- let sparse_paths = self.sparse_checkout_paths();
if !sparse_paths.is_empty() {
args.push("--");
args.extend(sparse_paths.iter().map(|s| s.as_str()));
}
let stdout = self.run_command(&args)?;
- Ok(LineDiff::from_shortstat(&stdout))
+ let result = LineDiff::from_shortstat(&stdout);
+ if use_cache {
+ super::probe_cache::put_diff_stats(self, &base_sha, &head_sha, result);
+ }
+ Ok(result)
}
/// Get formatted diff stats summary for display.
diff --git a/src/git/repository/integration.rs b/src/git/repository/integration.rs
index d89edc748..2308485b4 100644
--- a/src/git/repository/integration.rs
+++ b/src/git/repository/integration.rs
@@ -58,7 +58,18 @@ impl Repository {
pub fn is_ancestor(&self, base: &str, head: &str) -> anyhow::Result<bool> {
let base = self.resolve_preferring_branch(base);
let head = self.resolve_preferring_branch(head);
- self.run_command_check(&["merge-base", "--is-ancestor", &base, &head])
+
+ let base_sha = self.rev_parse_commit(&base)?;
+ let head_sha = self.rev_parse_commit(&head)?;
+
+ if let Some(cached) = super::probe_cache::get_is_ancestor(self, &base_sha, &head_sha) {
+ return Ok(cached);
+ }
+
+ let result =
+ self.run_command_check(&["merge-base", "--is-ancestor", &base_sha, &head_sha])?;
+ super::probe_cache::put_is_ancestor(self, &base_sha, &head_sha, result);
+ Ok(result)
}
/// Check if two refs point to the same commit.
@@ -86,16 +97,27 @@ impl Repository {
pub fn has_added_changes(&self, branch: &str, target: &str) -> anyhow::Result<bool> {
let branch = self.resolve_preferring_branch(branch);
let target = self.resolve_preferring_branch(target);
- // Try to get merge-base (cached). Orphan branches return None.
- let Some(merge_base) = self.merge_base(&target, &branch)? else {
- // Orphan branches have no common ancestor, so all their changes are unique
+
+ let branch_sha = self.rev_parse_commit(&branch)?;
+ let target_sha = self.rev_parse_commit(&target)?;
+
+ if let Some(cached) =
+ super::probe_cache::get_has_added_changes(self, &branch_sha, &target_sha)
+ {
+ return Ok(cached);
+ }
+
+ // Orphan branches have no common ancestor, so all their changes are unique
+ let Some(merge_base) = self.merge_base(&target_sha, &branch_sha)? else {
+ super::probe_cache::put_has_added_changes(self, &branch_sha, &target_sha, true);
return Ok(true);
};
- // git diff --name-only merge_base..branch shows files changed from merge-base to branch
- let range = format!("{merge_base}..{branch}");
+ let range = format!("{merge_base}..{branch_sha}");
let output = self.run_command(&["diff", "--name-only", &range])?;
- Ok(!output.trim().is_empty())
+ let result = !output.trim().is_empty();
+ super::probe_cache::put_has_added_changes(self, &branch_sha, &target_sha, result);
+ Ok(result)
}
/// Check if two refs have identical tree content (same files/directories).
diff --git a/src/git/repository/probe_cache.rs b/src/git/repository/probe_cache.rs
index b2f12c96a..567464571 100644
--- a/src/git/repository/probe_cache.rs
+++ b/src/git/repository/probe_cache.rs
@@ -1,19 +1,20 @@
-//! Persistent cache for SHA-keyed git merge probes.
+//! Persistent cache for SHA-keyed git command results.
//!
-//! Caches the results of expensive merge-tree / patch-id operations keyed
-//! on pairs of commit SHAs. Because commit SHAs are content-addressed and
-//! immutable, cached entries never go stale — the result of merging commit
-//! A into commit B is the same today as it was last week. No TTL, no
-//! invalidation logic, only a size bound to prevent unbounded growth.
+//! Caches the results of expensive git operations keyed on pairs of commit
+//! SHAs. Because commit SHAs are content-addressed and immutable, cached
+//! entries never go stale — the result of diffing commit A against commit B
+//! is the same today as it was last week. No TTL, no invalidation logic,
+//! only a size bound to prevent unbounded growth.
//!
//! # Layout
//!
//! One file per cached entry under `.git/wt/cache/{kind}/{key}.json`,
-//! where `kind` is the task kind (`merge-tree-conflicts`,
-//! `merge-add-probe`) and `key` is the SHA-pair filename. The sibling
-//! `ci-status/` and `summaries/` caches use different key schemes; see
+//! where `kind` identifies the operation (`merge-tree-conflicts`,
+//! `merge-add-probe`, `is-ancestor`, `has-added-changes`, `diff-stats`)
+//! and `key` is the SHA-pair filename. The sibling `ci-status/` and
+//! `summaries/` caches use different key schemes; see
//! `commands::list::collect` for the cross-cutting design across all
-//! four caches.
+//! `.git/wt/cache/` kinds.
//!
//! Symmetric kinds (merge-tree-conflicts) sort the SHA pair so
//! `merge-tree(A, B)` and `merge-tree(B, A)` hit the same entry.
@@ -42,6 +43,7 @@ use serde::{Serialize, de::DeserializeOwned};
use super::Repository;
use super::integration::MergeProbeResult;
+use crate::git::LineDiff;
/// Maximum cached entries per task kind before the LRU sweep removes the
/// oldest entries. 5000 entries × ~80 bytes ≈ 400 KB per kind — small
@@ -50,6 +52,18 @@ const MAX_ENTRIES_PER_KIND: usize = 5000;
const KIND_MERGE_TREE_CONFLICTS: &str = "merge-tree-conflicts";
const KIND_MERGE_ADD_PROBE: &str = "merge-add-probe";
+const KIND_IS_ANCESTOR: &str = "is-ancestor";
+const KIND_HAS_ADDED_CHANGES: &str = "has-added-changes";
+const KIND_DIFF_STATS: &str = "diff-stats";
+
+/// All cache kind identifiers, used by [`clear_all`].
+const ALL_KINDS: &[&str] = &[
+ KIND_MERGE_TREE_CONFLICTS,
+ KIND_MERGE_ADD_PROBE,
+ KIND_IS_ANCESTOR,
+ KIND_HAS_ADDED_CHANGES,
+ KIND_DIFF_STATS,
+];
/// Get the cache directory for a given task kind.
///
@@ -212,6 +226,79 @@ pub(super) fn put_merge_add_probe(
sweep_lru(&dir, MAX_ENTRIES_PER_KIND);
}
+// ============================================================================
+// Public API — is-ancestor (asymmetric)
+// ============================================================================
+
+/// Look up a cached `is_ancestor(base_sha, head_sha)` result.
+///
+/// Asymmetric: "is base ancestor of head?" differs from "is head ancestor of base?".
+pub(super) fn get_is_ancestor(repo: &Repository, base_sha: &str, head_sha: &str) -> Option<bool> {
+ let path = cache_dir(repo, KIND_IS_ANCESTOR).join(asymmetric_key(base_sha, head_sha));
+ read::<bool>(&path)
+}
+
+/// Store an `is_ancestor(base_sha, head_sha)` result.
+pub(super) fn put_is_ancestor(repo: &Repository, base_sha: &str, head_sha: &str, value: bool) {
+ let dir = cache_dir(repo, KIND_IS_ANCESTOR);
+ let path = dir.join(asymmetric_key(base_sha, head_sha));
+ write(&path, &value);
+ sweep_lru(&dir, MAX_ENTRIES_PER_KIND);
+}
+
+// ============================================================================
+// Public API — has-added-changes (asymmetric)
+// ============================================================================
+
+/// Look up a cached `has_added_changes(branch_sha, target_sha)` result.
+///
+/// Asymmetric: diff from merge-base to branch is directional.
+pub(super) fn get_has_added_changes(
+ repo: &Repository,
+ branch_sha: &str,
+ target_sha: &str,
+) -> Option<bool> {
+ let path = cache_dir(repo, KIND_HAS_ADDED_CHANGES).join(asymmetric_key(branch_sha, target_sha));
+ read::<bool>(&path)
+}
+
+/// Store a `has_added_changes(branch_sha, target_sha)` result.
+pub(super) fn put_has_added_changes(
+ repo: &Repository,
+ branch_sha: &str,
+ target_sha: &str,
+ value: bool,
+) {
+ let dir = cache_dir(repo, KIND_HAS_ADDED_CHANGES);
+ let path = dir.join(asymmetric_key(branch_sha, target_sha));
+ write(&path, &value);
+ sweep_lru(&dir, MAX_ENTRIES_PER_KIND);
+}
+
+// ============================================================================
+// Public API — diff-stats (asymmetric)
+// ============================================================================
+
+/// Look up cached `branch_diff_stats(base_sha, head_sha)` result.
+///
+/// Asymmetric: diff from merge-base(base,head)..head is directional.
+pub(super) fn get_diff_stats(
+ repo: &Repository,
+ base_sha: &str,
+ head_sha: &str,
+) -> Option<LineDiff> {
+ let path = cache_dir(repo, KIND_DIFF_STATS).join(asymmetric_key(base_sha, head_sha));
+ read::<LineDiff>(&path)
+}
+
+/// Store a `branch_diff_stats(base_sha, head_sha)` result.
+pub(super) fn put_diff_stats(repo: &Repository, base_sha: &str, head_sha: &str, value: LineDiff) {
+ let dir = cache_dir(repo, KIND_DIFF_STATS);
+ let path = dir.join(asymmetric_key(base_sha, head_sha));
+ write(&path, &value);
+ sweep_lru(&dir, MAX_ENTRIES_PER_KIND);
+}
+
// ============================================================================
// Maintenance
// ============================================================================
@@ -221,7 +308,7 @@ pub(super) fn put_merge_add_probe(
/// Called by `wt config state clear` to give users a clean slate.
pub(crate) fn clear_all(repo: &Repository) -> usize {
let mut cleared = 0;
- for kind in [KIND_MERGE_TREE_CONFLICTS, KIND_MERGE_ADD_PROBE] {
+ for kind in ALL_KINDS {
let dir = cache_dir(repo, kind);
let Ok(entries) = fs::read_dir(&dir) else {
continue;
@@ -442,4 +529,188 @@ mod tests {
assert!(cached.would_merge_add);
assert!(cached.is_patch_id_match);
}
+
+ // Round-trip: is-ancestor, has-added-changes, diff-stats
+
+ #[test]
+ fn test_is_ancestor_roundtrip() {
+ let test = TestRepo::with_initial_commit();
+ let repo = Repository::at(test.root_path()).unwrap();
+
+ assert_eq!(get_is_ancestor(&repo, "aaaa", "bbbb"), None);
+
+ put_is_ancestor(&repo, "aaaa", "bbbb", true);
+ assert_eq!(get_is_ancestor(&repo, "aaaa", "bbbb"), Some(true));
+
+ // Asymmetric: swapped args miss
+ assert_eq!(get_is_ancestor(&repo, "bbbb", "aaaa"), None);
+ }
+
+ #[test]
+ fn test_has_added_changes_roundtrip() {
+ let test = TestRepo::with_initial_commit();
+ let repo = Repository::at(test.root_path()).unwrap();
+
+ assert_eq!(get_has_added_changes(&repo, "aaaa", "bbbb"), None);
+
+ put_has_added_changes(&repo, "aaaa", "bbbb", false);
+ assert_eq!(get_has_added_changes(&repo, "aaaa", "bbbb"), Some(false));
+
+ // Asymmetric: swapped args miss
+ assert_eq!(get_has_added_changes(&repo, "bbbb", "aaaa"), None);
+ }
+
+ #[test]
+ fn test_diff_stats_roundtrip() {
+ let test = TestRepo::with_initial_commit();
+ let repo = Repository::at(test.root_path()).unwrap();
+
+ assert_eq!(get_diff_stats(&repo, "aaaa", "bbbb"), None);
+
+ let value = LineDiff {
+ added: 42,
+ deleted: 7,
+ };
+ put_diff_stats(&repo, "aaaa", "bbbb", value);
+ assert_eq!(get_diff_stats(&repo, "aaaa", "bbbb"), Some(value));
+
+ // Asymmetric: swapped args miss
+ assert_eq!(get_diff_stats(&repo, "bbbb", "aaaa"), None);
+ }
+
+ // Cache consultation: is_ancestor, has_added_changes, branch_diff_stats
+
+ #[test]
+ fn test_is_ancestor_reads_cache() {
+ let test = TestRepo::with_initial_commit();
+
+ test.run_git(&["checkout", "-b", "feature"]);
+ fs::write(test.root_path().join("new.txt"), "content\n").unwrap();
+ test.run_git(&["add", "new.txt"]);
+ test.run_git(&["commit", "-m", "Feature"]);
+ test.run_git(&["checkout", "main"]);
+
+ let repo = Repository::at(test.root_path()).unwrap();
+
+ // feature is NOT an ancestor of main (main didn't merge feature)
+ assert!(!repo.is_ancestor("feature", "main").unwrap());
+
+ // Tamper with cache to flip the answer
+ let dir = cache_dir(&repo, KIND_IS_ANCESTOR);
+ let entries: Vec<_> = fs::read_dir(&dir)
+ .unwrap()
+ .filter_map(|e| e.ok())
+ .filter(|e| e.file_name().to_str().is_some_and(|s| s.ends_with(".json")))
+ .collect();
+ assert_eq!(entries.len(), 1);
+ fs::write(entries[0].path(), "true").unwrap();
+
+ let repo2 = Repository::at(test.root_path()).unwrap();
+ assert!(repo2.is_ancestor("feature", "main").unwrap());
+ }
+
+ #[test]
+ fn test_has_added_changes_reads_cache() {
+ let test = TestRepo::with_initial_commit();
+
+ test.run_git(&["checkout", "-b", "feature"]);
+ fs::write(test.root_path().join("new.txt"), "content\n").unwrap();
+ test.run_git(&["add", "new.txt"]);
+ test.run_git(&["commit", "-m", "Feature"]);
+ test.run_git(&["checkout", "main"]);
+
+ let repo = Repository::at(test.root_path()).unwrap();
+
+ // feature has added changes compared to main
+ assert!(repo.has_added_changes("feature", "main").unwrap());
+
+ // Tamper with cache to flip the answer
+ let dir = cache_dir(&repo, KIND_HAS_ADDED_CHANGES);
+ let entries: Vec<_> = fs::read_dir(&dir)
+ .unwrap()
+ .filter_map(|e| e.ok())
+ .filter(|e| e.file_name().to_str().is_some_and(|s| s.ends_with(".json")))
+ .collect();
+ assert_eq!(entries.len(), 1);
+ fs::write(entries[0].path(), "false").unwrap();
+
+ let repo2 = Repository::at(test.root_path()).unwrap();
+ assert!(!repo2.has_added_changes("feature", "main").unwrap());
+ }
+
+ #[test]
+ fn test_branch_diff_stats_reads_cache() {
+ let test = TestRepo::with_initial_commit();
+
+ test.run_git(&["checkout", "-b", "feature"]);
+ fs::write(test.root_path().join("new.txt"), "content\n").unwrap();
+ test.run_git(&["add", "new.txt"]);
+ test.run_git(&["commit", "-m", "Feature"]);
+ test.run_git(&["checkout", "main"]);
+
+ let repo = Repository::at(test.root_path()).unwrap();
+
+ // Real computation
+ let real = repo.branch_diff_stats("main", "feature").unwrap();
+ assert_eq!(real.added, 1);
+ assert_eq!(real.deleted, 0);
+
+ // Tamper with cache to return different stats
+ let dir = cache_dir(&repo, KIND_DIFF_STATS);
+ let entries: Vec<_> = fs::read_dir(&dir)
+ .unwrap()
+ .filter_map(|e| e.ok())
+ .filter(|e| e.file_name().to_str().is_some_and(|s| s.ends_with(".json")))
+ .collect();
+ assert_eq!(entries.len(), 1);
+ let tampered = LineDiff {
+ added: 999,
+ deleted: 888,
+ };
+ fs::write(entries[0].path(), serde_json::to_string(&tampered).unwrap()).unwrap();
+
+ let repo2 = Repository::at(test.root_path()).unwrap();
+ let cached = repo2.branch_diff_stats("main", "feature").unwrap();
+ assert_eq!(cached.added, 999);
+ assert_eq!(cached.deleted, 888);
+ }
+
+ #[test]
+ fn test_clear_all_covers_all_kinds() {
+ let test = TestRepo::with_initial_commit();
+ let repo = Repository::at(test.root_path()).unwrap();
+
+ // Populate one entry in each kind
+ put_merge_conflicts(&repo, "a", "b", true);
+ put_merge_add_probe(
+ &repo,
+ "a",
+ "b",
+ MergeProbeResult {
+ would_merge_add: true,
+ is_patch_id_match: false,
+ },
+ );
+ put_is_ancestor(&repo, "a", "b", true);
+ put_has_added_changes(&repo, "a", "b", true);
+ put_diff_stats(
+ &repo,
+ "a",
+ "b",
+ LineDiff {
+ added: 1,
+ deleted: 0,
+ },
+ );
+
+ let cleared = clear_all(&repo);
+ assert_eq!(cleared, 5, "should clear one entry per kind");
+
+ // All kinds should be empty
+ assert_eq!(get_merge_conflicts(&repo, "a", "b"), None);
+ assert_eq!(get_merge_add_probe(&repo, "a", "b"), None);
+ assert_eq!(get_is_ancestor(&repo, "a", "b"), None);
+ assert_eq!(get_has_added_changes(&repo, "a", "b"), None);
+ assert_eq!(get_diff_stats(&repo, "a", "b"), None);
+ }
}
diff --git a/tests/helpers/wt-perf/src/lib.rs b/tests/helpers/wt-perf/src/lib.rs
index e1501c6c5..7fc281288 100644
--- a/tests/helpers/wt-perf/src/lib.rs
+++ b/tests/helpers/wt-perf/src/lib.rs
@@ -356,6 +356,9 @@ pub fn invalidate_caches_auto(repo_path: &Path) {
// Remove packed refs
let _ = std::fs::remove_file(git_dir.join("packed-refs"));
+
+ // Remove worktrunk's persistent SHA-keyed caches (diff-stats, is-ancestor, etc.)
+ let _ = std::fs::remove_dir_all(git_dir.join("wt/cache"));
}
/// Get or clone the rust-lang/rust repository for real-world benchmarks.
diff --git a/tests/integration_tests/list.rs b/tests/integration_tests/list.rs
index eddd596af..78fe3284b 100644
--- a/tests/integration_tests/list.rs
+++ b/tests/integration_tests/list.rs
@@ -2989,63 +2989,6 @@ fn test_list_skips_operations_for_prunable_worktrees(mut repo: TestRepo) {
assert_cmd_snapshot!(list_snapshots::command(&repo, repo.root_path()));
}
-/// Tests that branches far behind main show `…` instead of diff stats when
-/// skip_expensive_for_stale is enabled. This saves time in `wt switch` interactive
-/// picker for repos with many stale branches.
-///
-/// The `…` indicator distinguishes "not computed" from "zero changes" (blank).
-#[rstest]
-fn test_list_skips_expensive_for_stale_branches(mut repo: TestRepo) {
- // Create feature branch at current main
- let feature_path = repo.add_worktree("feature");
-
- // Advance main by 2 commits (feature will be 2 behind)
- repo.commit("Second commit on main");
- repo.commit("Third commit on main");
-
- // Add a change on feature so it's not integrated
- std::fs::write(feature_path.join("feature.txt"), "feature content").unwrap();
- repo.git_command()
- .args(["add", "feature.txt"])
- .current_dir(&feature_path)
- .run()
- .unwrap();
- repo.git_command()
- .args(["commit", "-m", "Feature work"])
- .current_dir(&feature_path)
- .run()
- .unwrap();
-
- // With threshold=1, feature branch (2 behind) should skip expensive tasks
- // and show `…` instead of actual diff stats
- assert_cmd_snapshot!({
- let mut cmd = list_snapshots::command(&repo, repo.root_path());
- cmd.arg("--full"); // Need --full to show BranchDiff column
- cmd.env("WORKTRUNK_TEST_SKIP_EXPENSIVE_THRESHOLD", "1");
- cmd
- });
-}
-
-/// Tests skip_expensive_for_stale with branch-only entries (no worktree).
-/// This exercises a different code path than the worktree test above.
-#[rstest]
-fn test_list_skips_expensive_for_stale_branches_only(repo: TestRepo) {
- // Create a branch without a worktree
- repo.create_branch("stale-branch");
-
- // Advance main by 2 commits (stale-branch will be 2 behind)
- repo.commit("Second commit on main");
- repo.commit("Third commit on main");
-
- // With threshold=1, stale-branch (2 behind) should skip expensive tasks
- assert_cmd_snapshot!({
- let mut cmd = list_snapshots::command(&repo, repo.root_path());
- cmd.args(["--branches", "--full"]);
- cmd.env("WORKTRUNK_TEST_SKIP_EXPENSIVE_THRESHOLD", "1");
- cmd
- });
-}
-
/// Tests that wt list works correctly when the configured default branch doesn't exist.
///
/// When a user sets `wt config state default-branch set develop` but the `develop`
diff --git a/tests/snapshots/integration__integration_tests__list__list_json_with_git_operation.snap b/tests/snapshots/integration__integration_tests__list__list_json_with_git_operation.snap
index 57c2d6d9c..91297660d 100644
--- a/tests/snapshots/integration__integration_tests__list__list_json_with_git_operation.snap
+++ b/tests/snapshots/integration__integration_tests__list__list_json_with_git_operation.snap
@@ -206,11 +206,11 @@ exit_code: 0
"deleted": 0
}
},
- "main_state": "empty",
+ "main_state": "would_conflict",
"operation_state": "conflicts",
"main": {
- "ahead": 0,
- "behind": 0
+ "ahead": 1,
+ "behind": 1
},
"worktree": {
"detached": true
@@ -218,8 +218,8 @@ exit_code: 0
"is_main": false,
"is_current": false,
"is_previous": false,
- "statusline": "feature /u001b[31m✘/u001b[39m/u001b[2m_/u001b[22m",
- "symbols": "_✘"
+ "statusline": "feature /u001b[31m✘/u001b[39m/u001b[33m✗/u001b[39m /u001b[32m↑1/u001b[0m /u001b[2m/u001b[31m↓1/u001b[0m",
+ "symbols": "✗✘"
}
]
diff --git a/tests/snapshots/integration__integration_tests__list__list_skips_expensive_for_stale_branches.snap b/tests/snapshots/integration__integration_tests__list__list_skips_expensive_for_stale_branches.snap
deleted file mode 100644
index 6eeae9930..000000000
--- a/tests/snapshots/integration__integration_tests__list__list_skips_expensive_for_stale_branches.snap
+++ /dev/null
@@ -1,55 +0,0 @@
----
-source: tests/integration_tests/list.rs
-info:
- program: wt
- args:
- - list
- - "--full"
- env:
- 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_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
- GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
- GIT_TERMINAL_PROMPT: "0"
- HOME: "[TEST_HOME]"
- LANG: C
- LC_ALL: C
- MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
- NO_COLOR: ""
- OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
- PATH: "[PATH]"
- PSModulePath: ""
- RUST_LOG: warn
- SHELL: ""
- TERM: alacritty
- USERPROFILE: "[TEST_HOME]"
- WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
- WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
- WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
- WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
- WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
- WORKTRUNK_TEST_EPOCH: "1735776000"
- WORKTRUNK_TEST_NUSHELL_ENV: "0"
- WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
- WORKTRUNK_TEST_POWERSHELL_ENV: "0"
- WORKTRUNK_TEST_SKIP_EXPENSIVE_THRESHOLD: "1"
- WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
- XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
----
-success: true
-exit_code: 0
------ stdout -----
- Branch Status HEAD± main↕ main…± Remote⇅ CI Path Commit Age Message
-@ main ^⇡ ⇡2 . c3d37f26 1d Third commit on main
-+ feature-a ↕ ↑1 ↓2 ⋯ ../repo.feature-a 1b87d473 16h Add feature-a file
-+ feature-b ↕ ↑1 ↓2 ⋯ ../repo.feature-b f62940fc 16h Add feature-b file
-+ feature-c ↕ ↑1 ↓2 ⋯ ../repo.feature-c 345c7c93 16h Add feature-c file
-+ feature ↕ ↑1 ↓2 ⋯ ../repo.feature 0acf205b 1d Feature work
-
-○ Showing 5 worktrees, 4 ahead
-
------ stderr -----
diff --git a/tests/snapshots/integration__integration_tests__list__list_skips_expensive_for_stale_branches_only.snap b/tests/snapshots/integration__integration_tests__list__list_skips_expensive_for_stale_branches_only.snap
deleted file mode 100644
index 9148591c9..000000000
--- a/tests/snapshots/integration__integration_tests__list__list_skips_expensive_for_stale_branches_only.snap
+++ /dev/null
@@ -1,56 +0,0 @@
----
-source: tests/integration_tests/list.rs
-info:
- program: wt
- args:
- - list
- - "--branches"
- - "--full"
- env:
- 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_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
- GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
- GIT_TERMINAL_PROMPT: "0"
- HOME: "[TEST_HOME]"
- LANG: C
- LC_ALL: C
- MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
- NO_COLOR: ""
- OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
- PATH: "[PATH]"
- PSModulePath: ""
- RUST_LOG: warn
- SHELL: ""
- TERM: alacritty
- USERPROFILE: "[TEST_HOME]"
- WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
- WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
- WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
- WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
- WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
- WORKTRUNK_TEST_EPOCH: "1735776000"
- WORKTRUNK_TEST_NUSHELL_ENV: "0"
- WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
- WORKTRUNK_TEST_POWERSHELL_ENV: "0"
- WORKTRUNK_TEST_SKIP_EXPENSIVE_THRESHOLD: "1"
- WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
- XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
----
-success: true
-exit_code: 0
------ stdout -----
- Branch Status HEAD± main↕ main…± Remote⇅ CI Path Commit Age Message
-@ main ^⇡ ⇡2 . c3d37f26 1d Third commit on main
-+ feature-a ↕ ↑1 ↓2 ⋯ ../repo.feature-a 1b87d473 16h Add feature-a file
-+ feature-b ↕ ↑1 ↓2 ⋯ ../repo.feature-b f62940fc 16h Add feature-b file
-+ feature-c ↕ ↑1 ↓2 ⋯ ../repo.feature-c 345c7c93 16h Add feature-c file
- stale-branch /⊂ ↓2 ⋯ 05a4a45d 16h Initial commit
-
-○ Showing 4 worktrees, 1 branches, 3 ahead
-
------ stderr -----
diff --git a/tests/snapshots/integration__integration_tests__list__maximum_status_with_git_operation.snap b/tests/snapshots/integration__integration_tests__list__maximum_status_with_git_operation.snap
index 52fbf71a7..6d1e809bc 100644
--- a/tests/snapshots/integration__integration_tests__list__maximum_status_with_git_operation.snap
+++ b/tests/snapshots/integration__integration_tests__list__maximum_status_with_git_operation.snap
@@ -47,8 +47,8 @@ exit_code: 0
+ feature-a ↕ ↑1 ↓2 +1 ../repo.feature-a 1b87d473 16h Add feature-a file
+ feature-b ↕ ↑1 ↓2 +1 ../repo.feature-b f62940fc 16h Add feature-b file
+ feature-c ↕ ↑1 ↓2 +1 ../repo.feature-c 345c7c93 16h Add feature-c file
-+ feature +!?✘– 🤖 +7 ../repo.feature 27eb0ee8 1d Main conflicting changes
++ feature +!?✘✗ 🤖 +7 ↑1 ↓1 +3 -2 ../repo.feature 27eb0ee8 1d Main conflicting changes
-○ Showing 5 worktrees, 1 with changes, 3 ahead
+○ Showing 5 worktrees, 1 with changes, 4 ahead
----- stderr -----