From: Junio C Hamano <gitster@pobox.com>
To: ydirson@free.fr
Cc: git <git@vger.kernel.org>
Subject: Re: [BUG] diff algorithm selection issue
Date: Tue, 26 May 2020 09:10:22 -0700 [thread overview]
Message-ID: <xmqqh7w2oexd.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <540830445.1034524732.1590485817611.JavaMail.root@zimbra39-e7> (ydirson@free.fr's message of "Tue, 26 May 2020 11:36:57 +0200 (CEST)")
ydirson@free.fr writes:
> When the config has diff.algorithm=patience set, "git diff --minimal" seems to
> be ignored, and does not give the same output as "git diff --diff-algorithm=minimal",
> but really the same as "git diff --diff-algorithm=patience".
Thanks for reporting. The document on --diff-algorithm does make it
sound as if the --diff-algorithm=minimal option must operate as if
myers algorithm is used with the minumalization tweak, but that is
wrong from the point of view of the intent of the "minimal" option,
which was meant to be a secondary option that tweaks the base
algorithm (be it myers or patience or any other new algorithm we
might introduce in the future) by allowing it to spend more cycles
to come up with a smaller diff.
At least, it is what the "--minimal" option (not the value "minimal"
given to the "--diff-algorithm=<algo>" option), and the underlying
mechanism that supports the option, meant to do.
But the way the option is surfaced to the end-user facing UI (and
the documentation) with "--diff-algorithm=minimal", it does look
like
git -c diff.algorithm=patience cmd --diff-algorithm=minimal
git -c diff.algorithm=patience cmd --diff-algorithm=myers --minimal
ought to be equivalent.
Also, I suspect that
git -c diff.algorithm=patience cmd --diff-algorithm=myers
does not do what we expect, either.
I have not convinced myself that the attached is the best way to fix
the issue, but anyway, somebody seems to be OR'ing in diff_algorithm
to xdl_opts field after we see --diff-algorithm=minimal and replaced
XDF_DIFF_ALGORITHM_MASK bits in xdl_opts field in this function, so
the attached patch may defeat that code---the real bug is probably in
that code, but I haven't figured out where it is X-<.
diff.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/diff.c b/diff.c
index 863da896c0..a6dba45cd6 100644
--- a/diff.c
+++ b/diff.c
@@ -5026,6 +5026,10 @@ static int diff_opt_diff_algorithm(const struct option *opt,
return error(_("option diff-algorithm accepts \"myers\", "
"\"minimal\", \"patience\" and \"histogram\""));
+ /* we shouldn't have to do this... */
+ if (!(value & XDF_DIFF_ALGORITHM_MASK))
+ diff_algorithm &= ~XDF_DIFF_ALGORITHM_MASK;
+
/* clear out previous settings */
DIFF_XDL_CLR(options, NEED_MINIMAL);
options->xdl_opts &= ~XDF_DIFF_ALGORITHM_MASK;
next prev parent reply other threads:[~2020-05-26 16:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <408624876.1034463388.1590484997966.JavaMail.root@zimbra39-e7>
2020-05-26 9:36 ` [BUG] diff algorithm selection issue ydirson
2020-05-26 16:10 ` Junio C Hamano [this message]
2020-05-26 16:23 ` Junio C Hamano
2020-05-26 16:56 ` ydirson
2020-05-26 17:21 ` ydirson
2020-05-26 18:33 ` 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=xmqqh7w2oexd.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=ydirson@free.fr \
/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).