Skip to content

2.2.8 - The worktree audit reads git refs by their full name and holds a branch's open PR

Latest

Choose a tag to compare

@chhoumann chhoumann released this 07 Nov 22:20
f344cb6

The worktree audit marks a worktree safe to prune when its HEAD is merged into the base or its branch has a PR that is not open. Three lookups could read unmerged or open work as safe.

A local ref named origin/main decided the merge check. The MERGED column ran git merge-base --is-ancestor against the base by its short name, such as origin/main, origin/master, or a -b origin/<branch>. Git resolves a short name through refs/tags/ and refs/heads/ before refs/remotes/, so a local branch or tag named origin/main won over the remote-tracking ref. In a throwaway repository with one unpushed commit on a worktree branch topic, 2.2.7 read that worktree no and review. After git branch origin/main topic, or git tag origin/main topic, it read YES and safe, with or without -b origin/main, while git merge-base --is-ancestor topic refs/remotes/origin/main said no. A clone sets origin/HEAD, and for a shadowed name git symbolic-ref --short printed remotes/origin/main, which these refs do not shadow. So the default base was exposed when origin/HEAD was missing, and -b origin/<branch> always was, as was -b upstream/main with a local ref named upstream/main. The audit now reads a base that starts with a remote's name by its refs/remotes/ name, and the same repository reads no and review. A -b that names a local ref, such as -b main, works as before. The REMOTE column made the same lookup for origin/<branch>, so a local branch named origin/topic at the worktree's HEAD read pushed for a commit that was never pushed. It now reads ahead1. REMOTE does not change the bucket.

A newer closed PR hid an older open one. The audit reads PR state once from gh pr list --state all, or from Origin's CLI when it can, and both list newest first. For each branch it took the first record, so a newer closed or merged PR for the same branch hid an older open one, as when one branch has PRs against two bases. With a stub gh on PATH that lists #12 closed and then #11 open for topic, 2.2.7 printed #12/closed and bucketed the worktree safe. The audit now takes the first record whose state is open or draft, Origin's state for a draft PR, which the bucket already holds. Without one it keeps the first record, as before. The same repository prints #11/open and hold-open-pr, through gh and through a stub Origin CLI alike.

A tag named like the branch hid its PR. The audit named each worktree's branch with git symbolic-ref --short HEAD, which prints heads/topic when a tag topic also exists. No PR record has that head, so a merged branch with an open PR read - and safe. It now strips refs/heads/ from the full name and reads #11/open and hold-open-pr.

Ethan found the first two in the JavaScript audit of Michael Denyer's pstack-claude and fixed them there in #423 and #424. This release makes the same fixes in the port's bash script, which tools/forks.json declares as a fork of Lauren's, and a review of this change found the third and the upstream/main case. Lauren's script has all three lookups, at the pin and at cursor/plugins main as of 6b03002. tests/worktree-audit.test.mjs adds seven tests. A local branch and a local tag named origin/main and upstream/main each leave unmerged work no and review, with the default base, with -b origin/main, with -b upstream/main, and with origin/HEAD set. A local branch named origin/topic leaves an unpushed commit ahead1. An older open PR from gh and an older draft PR from Origin each hold their worktree behind a newer closed PR, beside a branch whose newest PR is merged and stays safe. A tag named like a merged branch leaves its open PR holding the worktree. -b main checks against the local branch. All but the last fail on 2.2.7.

The audit still asks for at most 1,000 PRs, so an open PR older than the author's 1,000 newest in the repository goes unread.

This release syncs nothing from Lauren's pstack, so all three components stay pinned at cursor/plugins c742dd6. At that pin each component's dry run reports no undeclared fork and no substitution that matches nothing. Neither hooks file changes. This is a patch release, and no setting or workflow has to change. On Codex, run npx -y github:chhoumann/t3-pstack update after it, as after every release.