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

Re: [BUG] 'diff A...B' fails with multiple merge bases

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 13, 2010, 00:25 UTC
Message-ID
<7viq4k6xea.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vocec6xlt.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 7 quoted lines
> I prepared a patch to reject such a request when there are more than one
> merge base (see below---it is against 1.6.4 maintenance track).  While I
> think giving _one_ possible explanation of what you did since you forked
> would be better than rejecting, which I'll try in a separate message, but
> at the same time it may be misleading to give such an output without
> telling the user that we chose one merge base at random to diff against
> it.

And this is the other one (not relative to the previous patch) that shows diff since one randomly chosen merge base.

 builtin-diff.c |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/builtin-diff.c b/builtin-diff.c
index 2e51f40..1f44f5b 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -405,12 +405,28 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 		result = builtin_diff_index(&rev, argc, argv);
 	else if (ents == 2)
 		result = builtin_diff_tree(&rev, argc, argv, ent);
-	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.
+	else if (ent[0].item->flags & UNINTERESTING) {
+		/*
+		 * Perhaps the user gave us A...B, which expands
+		 * to a list of negative merge bases followed by
+		 * A (symmetric-left) and B?  Let's make sure...
 		 */
-		ent[1] = ent[2];
+		for (i = 1; i < ents; i++)
+			if (!(ent[i].item->flags & UNINTERESTING))
+				break;
+		if (ents != i + 2 ||
+		    (ent[i+1].item->flags & UNINTERESTING) ||
+		    (!ent[i].item->flags & SYMMETRIC_LEFT) ||
+		    (ent[i+1].item->flags & SYMMETRIC_LEFT))
+			die("what do you mean by that?");
+		/*
+		 * diff A...B where there is at least one merge base
+		 * between A and B.  We have ent[0] == merge-base,
+		 * ent[ents-2] == A, and ent[ents-1] == B.  Show diff
+		 * between the base and B.  Note that we pick one
+		 * merge base at random if there are more than one.
+		 */
+		ent[1] = ent[ents-1];
 		result = builtin_diff_tree(&rev, argc, argv, ent);
 	}
 	else
Previous: Junio C HamanoNext: Sverre Rabbelier
Message 4 of 10 in “[BUG] 'diff A...B' fails with multiple merge bases”
  1. Pickens, James EJul 10, 2010
  2. Junio C HamanoJul 12, 2010
  3. Junio C HamanoJul 13, 2010
  4. Junio C HamanoJul 13, 2010
  5. Sverre RabbelierJul 13, 2010
  6. Junio C HamanoJul 13, 2010
  7. Sverre RabbelierJul 13, 2010
  8. Junio C HamanoJul 13, 2010
  9. Sverre RabbelierJul 13, 2010
  10. Pickens, James EJul 13, 2010

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.