threads / bug / 39458

[BUG] potential error in parsing git checkout options?

Subject: [BUG] potential error in parsing git checkout options?

## tl;dr

2 messages between May 29, 2015 and May 29, 2015.

replies: 1people: 2as markdown or json

Guillaume Pages· May 29, 2015, 10:30 UTC · lore
Git version : 2.4.1.652.g8fd8657 

When we run git checkout -babar, we would expect an error message like "unknown switch 'a' " and we get "Switched to a new branch 'abar'". We are not sure since we don't entirely understand the syntax -b <branch> which is shown in the documentation, but as average users, we found it a bit surprising.

Guillaume Pagès
Matthieu Moy· May 29, 2015, 12:23 UTC · re: Guillaume Pages · lore

Re: [BUG] potential error in parsing git checkout options?

Guillaume Pages <guillaume.pages@ensimag.grenoble-inp.fr> writes:
> Git version : 2.4.1.652.g8fd8657 
>
> When we run git checkout -babar, we would expect an error message like 
> "unknown switch 'a' " and we get "Switched to a new branch 'abar'".

Yes, the option-parser accepts sticked form (-bbranch) and unsticked (-b branch). This is the convention with most Unix commands (try "grep -e foo" Vs "grep -efoo").

It gets more confusing for "git -amend" Vs "git --amend", which got a special-case to avoid confusion (strictly speaking, it should have been equivalent to "git commit -a -m end").

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

← back to recent threads