git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git-branch -m interprets first argument differently when two are supplied

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Feb 14, 2008, 16:30 UTC
Message-ID
<47B46C8E.5030905@nrlssc.navy.mil>
In-Reply-To
<47B3EFC4.1020808@viscovery.net>
Johannes Sixt wrote:
Show 12 quoted lines
> Brandon Casey schrieb:
>> The first non-option argument is interpreted differently depending on
>> whether one argument or two arguments have been supplied.
>>
>> 	git-branch -m [<oldbranch>] <newbranch>
>>
>> Has anyone considered whether this is inconsistent with how other
>> commands operate?
> 
> Funny, I fell into this trap just yesterday and accidentally renamed
> my master branch to something else. IMO git-branch -m should take two
> arguments. Full stop.

Actually, I think the single argument case is unambiguous and I would rather not give it up.

It's the two argument case that both expects its arguments in a different order than other commands _and_ is dangerous in the case of -M.

I was thinking that -M should print a message describing what it is going to do, and prompt the user for confirmation. A new option could be added to suppress this behavior like -q. Or we could reuse -f, but see below.

While I'm looking at git-branch, I think the capital forms are unnecessary. We have a -f (force) option, so I think it makes more sense to deprecate the captital forms(not remove them), and interpret -f along with -m or -d to provide the same functionality. Again, with the behavior described above for confirmation with something like -q.

Oh, and I wouldn't mind switching the arguments around after we have the confirmation implemented. :)

-brandon
Previous: Johannes SixtNext: Johannes Schindelin
Message 3 of 6 in “git-branch -m interprets first argument differently when two are supplied”
  1. Brandon CaseyFeb 13, 2008
  2. Johannes SixtFeb 14, 2008
  3. Brandon CaseyFeb 14, 2008
  4. Johannes SchindelinFeb 14, 2008
  5. Brandon CaseyFeb 14, 2008
  6. Johannes SchindelinFeb 14, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.