feat: add madtea switch and madt_switch to move to an existing branch #894

Merged
hexajon merged 17 commits from issue-867-switch-on-main into main 2026-10-24 00:42:15 +00:00
Owner

Summary

madtea had no surface that moves HEAD to a branch that already exists, so a caller that drives git through madtea fell back to raw git switch to return to the default branch. This adds madtea switch <branch> and madt_switch.

  • It moves HEAD to an existing local branch, the default branch included, and reports the branch and the new short HEAD sha.
  • It never creates a branch. A name that only a remote-tracking ref holds, a tag, or a commit is refused with git's own words, and the refusal names the exact madt_branch_create or madtea branch -b call.
  • Uncommitted changes that do not conflict carry onto the target branch, as in git. A switch that would overwrite a change refuses with git's message.
  • A switch to the branch that is already checked out succeeds and says that HEAD did not move.
  • A foreign primary checkout is refused, and so is a dirty linked worktree of a foreign repo. The decision records for foreign repos now name the switch.
  • A branch that another worktree holds is refused with steps that never act on that worktree.

Closes #867

## Summary madtea had no surface that moves HEAD to a branch that already exists, so a caller that drives git through madtea fell back to raw `git switch` to return to the default branch. This adds `madtea switch <branch>` and `madt_switch`. - It moves HEAD to an existing local branch, the default branch included, and reports the branch and the new short HEAD sha. - It never creates a branch. A name that only a remote-tracking ref holds, a tag, or a commit is refused with git's own words, and the refusal names the exact `madt_branch_create` or `madtea branch -b` call. - Uncommitted changes that do not conflict carry onto the target branch, as in git. A switch that would overwrite a change refuses with git's message. - A switch to the branch that is already checked out succeeds and says that HEAD did not move. - A foreign primary checkout is refused, and so is a dirty linked worktree of a foreign repo. The decision records for foreign repos now name the switch. - A branch that another worktree holds is refused with steps that never act on that worktree. Closes #867
fix: end the switch refusals without a period, as Go error strings do
Some checks failed
ci / gate (pull_request) Has been cancelled
drift / govulncheck (pull_request) Has been cancelled
drift / surface-diff (pull_request) Has been cancelled
drift / forgejo-smoke (pull_request) Has been cancelled
ci / gate (push) Has been cancelled
drift / govulncheck (push) Has been cancelled
drift / surface-diff (push) Has been cancelled
drift / forgejo-smoke (push) Has been cancelled
ed12d05b8f
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sixfold-space/madtea!894
No description provided.