From: Junio C Hamano <gitster@pobox.com>
To: Jerry Zhang <jerry@skydio.com>
Cc: Git Mailing List <git@vger.kernel.org>, lilinchao@oschina.cn
Subject: Re: [PATCH] git-apply: fix --3way with binary patch
Date: Wed, 28 Jul 2021 13:08:04 -0700 [thread overview]
Message-ID: <xmqq1r7i9p7f.fsf@gitster.g> (raw)
In-Reply-To: <CAMKO5CvZCMHuzRLSs2aHJ3iUH-LBJfFP3fG+GgwtQvsKQPtT5Q@mail.gmail.com> (Jerry Zhang's message of "Wed, 28 Jul 2021 12:38:20 -0700")
Jerry Zhang <jerry@skydio.com> writes:
> So basically, another way of stating the problem would be that binary
> patches can apply cleanly with direct application in some cases where
> merge application is not clean. If i understand correctly this is unique
> to binary files, although it would be possible for a user to supply a custom
> merge driver for text files that is worse than direct application, that is
> most likely heavy user error that we shouldn't have to cater to.
Not really. The built-in binary merge driver luckily had such
characteristics to allow us to catch this regression, but I see no
reason to believe that it is unique to binary. Funky merge backends
like union merges can turn an otherwise conflicting merge into a
clean merge even for non-binary files. And no, it is not an error
for a merge driver to fail "apply --3way" merge on incoming data
that "apply --no-3way" would apply cleanly.
> However
> the issue with binary is that the *default* merge driver is actually worse
> than direct application (in some cases).
> 1. do as you suggest and run 3way -> direct -> 3way. I would modify
> this and say we should only attempt this for binary patches, since a text
> file that fails 3way would most likely also fail direct,...
No, I do not trust our (myself and your) unsubstantiated belief that
it is limited to binary. We saw a problem with binary, and I would
think it is a tip of iceberg for any non-straight-text-merge backend
(and I do not have any sound reason to believe that straight
text-merge backend will not have this issue). I'd rather treat this
as coalmine canary.
I think the real problem, even without the "try threeway, fall back
to direct application, and then try threeway again", is that after
swapping the fallback order, a failed threeway does *not* fall back
to direct application in this case. Regardless of what ll_merge()
and its backend does, if they fail, shouldn't the caller of
try_threeway() notice the failure and fall back to direct
application, just like the earlier code tried direct application
first and then _always_ fell back to threeway if it failed? I do
not know exactly why today's code fails to do so, but I suspect that
fixing that is the real solution, no?
Independent from that, I suspect that it may be a good thing to do
to (at least optionally) allow ll_merge() to notice trivial merges
that proper merge frontends would never ask it to do and resolve
them trivially. The patch you saw from me to ll_merge_binary() may
do so at a wrong layer (doing it in ll_merge() before it dispatches
to ll_merge_binary() and other backends might be a better approach)
but would be a good starting point for that independent effort, but
"apply --3way" should work correctly even with user-configured merge
drivers (after all, the "direct application first and then fall back
to 3way" code would have worked perfectly fine even with broken
custom merge drivers in the case we are discussing right now).
Thanks.
next prev parent reply other threads:[~2021-07-28 20:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-28 2:44 [PATCH] git-apply: fix --3way with binary patch Jerry Zhang
2021-07-28 4:29 ` Junio C Hamano
2021-07-28 4:30 ` Junio C Hamano
2021-07-28 17:55 ` [PATCH] ll-merge: teach ll_binary_merge() a trivial three-way merge Junio C Hamano
2021-07-28 23:49 ` Elijah Newren
2021-07-29 1:06 ` Junio C Hamano
2021-09-05 19:06 ` [PATCH v2] apply: resolve trivial merge without hitting ll-merge with "--3way" Junio C Hamano
2021-09-06 18:57 ` Elijah Newren
2021-09-06 21:59 ` Ævar Arnfjörð Bjarmason
2021-09-07 2:32 ` Junio C Hamano
2021-09-07 20:15 ` Junio C Hamano
2021-07-28 19:38 ` [PATCH] git-apply: fix --3way with binary patch Jerry Zhang
2021-07-28 20:04 ` Jerry Zhang
2021-07-28 20:08 ` Junio C Hamano [this message]
2021-07-28 20:37 ` Jerry Zhang
2021-07-28 21:01 ` Junio C Hamano
[not found] <ee1d1a82ef4d11ebbb4cd4ae5278bc123046@skydio.com>
2021-07-28 4:45 ` lilinchao
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=xmqq1r7i9p7f.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jerry@skydio.com \
--cc=lilinchao@oschina.cn \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).