# git add --intent-to-add silently creates empty commits

3 messages from 2016-09-15 to 2016-09-19. Participants: Aviv Eyal, Junio C Hamano, Duy Nguyen.
Thread: https://gitlist.dev/t/44090

## Aviv Eyal, 2016-09-15 05:01

Subject: git add --intent-to-add silently creates empty commits
Message-ID: <CAGHT48L2s_nf-oSGPKrOB7uo5UAkCScNh+Ju5xH1dE5DFVnHwA@mail.gmail.com>
URL: https://gitlist.dev/e/CAGHT48L2s_nf-oSGPKrOB7uo5UAkCScNh%2BJu5xH1dE5DFVnHwA%40mail.gmail.com

```
Hello,

I think this is an unintended behavior, but I might be wrong:

Using `git add -N` allows creating of empty commits:


git init test && cd test
echo text > file
git add --intent-to-add file
git commit -m 'Empty commit'
echo $?                                    # prints 0
git log -1 -p --format='' HEAD | wc -l     # prints 0
git status -s                              # prints `AM file`


I'd expect `git commit` to error out instead of producing an empty commit.

I've seen this with git 2.8.1 and 2.10.0.129.g35f6318

Thanks,
Aviv

```

## Junio C Hamano, 2016-09-15 17:48

Subject: Re: git add --intent-to-add silently creates empty commits
Message-ID: <xmqq1t0loxz4.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqq1t0loxz4.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <CAGHT48L2s_nf-oSGPKrOB7uo5UAkCScNh+Ju5xH1dE5DFVnHwA@mail.gmail.com>

```
Aviv Eyal <avivey@gmail.com> writes:

> Using `git add -N` allows creating of empty commits:
>
> git init test && cd test
> echo text > file
> git add --intent-to-add file
> git commit -m 'Empty commit'
> echo $?                                    # prints 0
> ...
> I'd expect `git commit` to error out instead of producing an empty commit.
>
> I've seen this with git 2.8.1 and 2.10.0.129.g35f6318

I think I've seen this reported some time ago.

https://public-inbox.org/git/%3CCACsJy8A8-RgpYxYsJBaLrMia7D3DfQPr4cxASNsaLyCnmgm3ZQ@mail.gmail.com%3E/

I do not offhand recall what happend to the topic after that.

```

## Duy Nguyen, 2016-09-19 13:16

Subject: Re: git add --intent-to-add silently creates empty commits
Message-ID: <CACsJy8AGYPfX9936QJyKU8paxbt+SABMbeCWnpgVvODFr7v4LA@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8AGYPfX9936QJyKU8paxbt%2BSABMbeCWnpgVvODFr7v4LA%40mail.gmail.com
In-Reply-To: <xmqq1t0loxz4.fsf@gitster.mtv.corp.google.com>

```
On Fri, Sep 16, 2016 at 12:48 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Aviv Eyal <avivey@gmail.com> writes:
>
>> Using `git add -N` allows creating of empty commits:
>>
>> git init test && cd test
>> echo text > file
>> git add --intent-to-add file
>> git commit -m 'Empty commit'
>> echo $?                                    # prints 0
>> ...
>> I'd expect `git commit` to error out instead of producing an empty commit.
>>
>> I've seen this with git 2.8.1 and 2.10.0.129.g35f6318
>
> I think I've seen this reported some time ago.
>
> https://public-inbox.org/git/%3CCACsJy8A8-RgpYxYsJBaLrMia7D3DfQPr4cxASNsaLyCnmgm3ZQ@mail.gmail.com%3E/
>
> I do not offhand recall what happend to the topic after that.

Yeah. I'm a bit behind, no, I'm waaaay behind my git backlog. This
definitely gets a rise-up, together with the multiworktree bug fix in
git-init.
-- 
Duy

```
