threads / discuss / 44090

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

Subject: git add --intent-to-add silently creates empty commits

## tl;dr

3 messages between Sep 15, 2016 and Sep 19, 2016.

replies: 2people: 3as markdown or json

Aviv Eyal· Sep 15, 2016, 05:01 UTC · lore
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· Sep 15, 2016, 17:48 UTC · re: Aviv Eyal · lore

Re: git add --intent-to-add silently creates empty commits

Aviv Eyal <avivey@gmail.com> writes:
Show 11 quoted lines
> 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· Sep 19, 2016, 13:16 UTC · re: Junio C Hamano · lore

Re: git add --intent-to-add silently creates empty commits

On Fri, Sep 16, 2016 at 12:48 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 19 quoted lines
> 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

← back to recent threads