Re: [PATCH 3/5] apply: only write intents to add for new files
- From
Raymond E. Pasco <ray@ameretat.dev>
- Date
- Jul 1, 2025, 05:44 UTC
- Message-ID
- <vzkxbwj5khnlzx23p2jz2omf4nfzfaal25gwlovvwgzxi2mmjx@vijooguwndsj>
- In-Reply-To
- <xmqq7c0t12oz.fsf@gitster.g>
On 25/06/30 11:53AM, Junio C Hamano wrote:
Show 23 quoted lines
> "Raymond E. Pasco" <ray@ameretat.dev> writes: > > > In the "update only the worktree" mode, the index should not be touched > > except to record intents to add when --intent-to-add is on. Because > > having --intent-to-add on sets update_index, to indicate that we are > > touching the index, we can't rely only on that flag to decide whether to > > write an index entry. > > Does that let us inspect state->ita_only alone and conclude that > state->update_index is set, though? IOW ... > > > if (patch->conflicted_threeway) > > return add_conflicted_stages_file(state, patch); > > - else if (state->update_index) > > + else if (state->check_index || (state->ita_only && patch->is_new > 0)) > > ... I would have expected the new code to check not just ita_only but > check ita_only only when update_index is in effect. > > > > return add_index_file(state, path, mode, buf, size); > > return 0; > > }
We're behind a more specific test on state->apply to enter this codepath at all (the only way in is the call to write_out_results around line 4859). So we're already committed to applying the patch, which is one half of update_index, but the other half is check_index || ita_only and we must behave differently depending on which of those is in effect and causing us to touch the index.