# [BUG] git commit --allow-empty-message -m '' fails

4 messages from 2015-05-01 to 2015-05-02. Participants: Josh Hagins, Jeff King.
Thread: https://gitlist.dev/t/39217

## Josh Hagins, 2015-05-01 23:31

Subject: [BUG] git commit --allow-empty-message -m '' fails
Message-ID: <CANuW5x0eKVAToG76rJr6+n-Fdg7E5c8mHb8NvnQUT2PBzxjjPQ@mail.gmail.com>
URL: https://gitlist.dev/e/CANuW5x0eKVAToG76rJr6%2Bn-Fdg7E5c8mHb8NvnQUT2PBzxjjPQ%40mail.gmail.com

```
When passed the `--allow-empty-message` flag with no `-m`, `git
commit` will open the editor and allow you to exit with an empty
message, as expected.

However, when passed `-m ''` in addition to `--allow-empty-message`,
the commit fails. Example below:

    $ git commit -a --allow-empty-message -m ''
    error: switch `m' requires a value
    usage: git commit [<options>] [--] <pathspec>...
    ...

Shouldn't the `-m` switch know whether the `--allow-empty-message`
flag has been passed?

Thanks,
Josh

```

## Jeff King, 2015-05-02 01:06

Subject: Re: [BUG] git commit --allow-empty-message -m '' fails
Message-ID: <20150502010605.GA5634@peff.net>
URL: https://gitlist.dev/e/20150502010605.GA5634%40peff.net
In-Reply-To: <CANuW5x0eKVAToG76rJr6+n-Fdg7E5c8mHb8NvnQUT2PBzxjjPQ@mail.gmail.com>

```
On Fri, May 01, 2015 at 07:31:08PM -0400, Josh Hagins wrote:

> When passed the `--allow-empty-message` flag with no `-m`, `git
> commit` will open the editor and allow you to exit with an empty
> message, as expected.
> 
> However, when passed `-m ''` in addition to `--allow-empty-message`,
> the commit fails. Example below:
> 
>     $ git commit -a --allow-empty-message -m ''
>     error: switch `m' requires a value
>     usage: git commit [<options>] [--] <pathspec>...
>     ...
> 
> Shouldn't the `-m` switch know whether the `--allow-empty-message`
> flag has been passed?

It should. It works here for me:

  $ git commit --allow-empty --allow-empty-message -m ''
  [master 2957ea1]

The message you're seeing comes from the option-parser, which thinks
there isn't any argument to `-m` at all. I can get the same result like:

  $ git commit --allow-empty --allow-empty-message -m
  error: switch `m' requires a value
  ...

Are you running the command inside another bit of shell script that
might be eating the empty argument (e.g., eval-ing it inside of another
set of single quotes or something like that)?

-Peff

```

## Jeff King, 2015-05-02 02:29

Subject: Re: [BUG] git commit --allow-empty-message -m '' fails
Message-ID: <20150502022924.GA587@peff.net>
URL: https://gitlist.dev/e/20150502022924.GA587%40peff.net
In-Reply-To: <CANuW5x1jeAY4KrOQez30mNp864abaYFyDDrdfM=NHCSosTSzkQ@mail.gmail.com>

```
On Sat, May 02, 2015 at 01:25:45AM +0000, Josh Hagins wrote:

> I have git aliased to hub, which must do some preprocessing before handing
> the command off to git.
> 
> That's likely the culprit, but I'm using iTerm as my terminal emulator,
> which might be doing something tricky, but I doubt it. I'll open an issue
> on hub's GitHub repo and see what I can find out.

Ah, yeah, it's probably hub. Looks like it's fixed already there:

  https://github.com/github/hub/pull/727

-Peff

```

## Josh Hagins, 2015-05-02 02:44

Subject: Re: [BUG] git commit --allow-empty-message -m '' fails
Message-ID: <CANuW5x3oHmjAk=Ju6j+sxYnVp8mSs_V6t7YHm2S9=+0GgHnkDg@mail.gmail.com>
URL: https://gitlist.dev/e/CANuW5x3oHmjAk%3DJu6j%2BsxYnVp8mSs_V6t7YHm2S9%3D%2B0GgHnkDg%40mail.gmail.com
In-Reply-To: <20150502022924.GA587@peff.net>

```
Turns out it was actually scm_breeze. It defines a git() bash function
and takes care of expanding arguments itself:

  https://github.com/ndbroadbent/scm_breeze/blob/master/lib/git/aliases.sh#L26

I'll open an issue there.

On Fri, May 1, 2015 at 10:29 PM, Jeff King <peff@peff.net> wrote:
> On Sat, May 02, 2015 at 01:25:45AM +0000, Josh Hagins wrote:
>
>> I have git aliased to hub, which must do some preprocessing before handing
>> the command off to git.
>>
>> That's likely the culprit, but I'm using iTerm as my terminal emulator,
>> which might be doing something tricky, but I doubt it. I'll open an issue
>> on hub's GitHub repo and see what I can find out.
>
> Ah, yeah, it's probably hub. Looks like it's fixed already there:
>
>   https://github.com/github/hub/pull/727
>
> -Peff



-- 
Josh Hagins
College of Engineering
Cornell University '14
(843) 847-6008

```
