Repository navigation
worktree-audit: read git refs by full name and hold a branch's open PR (2.2.8) - #70
Merged
Merged
Conversation
…ad as safe A local branch or tag named origin/main makes unmerged work read MERGED and safe, and one named origin/<branch> makes an unpushed commit read pushed. A newer closed or merged PR listed before an older open one buckets the worktree safe. These tests fail on 2.2.7.
… open PR A local branch or tag named origin/main won git's shorthand lookup over refs/remotes/origin/main, so the MERGED check could read unmerged work as merged and safe. An origin/* base and origin/<branch> are now read by their refs/remotes/ names. A -b that names a local ref works as before. gh and Origin list a branch's PRs newest first, and the audit took the first, so a newer closed or merged PR hid an older open one and the worktree read safe. The audit now takes the first open or draft record, else the first. Same fixes as Michael Denyer's pstack-claude #423 and #424.
… the branch A local ref named upstream/main still decides -b upstream/main, and an origin/HEAD that points at refs/remotes/upstream/main reaches the same short name. A tag named like the worktree's branch makes symbolic-ref --short print heads/<branch>, so no PR matches and an open PR reads safe.
A local ref named upstream/main still decided -b upstream/main. A base that starts with a configured remote's name is now read under refs/remotes/. The branch name comes from symbolic-ref without --short, which prints heads/<name> when a tag shares the name, so a tag no longer hides the branch's PR.
chhoumann
marked this pull request as ready for review
November 7, 2026 22:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The worktree audit should never call a worktree safe to prune while it holds unmerged work or an open PR. Two lookups let it. A local branch or tag named
origin/mainwon git's short-name lookup overrefs/remotes/origin/main, so theMERGEDcheck read unmerged work as merged. Andghlists a branch's PRs newest first, so a newer closed or merged PR hid an older open one. Both were found and fixed in Michael Denyer's pstack-claude, #423 and #424, in its JavaScript audit. This makes the same fixes in our bash fork.What changed
worktree-audit.shreads a base that starts with a remote's name, andorigin/<branch>in theREMOTEcolumn, by theirrefs/remotes/names. A-bthat names a local ref, such as-b main, works as before. The branch name comes from the fullrefs/heads/ref, so a tag with the same name no longer hides the branch's PR.openordraft, else the first record, on both theghand the Origin path.tests/worktree-audit.test.mjs, six of which fail onmain. Release 2.2.8 with the fork'swhy,CHANGES.md, the stamped manifests, and the README's tag example.Scope
-b upstream/maincase and the tag named like the branch. Both are the same short-name lookup, so they are fixed here. TheREMOTEfix does not change the bucket.Verification
topic. Onmain,git branch origin/main topicorgit tag origin/main topicturns the row fromno reviewintoYES safe, also with-b origin/main. With this branch it staysno review. A real merge with a staleorigin/maintag still readsYES safe.ghonPATHlisting#12closed then#11open fortopic, and the same records from a stub Origin CLI. Onmainthe row reads#12/closed safe. With this branch it reads#11/open hold-open-pron both paths.bun tools/generate.mjs --check,GIT_CONFIG_GLOBAL=/dev/null bun test tests/ --timeout 30000(561 pass, 0 fail), the sync dry-run for each component atc742dd6, shellcheck on the script, and markdownlint on the changed Markdown all pass.codex/gpt-6-astraatreasoningEffort=xhighfound three high issues. Two are fixed above with tests that failed first. The third is the PR limit in Scope.Note
Low Risk
Bash audit tooling only; changes make prune recommendations more conservative and are covered by new tests, with no auth or runtime workflow impact.
Overview
Release 2.2.8 fixes three cases where
worktree-audit.shcould mark a worktree safe while it still had unmerged work or an open PR.The merge and remote columns now resolve bases like
origin/mainandorigin/<branch>through explicitrefs/remotes/names so a local branch or tag with the same shorthand no longer wins over the remote-tracking ref. Branch names for PR lookup come from the fullrefs/heads/name so a tag with the same name cannot blank the PR column. When PRs are listed newest-first, the script picks the first open or draft record for the branch instead of the newest row overall.Seven tests in
tests/worktree-audit.test.mjscover these scenarios; version stamps and changelog/README examples move to 2.2.8.Reviewed by Cursor Bugbot for commit e5ad5c7. Bugbot is set up for automated code reviews on this repo. Configure here.