Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Scope the branch-inventory staleness contract to membership (#3988)
Maximilian Roos7a3ad6bb3df0
diff --git a/src/git/repository/branches.rs b/src/git/repository/branches.rsindex 3fd1c204e..d744fb6d2 100644--- a/src/git/repository/branches.rs+++ b/src/git/repository/branches.rs@@ -112,7 +112,10 @@ impl Repository {/// needs a current SHA for a ref must resolve through a `RefSnapshot`/// captured at the moment of read, not through this inventory. The/// inventory itself is used for branch listing and upstream-tracking- /// metadata, both of which are stable for the duration of a command.+ /// metadata, stable for the duration of a command that runs no hook.+ /// A hook runs inside the command, so one that touches refs leaves the+ /// rest of the inventory stale too — which branches are in it, and where+ /// each one's upstream points.pub fn local_branches(&self) -> anyhow::Result<&[LocalBranch]> {Ok(self.local_branch_inventory()?.entries())}diff --git a/src/git/repository/mod.rs b/src/git/repository/mod.rsindex 4b2960bd8..e4e8f5738 100644--- a/src/git/repository/mod.rs+++ b/src/git/repository/mod.rs@@ -322,8 +322,8 @@ pub(super) struct RepoCache {/// **The `commit_sha` field on each entry is a snapshot at scan time.**/// Code that needs a current SHA must resolve through a [`RefSnapshot`]/// captured at the moment the read happens — not through this inventory.- /// The inventory is used for branch-name listing and upstream-tracking- /// metadata, both of which are stable for the duration of a command.+ /// Everything else the inventory holds goes stale the same way once the+ /// command runs a hook; [`Repository::local_branches`] owns that contract.pub(super) local_branches: OnceCell<branches::LocalBranchInventory>,/// Remote-tracking branch inventory: one `git for-each-ref refs/remotes/`/// scan, cached for the lifetime of the repository. Sorted by most recent