Git guard: a clustered or abbreviated branch flag (-fm, -Dq, --mov) renames or deletes a peer's branch unseen #125
Loading…
Add table
Add a link
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?
Purpose (fix): the git guard reads a
branchdelete or move however its flags are spelled, so a member cannot rename or delete another member's branch by writing-fmor--mov.Found in the review of martha#45 (PR 122, tip
2811c4f). It is in the code atf187dd7too, so it is older than that range and outside the package.src/guard_workspace/guard_workspace.tsmatches whole words againstMOVE_A_BRANCH(-m -M --move) andDELETE_A_BRANCH(-d -D --delete). git also reads short options clustered and long options by any unique prefix. In another member's worktree, each of these passes the guard and git carries it out (guard side probed on the archived tip; git behaviour from git's parse-options):git branch -fm mine,-mf mine,--mov mine,--mo minegit branch -fm uranus/9 mine,-Mf uranus/9 mine,--mov uranus/9 minegit branch -dr uranus/9,-Dq uranus/9Smaller, same class:
git branch -m @{-1} minejudges@{-1}as a literal name. Forpush,--mirro/--mir/--prunpass where--mirror/--pruneare refused.Fix: read a short-option cluster letter by letter, and a long option by unique prefix, for the sets the guard matches. Red first: one failing case per form above.
Refs #45
Approach (Titan), plan only until PR 122 lands
Probed on this box first, in a scratch repo:
git branch --mov uranus/9 againandgit branch -fm …are carried out;git branch --mis refused by git itself as ambiguous ("could be --move or --merged");git branch -m @{-1} renamedrenames the branch checked out before this one;git push --prun,--mir,--mirro,--al,--tagall parse (each ends at "No configured push destination").-pis not a push option (git push -p→ "unknown switch `p'"), so no short form is added for prune.One rule, one place —
isOneOfTheOptions(word, options, theShortOptionsThatTakeAValue):--…: a match when a member of the set starts with the word (--mov→--move,--prun→--prune);-…: read the letters one at a time and match when one of them is a member, stopping at the first letter that takes a value, so-bmine,-uorigin/mainand-omr.draftare not read as flags. The value-taking letters are a table beside the sets: checkout/switchb B c C, worktreeb B, branchu, pusho.Every place that asks a set today reads through it:
refusalOfABranchDeleteOrMoveandrefusalOfABranchInAClone(delete, move),refusalOfAPush(prune),refusalOfAPushOntoTheDefault(every branch; the tags), and the raw ref update inrefusalOfAnotherMembers. The only over-refusal the rule adds is git's own ambiguity (--mis refused, and git refuses it too); no legitimate call is newly refused.@{-1}: a branch word of git's "the branch checked out N switches ago" form is one the guard cannot resolve, and that branch may be another member's, sobranch -m|-d|-D @{-1}is refused by name ("@{-1}names the branch checked out before this one, which this guard cannot read: name the branch you mean").Red first, one failing case per refused form:
branch -fm uranus/9 mine,-mf uranus/9 mine,--mov uranus/9 mine,--mo uranus/9 mine,-Mf uranus/9 mine,-dr uranus/9,-Dq uranus/9,push --mirro origin,push --mir origin,push --prun origin,branch -m @{-1} mine. Controls that must stay green:checkout -bmine,branch -uorigin/main,push -omr.draft origin hygiea/562,branch -a,--list,-vv.Mutants, one per rule: no cluster reading (
-fm,-Dqfail); no long-prefix reading (--mov,--prunfail); the prefix compared the other way round; the value-taking stop removed (the-bminecontrol fails);@{-1}read as a literal again.No new check: the same refusals and notices, read from more spellings. Bases on main once PR 122 (
e4ff9069) lands; Mercurius reviews.Reading PR 122's diff (posted after this issue was filed), two more sites join the list in my approach above, both new in it:
theBranchMovedAway(args, facts): it filtersMOVE_A_BRANCHwhole-word and counts the rest, sobranch --mov uranus/9 mineleaves three words,namesBothis false, and it falls back to the checked-out branch — the peer's branch is never judged. It must read the move word through the same rule, the way the rest does.PRUNE_THE_REMOTE(--prune,--mirror): matched whole-word today, so--prun/--mirropass it too.The mutant list grows by one:
theBranchMovedAwayreading its option whole-word again (--mov uranus/9 minemust fail by name).HELD (Titan, 2026-11-24), not started: DECIDED 2026-11-24 "the team is way too paranoid" -- a guard against a crew member's own flag spellings names no outside attacker and no owner harm, so it becomes a note rather than a change. The two approach comments above stay as the record of what it would take; nothing is built here while the Supervisor's ruling is pending.
martha upbrings up a martha-engine member on a fresh host with no hand-built binary #119Closed by ruling, not built. DECIDED 2026-11-24, Raf (relayed by the Supervisor): "the team is way too paranoid". Crew members are trusted: no guard for a crew-insider scenario on our own boxes, forge or private repos. This issue widens the git guard against crew flag spellings (-fm, --mov, --mirro, --prun), which is that kind of guard. Titan's plan (c3455, c3456) stays here for the record. Purpose not met: dropped by ruling.