git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] read-cache: fix directory/file conflict handling in read_index_unmerged()

From
Elijah Newren <newren@gmail.com>
Date
Jul 11, 2018, 18:24 UTC
Message-ID
<CABPp-BEzsj6T2eaz-OEi_+CMJetHVsMTBgy6DBfVY26e3M1NoA@mail.gmail.com>
In-Reply-To
<xmqqsh4p3dtk.fsf@gitster-ct.c.googlers.com>
On Wed, Jul 11, 2018 at 10:03 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 37 quoted lines
> Elijah Newren <newren@gmail.com> writes:
>
>>     The _only_ reason we want to keep a previously unmerged entry in the
>>     index at stage #0 is so that we don't forget the fact that we have
>>     corresponding file in the work tree in order to be able to remove it
>>     when the tree we are resetting to does not have the path.
>> ...
>> So, that's the intended purpose of this function.  The problem is that
>> when directory/files conflicts are present, trying to add the file to the
>> index at stage 0 fails (because there is still a directory in the way),
>> and the function returns early with a -1 return code to signify the error.
>> As noted above, none of the callers who want the drop-to-stage-0 behavior
>> check the return status, though, so this means all remaining unmerged
>> entries remain in the index and the callers proceed assuming otherwise.
>
> Nicely analysed and explained so far.
>
>> ...  The temporary simultaneous appearance of the
>> directory and file entries in the index will be removed by the callers
>> before they attempt to write the index anywhere.
>
> But this part makes me feel a bit uneasy, as I find this "will be
> removed" a bit hand-wavy.  There are two such callers.  "am --skip"
> and "reset".
>
> The former uses am.c::fast_forward_to that calls unpack_trees() to
> two-way merge (aka "switch to the other branch") and these entries
> with CE_CONFLICTED flag get removed in merged/deleted_entry().
>
> "reset" (all variants) call unpack_trees() on the index prepared
> with read_cache_unmerged(), and the unmerged entries that are marked
> with CE_CONFLICTED bit get removed the same way.
>
> So perhaps before "before they attempt to", saying "by calling
> unpack_trees(), which excludes these unmerged entries marked with
> CE_CONFLICTED flag from the resulting index," or something like that
> would help uneasy readers?

Makes sense, I'll include that in my re-roll after waiting a little bit for any further reviews.

Previous: Junio C HamanoNext: Elijah Newren
Message 7 of 14 in “Address recovery failures with directory/file conflicts”
  1. 0/2 Address recovery failures with directory/file conflictsElijah Newren, Jul 11, 2018
  2. 1/2 t1015: demonstrate directory/file conflict recovery failuresElijah Newren, Jul 11, 2018
  3. Eric SunshineJul 11, 2018
  4. Elijah NewrenJul 11, 2018
  5. 2/2 read-cache: fix directory/file conflict handling in read_index_unmerged()Elijah Newren, Jul 11, 2018
  6. Junio C HamanoJul 11, 2018
  7. Elijah NewrenJul 11, 2018
  8. 0/2 Address recovery failures with directory/file conflictsElijah Newren, Jul 13, 2018
  9. 2/2 read-cache: fix directory/file conflict handling in read_index_unmerged()Elijah Newren, Jul 13, 2018
  10. 1/2 t1015: demonstrate directory/file conflict recovery failuresElijah Newren, Jul 13, 2018
  11. Elijah NewrenJul 13, 2018
  12. 0/2 Address recovery failures with directory/file conflictsElijah Newren, Jul 31, 2018
  13. 2/2 read-cache: fix directory/file conflict handling in read_index_unmerged()Elijah Newren, Jul 31, 2018
  14. 1/2 t1015: demonstrate directory/file conflict recovery failuresElijah Newren, Jul 31, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.