Skip to content

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

docs(picker): warn off the cached merge-base path in compute_log_preview (#2659)

Maximilian Roos8ef887547ee0
diff --git a/src/commands/picker/items.rs b/src/commands/picker/items.rs
index eb50eabc4..4be6369ad 100644
--- a/src/commands/picker/items.rs
+++ b/src/commands/picker/items.rs
@@ -503,6 +503,21 @@ impl WorktreeSkimItem {
// dim/bright split tracks main's current position. See the cache
// entry docstring for why we keep this off the SHA-keyed disk cache.
//
+ // Don't pre-resolve `default_branch` to a SHA via
+ // `Repository::default_branch_sha` here. That accessor is a
+ // snapshot of the local-branch inventory at first scan (see its
+ // docstring) — feeding the snapshot into a merge-base call would
+ // freeze the dim/bright styling at the SHA main pointed at when
+ // the picker started, instead of the current SHA. The
+ // `log_cache_dim_split_tracks_main_advance` test pins this
+ // contract.
+ //
+ // (`Repository::merge_base` is correctness-safe — it re-resolves
+ // ref names through an uncached `git rev-parse` before hitting
+ // its SHA-keyed cache — but it'd cost an extra subprocess per
+ // render on cache miss, with no win since each item's head is
+ // unique.)
+ //
// Error handling note: this code runs in an interactive preview
// pane. Silent fallbacks beat disruptive errors during navigation;
// the preview is supplementary, users can still select worktrees