On 25/06/29 11:10AM, Lidong Yan wrote: > 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. This behavior is correct and expected (even if you don't register an intent to add) because the file is there in the worktree, so you can't create a new file in the worktree with that name. But the real reason for that test in create_file is that we're in a mode that shouldn't be touching the index at all, so we shouldn't touch the index (except in the special case where intents to add live in the index). If there's a patch that updates existing file A, and creates new file B, then without that test apply will touch the index for both A and B, which is wrong. It must only touch it for B.