Files
tty7/crates
l0ng-ai 65094a415b fix(git): a branch name that looks like an option is still a name
`GitOp::CreateBranch` with checkout: false builds `git branch <name>`,
which the commit graph's "branch at this commit" uses — naming a place
without moving to it. That puts a name the user typed where git parses
options.

Measured against real git rather than reasoned about:

  git branch --list main    lists branches, exits 0, creates nothing
  git branch -- --list main fatal: '--list' is not a valid branch name

An exit of 0 is what `run_op` reads as success, so the first line is a
panel reporting a branch that does not exist. `-D` and `-foo` are merely
confusing by comparison; `--help` opens the man page.

So `--` goes ahead of the name on both `branch` forms, create and delete.
Not on `checkout -b`, and that asymmetry is the point: `-b` takes the next
argument as its value whatever it looks like, so that form already
answers "not a valid branch name", and for `checkout` a `--` means
"paths follow" — a different instruction. `CheckoutBranch` already carried
a trailing `--` for its own version of this, so the class was known here;
`branch` was the form that missed it.

My first version of the test searched the argv for the name, which finds
the force flag when the two look alike — `["branch", "-D", "--", "-D"]`
is correct and it called that broken. It asserts what follows the
separator instead.
2026-08-23 20:44:27 +08:00
..