Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
docs(cache): list head_sha() in the not-cached set (#2545)
Maximilian Roos7e80656ab139
diff --git a/CLAUDE.md b/CLAUDE.mdindex e28305471..ce0ac4d1b 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -460,6 +460,7 @@ Most data is stable for the duration of a command. `Repository` caches read-only**Not cached (changes during command execution):**- `is_dirty()` — changes as we stage/commit+- `head_sha()` — HEAD moves on commit/rebase/merge; a stale SHA would surface in `{{ commit }}` for hooks that fire after the move`list_worktrees()` *is* cached, even though `wt switch --create` / `wt remove` mutate the underlying list. The invariant is that mutating paths must not read the list through the same `Repository` after their own mutation: either read once up front and thread the slice through, or call `Repository::at(...)` again to get a fresh cache before any post-mutation probe.diff --git a/src/git/repository/mod.rs b/src/git/repository/mod.rsindex 89e2b3bfd..47f23d125 100644--- a/src/git/repository/mod.rs+++ b/src/git/repository/mod.rs@@ -48,6 +48,8 @@//! **What is NOT cached.** Values that change during command execution are intentionally//! excluded://! - `WorkingTree::is_dirty()` — changes as we stage and commit+//! - `WorkingTree::head_sha()` — HEAD moves on commit, rebase, or merge; a stale SHA+//! would surface in template variables (`{{ commit }}`) for hooks that fire after the move//!//! [`Repository::list_worktrees`] is cached despite mutating commands adding or//! removing worktrees. The cache is safe because no caller reads the list