Subject: Re: [PATCH 3/8] apply: fix adding new files on i-t-a entries

From: Junio C Hamano <[email-masked]>
Date: Tue, 25 Aug 2015 10:01:06 -0700

Nguyễn Thái Ngọc Duy  <[email-masked]> writes:

> Applying a patch that adds a file when that file is registered with "git
> add -N" will fail with message "already exists in index" because
> git-apply checks, sees those i-t-a entries and aborts. git-apply does
> not realize those are for bookkeeping only, they do not really exist in
> the index. This patch tightens the "exists in index" check, ignoring
> i-t-a entries.

Suppose that you came up with some contents to register at path F in
your working tree, told Git about your intention with "add -N F",
and then tried to apply a patch that wants to _create_ F:

Without this patch, we would say "F already exists so a patch to
create is incompatible with our current state".

With this patch, we do not say that, but instead we'll hopefully
trigger "does it exist in the working tree" check, unless you are
running under "--cached".

Which means that this change will not lead to data loss in the
"untracked" file F in the working tree that was merely added to the
index with i-t-a bit.

As you did not say the equivalent of the last paragraph above in the
log message, my knee-jerk reaction was "why could this possibly be a
good idea?"

Please try again with a better log message.

Thanks.