From: Junio C Hamano <gitster@pobox.com>
To: Michael Montalbo <mmontalbo@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 3/4] add: introduce '--resolved' option
Date: Sun, 02 Aug 2026 15:38:14 -0700 [thread overview]
Message-ID: <xmqqfr0w2lnt.fsf@gitster.g> (raw)
In-Reply-To: <CAC2QwmJeohdnWhUbcP6Pc5w1X8yZf3jXvpR8JC=Hb9gqkFF6ig@mail.gmail.com> (Michael Montalbo's message of "Sat, 1 Aug 2026 17:49:40 -0700")
Michael Montalbo <mmontalbo@gmail.com> writes:
> 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.
next prev parent reply other threads:[~2026-08-02 22:38 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 21:52 [PATCH 0/4] git add --resolved Junio C Hamano
2026-07-28 21:52 ` [PATCH 1/4] merge-ll: consolidate conflict marker scanning logic Junio C Hamano
2026-07-28 21:52 ` [PATCH 2/4] read-cache: add remove_file_from_index_with_flags() Junio C Hamano
2026-07-28 21:52 ` [PATCH 3/4] add: introduce '--resolved' option Junio C Hamano
2026-07-29 3:28 ` Michael Montalbo
2026-07-29 13:43 ` Junio C Hamano
2026-07-29 13:49 ` Junio C Hamano
2026-08-02 2:23 ` Junio C Hamano
2026-07-29 15:01 ` Junio C Hamano
2026-08-02 0:49 ` Michael Montalbo
2026-08-02 22:38 ` Junio C Hamano [this message]
2026-08-03 1:15 ` Michael Montalbo
2026-07-28 21:52 ` [PATCH 4/4] read-cache: reindent Junio C Hamano
2026-07-29 17:25 ` [PATCH v2 0/4] git add --resolved Junio C Hamano
2026-07-29 17:25 ` [PATCH v2 1/4] read-cache: reindent Junio C Hamano
2026-07-29 17:25 ` [PATCH v2 2/4] merge-ll: consolidate conflict marker scanning logic Junio C Hamano
2026-07-29 17:25 ` [PATCH v2 3/4] read-cache: add remove_file_from_index_with_flags() Junio C Hamano
2026-07-29 17:25 ` [PATCH v2 4/4] add: introduce '--resolved' option Junio C Hamano
2026-07-29 22:19 ` Junio C Hamano
2026-07-29 23:41 ` [PATCH v2 0/4] git add --resolved Michael Montalbo
2026-07-30 8:41 ` Junio C Hamano
2026-08-02 0:22 ` Michael Montalbo
2026-07-31 12:56 ` [PATCH v3 " Junio C Hamano
2026-07-31 12:56 ` [PATCH v3 1/4] read-cache: reindent Junio C Hamano
2026-07-31 12:56 ` [PATCH v3 2/4] merge-ll: consolidate conflict marker scanning logic Junio C Hamano
2026-07-31 12:56 ` [PATCH v3 3/4] read-cache: add remove_file_from_index_with_flags() Junio C Hamano
2026-07-31 12:56 ` [PATCH v3 4/4] add: introduce '--resolved' option Junio C Hamano
2026-08-01 14:14 ` [PATCH v3 0/4] git add --resolved Jeff King
2026-08-01 17:58 ` Junio C Hamano
2026-08-01 21:45 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqfr0w2lnt.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=mmontalbo@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.