feat(hooks): steer a plain git switch to madt_switch #868

Open
opened 2026-10-21 22:10:58 +00:00 by hexajon · 0 comments
Owner

The gap

The local-git hook (hooks/scripts/check-git-local.sh) says nothing about a plain same-repo git switch <branch> or git checkout <branch>. It denies only the create forms (switch -c, checkout -b) and a switch on a foreign primary checkout. Two of its deny texts also say that a switch to an existing branch is "NOT affected".

When madt_switch lands (#867), an agent that runs raw git switch gets no pointer to it. A switch moves HEAD, so it is a mutation, and the hook steers mutations to the madt_* tools by deny.

What I want

  • The hook denies a plain same-repo git switch <branch> and git checkout <branch>, and steers to madt_switch, the same way it treats a branch create.
  • The two deny texts that say a switch to an existing branch is "NOT affected" name madt_switch for that case.
  • The deny follows the guard-text rules: it names the exact replacement call, and for a compound command it states that none of it ran.

Acceptance criteria

  • A plain same-repo git switch <branch> and git checkout <branch> are denied, and the text names madt_switch.
  • git checkout -- <path> and the create forms keep their current behaviour.
  • The two "NOT affected" deny texts name madt_switch.
  • The hook tests in hooks/tests/ cover each form.

Depends on #867.

## The gap The local-git hook (`hooks/scripts/check-git-local.sh`) says nothing about a plain same-repo `git switch <branch>` or `git checkout <branch>`. It denies only the create forms (`switch -c`, `checkout -b`) and a switch on a foreign primary checkout. Two of its deny texts also say that a switch to an existing branch is "NOT affected". When `madt_switch` lands (#867), an agent that runs raw `git switch` gets no pointer to it. A switch moves HEAD, so it is a mutation, and the hook steers mutations to the madt_* tools by deny. ## What I want - The hook denies a plain same-repo `git switch <branch>` and `git checkout <branch>`, and steers to `madt_switch`, the same way it treats a branch create. - The two deny texts that say a switch to an existing branch is "NOT affected" name `madt_switch` for that case. - The deny follows the guard-text rules: it names the exact replacement call, and for a compound command it states that none of it ran. ## Acceptance criteria - [ ] A plain same-repo `git switch <branch>` and `git checkout <branch>` are denied, and the text names `madt_switch`. - [ ] `git checkout -- <path>` and the create forms keep their current behaviour. - [ ] The two "NOT affected" deny texts name `madt_switch`. - [ ] The hook tests in `hooks/tests/` cover each form. Depends on #867.
Sign in to join this conversation.
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.

Reference
sixfold-space/madtea#868
No description provided.