From: Junio C Hamano <gitster@pobox.com>
To: "Pickens\, James E" <james.e.pickens@intel.com>
Cc: "git\@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: [BUG] 'diff A...B' fails with multiple merge bases
Date: Mon, 12 Jul 2010 16:30:44 -0700 [thread overview]
Message-ID: <7vaapw8ehn.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <3BA20DF9B35F384F8B7395B001EC3FB36CF674AE@azsmsx507.amr.corp.intel.com> (James E. Pickens's message of "Fri\, 9 Jul 2010 18\:15\:45 -0700")
"Pickens, James E" <james.e.pickens@intel.com> writes:
> The command 'git diff A...B' is supposed to be equivalent to 'git diff $(git
> merge-base A B) B'. But when there are multiple merge bases between A and B,
> the former gives no output...
> ...
> The diff commands at the end will give different results. It bisects to:
>
> commit b75271d93a9e4be960d53fc4f955802530e0e733
> Author: Matt McCutchen <matt@mattmccutchen.net>
> Date: Fri Oct 10 21:56:15 2008 -0400
Thanks for a report, and for bisecting.
This unfortunately is somewhat an expected fallout from Matt's patch.
The low-level diff dispatcher in cmd_diff() function, where "ents" are
tree-ish given from the command line (either using 'diff A', 'diff A B',
'diff A..B', 'diff A...B' or 'diff A B C D E ...', syntaxes), says this:
...
else if ((ents == 3) && (ent[0].item->flags & UNINTERESTING)) {
/* diff A...B where there is one sane merge base between
* A and B. We have ent[0] == merge-base, ent[1] == A,
* and ent[2] == B. Show diff between the base and B.
*/
ent[1] = ent[2];
result = builtin_diff_tree(&rev, argc, argv, ent);
}
else
result = builtin_diff_combined(&rev, argc, argv,
ent, ents);
I omitted the 1 or 2 trees case where we do naturally diff-index or
diff-tree from the above.
When the user gives more than two trees (e.g. "diff A B C"), we show a
combined diff that explains a merge of B and C that produces A, which was
introduced by 0fe7c1d (built-in diff: assorted updates., 2006-04-29).
Remember that the first tree is the merge result, and the user is asking
us to explain that result relative to its parents.
The special case with three trees, among which the first one being
uninteresting, came much later. The revision parser parses A...B into a
list of "--not $(merge-bases A B)", A (SYMMETRIC_LEFT), and then B. As
the purpose of "diff A...B" is to show what you did up to B since you
forked from A, showing the tree diff between the ent[0] (merge base) and
ent[2] (B) is the right thing to do. But the codepath is of course
prepared to about dealing with a single-base merges, so your criss-cross
merge case does not trigger this special case.
So we fall into the "combined diff" case, which does this:
git diff $(git merge-base --all A B) A B
As defined by 0fe7c1de, this should output the combined diff to explain as
if one of the merge bases (that happens to be the first one in merge-base
output) were the merge result of all the other merge bases, the refs A and
B you gave from the command line. Which does not make _any_ sense, as it
is picking one of the criss-cross merge bases at random and forcing the
history to flow backwards.
Before Matt's patch, I think diff_combined() was giving a _slightly_ more
reasonable result because it (incorrectly) reversed the arguments to
explain as if B (typically yours) is the merge across all the merge bases
and the other tip A. I say that is a "slightly" more reasonable, only
because what is explained is what you are familiar with, i.e. B. I don't
think the way it explains it as a pseudo merge across all the merge bases
and the other tip makes any sense.
It should not be too hard to add logic to reverse the list of revisions as
another special case in the above else-if chain to support the old output
you saw before Matt's fix if such an output were useful. You would detect
if the list begins with a run of UNINTERESTING ones followed by two
interesting ones (because that is how A...B parser gives its output to
us), and in that case feed diff_combined with a reversed list.
But I do not see how such an pseudo-merge output is useful, so please
enlighten me with an illustration. Your "earlier it showed something, now
it doesn't show anything" is not good enough here, as I am doubting that
something we used to show in a criss-cross merge case was a useful output.
Thanks.
next prev parent reply other threads:[~2010-07-12 23:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-10 1:15 [BUG] 'diff A...B' fails with multiple merge bases Pickens, James E
2010-07-12 23:30 ` Junio C Hamano [this message]
2010-07-13 0:20 ` Junio C Hamano
2010-07-13 0:25 ` Junio C Hamano
2010-07-13 0:41 ` Sverre Rabbelier
2010-07-13 0:45 ` Junio C Hamano
2010-07-13 0:49 ` Sverre Rabbelier
2010-07-13 0:55 ` Junio C Hamano
2010-07-13 1:12 ` Sverre Rabbelier
2010-07-13 1:16 ` Pickens, James E
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=7vaapw8ehn.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=james.e.pickens@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox