Carry patches as revision refs instead of branches #2
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Spec: docs/superpowers/specs/2026-08-09-patch-revision-refs-design.md
Move each revision to an immutable ref in the patch's own namespace:
Patches then travel under the refspecs sync already uses (sync.rs:230-233), so contributing needs no 'git push' of a branch and no write access to refs/heads/*.
Fixes two live defects:
Also removes PatchState.base_commit in favour of a per-revision base; see the follow-up issue on interdiff.
Migrated from git-collab issue
c65ac0e2646c3e7aa884672f35d15dcfa16f41a3.Original author: a73x dev@a73x.sh.
Close reason: Implemented by patch
659f0350, mergedDemonstrated live while merging this session's five agent patches.
Patch
9fada820recorded revision 1 at commit91b337da. The branch was rebased onto main and fast-forwarded - an entirely ordinary merge - and afterwards:The commit revision 1 points at is reachable from zero refs. It survives only until the next 'git gc', at which point 'patch log
9fada820' and any interdiff against r1 break permanently, with no warning and no way to recover.This is exactly what the write-once refs/collab/patches//r/ layout prevents, and it needs no unusual workflow to trigger - just rebase-and-fast-forward, which is the normal way to keep a linear history.
Confirmed by demonstration: today's branch-tip auto-detection is a silent side effect of unrelated writes, not of reads.
patch comment and patch review both call auto_detect_revision() (src/patch.rs, from comment() ~line 268 and review() ~line 332), which compares the branch's current tip to the last recorded revision and, if they differ, appends a PatchRevision event BEFORE recording the comment or review - with no indication to the user. Reads (patch show, patch log) never trigger it, since state is replayed from recorded events only. So rebasing a patch's branch and then looking at it shows nothing new.
The next unrelated write then manufactures a revision. Reproduced: amend a patch branch's tip, confirm patch log still shows only r1, then run 'patch comment' - the CLI prints 'Comment added.' and nothing else, but patch log now shows r2, timestamped at the comment rather than the code change, with an empty body (0 files changed, +0 -0). Repeating with 'patch review' produced r3 the same way.
patch revise does not go through this helper - it has its own explicit tip check and errors with 'no changes since revision N', which is the intended behaviour.
Since the explicit patch revise command already exists, the auto-detection path is redundant and actively misleading: it records history the user did not ask for, at a time unrelated to the actual code change. Another argument for the explicit-only model in this design.