threads / bug / 35345

Fwd: Possible bug report: `git commit -ammend`

Subject: Fwd: Possible bug report: `git commit -ammend`

## tl;dr

4 messages between Nov 15, 2013 and Nov 16, 2013.

replies: 3people: 4as markdown or json

rhys evans· Nov 15, 2013, 15:44 UTC · lore

I ran `git commit -ammend` on a repo where 1 out of 3 files changed were staged for commit.

I would've expected an error to be thrown due to the double typo but instead it committed all 3 files with the message 'mend'.

So it looks like it interpreted it as `git commit -a -m 'mend'`.
I'm running git 1.8.3.4 using iTerm 1.0.0 on OSX 10.9.
-- 
------------------------------
This email was sent by a company owned by Pearson plc, registered office at 
80 Strand, London WC2R 0RL.  Registered in England and Wales with company 
number 53723.
Matthieu Moy· Nov 15, 2013, 15:54 UTC · re: rhys evans · lore

Re: Fwd: Possible bug report: `git commit -ammend`

rhys evans <rhys.evans@ft.com> writes:
Show 7 quoted lines
> I ran `git commit -ammend` on a repo where 1 out of 3 files changed
> were staged for commit.
>
> I would've expected an error to be thrown due to the double typo but
> instead it committed all 3 files with the message 'mend'.
>
> So it looks like it interpreted it as `git commit -a -m 'mend'`.

Yes. This is a rather widespread convention (e.g. rm -fr == rm -r -f). Git does a special-case for -amend to avoid confusion:

  $ git commit -amend
  error: did you mean `--amend` (with two dashes ?)
But it did not special-case the double-typo.
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Duy Nguyen· Nov 16, 2013, 03:28 UTC · re: Matthieu Moy · lore

Re: Fwd: Possible bug report: `git commit -ammend`

On Fri, Nov 15, 2013 at 10:54 PM, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:

Show 17 quoted lines
> rhys evans <rhys.evans@ft.com> writes:
>
>> I ran `git commit -ammend` on a repo where 1 out of 3 files changed
>> were staged for commit.
>>
>> I would've expected an error to be thrown due to the double typo but
>> instead it committed all 3 files with the message 'mend'.
>>
>> So it looks like it interpreted it as `git commit -a -m 'mend'`.
>
> Yes. This is a rather widespread convention (e.g. rm -fr == rm -r -f).
> Git does a special-case for -amend to avoid confusion:
>
>   $ git commit -amend
>   error: did you mean `--amend` (with two dashes ?)
>
> But it did not special-case the double-typo.

"-m" taking a string without a space or '=' increases the risk of this typo. If it does require '=' or ' ' after -m then -ammend is more likely to be rejected. Anybody know why we should support -mabc, besides convenient?

-- 
Duy
Jeff King· Nov 16, 2013, 04:02 UTC · re: Duy Nguyen · lore

Re: Fwd: Possible bug report: `git commit -ammend`

On Sat, Nov 16, 2013 at 10:28:36AM +0700, Duy Nguyen wrote:
Show 12 quoted lines
> > Yes. This is a rather widespread convention (e.g. rm -fr == rm -r -f).
> > Git does a special-case for -amend to avoid confusion:
> >
> >   $ git commit -amend
> >   error: did you mean `--amend` (with two dashes ?)
> >
> > But it did not special-case the double-typo.
> 
> "-m" taking a string without a space or '=' increases the risk of this
> typo. If it does require '=' or ' ' after -m then -ammend is more
> likely to be rejected. Anybody know why we should support -mabc,
> besides convenient?

For flags with optional arguments, "-m abc" would not work (we do not know if "abc" is the argument or the next flag). An example of such a flag is "git status -uall".

We could disallow it for mandatory options, but that would create an inconsistency in the option parsing.

Other than that, I think it is mostly convenience and compatibility with other option-parsing systems.

-Peff

← back to recent threads