Re: [PATCH 2/5] apply: read in the index in --intent-to-add mode
- From
Raymond E. Pasco <ray@ameretat.dev>
- Date
- Jul 1, 2025, 05:32 UTC
- Message-ID
- <i5mft6pima4ft4gyhluoflktnr22dzl6vc2txqfwvhldecdk5b@rkfdkf2ryci7>
- In-Reply-To
- <xmqqbjq512y5.fsf@gitster.g>
On 25/06/30 11:47AM, Junio C Hamano wrote:
Show 17 quoted lines
> "Raymond E. Pasco" <ray@ameretat.dev> writes: > > > There are three main modes of operation for apply: applying only to the > > worktree, applying to the worktree and index (--index), and applying > > only to the index (--cached). > > > > The --intent-to-add flag modifies the first of these modes, applying > > only to the worktree, in a way which touches the index, because > > intents to add are special index entries. However, it has not ever > > worked correctly in any but the most trivial (empty repository) > > cases, because the index was never read in (in apply, this is done > > in read_apply_cache()) before writing to it. > > As the inventor of "add -N", I think what "apply -N" does may be > wrong (only judging from the above description; it's been a while > since I really read the code in apply.c). It does not make any > sense to write a new index that has only the ITA entries.
Yeah, that's the bug; it writes a new index with just ITA entries (iow, the index thinks every existing file has been deleted); the fix is to instead write ITA entries to the existing index, not make a new one. And the root cause is not having read the index, so it's starting from an empty tree.