Subject: Re: [PATCH 0/5] fix apply --intent-to-add

From: Lidong Yan <[email-masked]>
Date: Sun, 29 Jun 2025 11:10:57 +0800

Raymond E. Pasco <[email-masked]> writes:
> The --intent-to-add (-N) flag to apply has not worked properly since its
> introduction in Git 2.19; in particular, it creates an empty index
> except for any new files in the patch, making it largely useless except
> on blank repositories.

I find the problem is that when we use 'git apply —intent-to-add’, git doesn’t
read index file then update the intent-to-add cache entry, git forgot to read
the index file and only update one intent-to-add cache entry in index file. 

> This patch series fixes it to work as expected and updates the tests
> and documentation for this flag.

I think [PATCH 2/5] actually solve the problem. [PATCH 3/5] makes 'git apply'
consistent with 'git add', which means
  git add —intent-to-add exist-in-index-file.c
and
  git apply —intent-to-add patch-contains-exist-in-index-file

will ignore intent-to-add and do nothing.