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

Re: [PATCH 3/4] add: introduce '--resolved' option

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 2, 2026, 22:38 UTC
Message-ID
<xmqqfr0w2lnt.fsf@gitster.g>
In-Reply-To
<CAC2QwmJeohdnWhUbcP6Pc5w1X8yZf3jXvpR8JC=Hb9gqkFF6ig@mail.gmail.com>
Michael Montalbo <mmontalbo@gmail.com> writes:
Show 26 quoted lines
> On Wed, Jul 29, 2026 at 8:17 AM Junio C Hamano <gitster@pobox.com> wrote:
>>
>>
>> Left unchecked, this loop may end up scanning a large binary file to
>> the end in vain.  We may squeeze in something like this to punt
>> early.
>>
>>  merge-ll.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/merge-ll.c b/merge-ll.c
>> index 5e5044b9e3..ef5287dee8 100644
>> --- a/merge-ll.c
>> +++ b/merge-ll.c
>> @@ -516,6 +516,9 @@ int has_conflict_markers(struct index_state *istate, const char *path)
>>                         has_markers = 1;
>>                         break;
>>                 }
>> +               if (buffer_is_binary(sb.buf,
>> +                                    ULONG_MAX <= sb.len ? ULONG_MAX : sb.len))
>> +                       break;
>>         }
>
> Should this check be before the conflict marker line check in case the first
> iteration accidentally matches for a binary file and breaks with
> has_markers = 1?
If we misidentify early, that is a desirable outcome, isn't it?

We did not have to scan much and we gave control back to the user as soon as we saw "<<<<<<", telling them that we refused to add the path to the index, so that the user can inspect the situation more deeply. In this application, false positives are much better than false negatives, and failing early is better than failing late.

So, no, I do not think so, even though in practice I do not think it would matter either way.

A question that may have much more impact is whether the attribute system should have any say in this code path. I am somewhat torn on this.

Previous: Michael MontalboNext: Michael Montalbo
Message 11 of 30 in “git add --resolved”
  1. 0/4 git add --resolvedJunio C Hamano, Jul 28, 2026
  2. 1/4 merge-ll: consolidate conflict marker scanning logicJunio C Hamano, Jul 28, 2026
  3. 2/4 read-cache: add remove_file_from_index_with_flags()Junio C Hamano, Jul 28, 2026
  4. 3/4 add: introduce '--resolved' optionJunio C Hamano, Jul 28, 2026
  5. Michael MontalboJul 29, 2026
  6. Junio C HamanoJul 29, 2026
  7. Junio C HamanoJul 29, 2026
  8. Junio C HamanoAug 2, 2026
  9. Junio C HamanoJul 29, 2026
  10. Michael MontalboAug 2, 2026
  11. Junio C HamanoAug 2, 2026
  12. Michael MontalboAug 3, 2026
  13. 4/4 read-cache: reindentJunio C Hamano, Jul 28, 2026
  14. 0/4 git add --resolvedJunio C Hamano, Jul 29, 2026
  15. 1/4 read-cache: reindentJunio C Hamano, Jul 29, 2026
  16. 2/4 merge-ll: consolidate conflict marker scanning logicJunio C Hamano, Jul 29, 2026
  17. 3/4 read-cache: add remove_file_from_index_with_flags()Junio C Hamano, Jul 29, 2026
  18. 4/4 add: introduce '--resolved' optionJunio C Hamano, Jul 29, 2026
  19. Junio C HamanoJul 29, 2026
  20. Michael MontalboJul 29, 2026
  21. Junio C HamanoJul 30, 2026
  22. Michael MontalboAug 2, 2026
  23. 0/4 git add --resolvedJunio C Hamano, Jul 31, 2026
  24. 1/4 read-cache: reindentJunio C Hamano, Jul 31, 2026
  25. 2/4 merge-ll: consolidate conflict marker scanning logicJunio C Hamano, Jul 31, 2026
  26. 3/4 read-cache: add remove_file_from_index_with_flags()Junio C Hamano, Jul 31, 2026
  27. 4/4 add: introduce '--resolved' optionJunio C Hamano, Jul 31, 2026
  28. Jeff KingAug 1, 2026
  29. Junio C HamanoAug 1, 2026
  30. Junio C HamanoAug 1, 2026

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.