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

Re: A note on merging conflicts..

From
Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Jul 2, 2006, 11:31 UTC
Message-ID
<20060702113133.GA11529@lsrfire.ath.cx>
In-Reply-To
<Pine.LNX.4.64.0607011937190.9789@iabervon.org>
On Sat, Jul 01, 2006 at 07:45:33PM -0400, Daniel Barkalow wrote:
> That is: (this only has the logic portion, and it's against master, so it 
> isn't actually a really working patch or anything; also, it doesn't handle 
> "--not a...b" correctly, whatever that should mean)
[concept patch snipped]

You mean something like the patch below? It seems to work, but in my unscientific tests it's significant slower than the version based on get_merge_bases() (0.17s vs 0.05s for "git-rev-list 89719209...262a6ef7 66ae0c77...ced9456a"). Did I do something wrong?

You had no mark_parents_left_right() in your patch. I added it because otherwise it wouldn't remove any common commits. Was this supposed to work some other way?

We still need an automatic test case, and a better benchmark.
diff --git a/revision.c b/revision.c
index ebee05a..8c494ee 100644
--- a/revision.c
+++ b/revision.c
@@ -339,6 +339,20 @@ static void try_to_simplify_commit(struc
 		commit->object.flags |= TREECHANGE;
 }
 
+static void mark_parents_left_right(struct commit *commit)
+{
+	unsigned int flags = commit->object.flags & (RIGHT_HALF | LEFT_HALF);
+	struct commit_list *parents = commit->parents;
+
+	while (parents) {
+		struct commit *p = parents->item;
+		p->object.flags |= flags;
+		if (p->parents)
+			mark_parents_left_right(p);
+		parents = parents->next;
+	}
+}
+
 static void add_parents_to_list(struct rev_info *revs, struct commit *commit, struct commit_list **list)
 {
 	struct commit_list *parent = commit->parents;
@@ -347,6 +361,13 @@ static void add_parents_to_list(struct r
 		return;
 	commit->object.flags |= ADDED;
 
+	if (commit->object.flags & (RIGHT_HALF | LEFT_HALF)) {
+		if (commit->object.flags & RIGHT_HALF &&
+		    commit->object.flags & LEFT_HALF)
+			commit->object.flags |= UNINTERESTING;
+		mark_parents_left_right(commit);
+	}
+
 	/*
 	 * If the commit is uninteresting, don't try to
 	 * prune parents - we want the maximal uninteresting
@@ -772,7 +793,10 @@ int setup_revisions(int argc, const char
 			unsigned char from_sha1[20];
 			const char *next = dotdot + 2;
 			const char *this = arg;
+			int symmetric = *next == '.';
+
 			*dotdot = 0;
+			next += symmetric;
 			if (!*next)
 				next = "HEAD";
 			if (dotdot == arg)
@@ -782,8 +806,13 @@ int setup_revisions(int argc, const char
 				struct object *exclude;
 				struct object *include;
 
-				exclude = get_reference(revs, this, from_sha1, flags ^ UNINTERESTING);
-				include = get_reference(revs, next, sha1, flags);
+				if (symmetric) {
+					exclude = get_reference(revs, this, from_sha1, flags | LEFT_HALF);
+					include = get_reference(revs, next, sha1, flags | RIGHT_HALF);
+				} else {
+					exclude = get_reference(revs, this, from_sha1, flags ^ UNINTERESTING);
+					include = get_reference(revs, next, sha1, flags);
+				}
 				if (!exclude || !include)
 					die("Invalid revision range %s..%s", arg, next);
 
diff --git a/revision.h b/revision.h
index c010a08..0090232 100644
--- a/revision.h
+++ b/revision.h
@@ -9,6 +9,8 @@ #define TMP_MARK	(1u<<4) /* for isolated
 #define BOUNDARY	(1u<<5)
 #define BOUNDARY_SHOW	(1u<<6)
 #define ADDED		(1u<<7)	/* Parents already parsed and added? */
+#define RIGHT_HALF	(1u<<8)
+#define LEFT_HALF	(1u<<9)
 
 struct rev_info;
 struct log_info;
Previous: Daniel BarkalowNext: Daniel Barkalow
Message 15 of 49 in “A note on merging conflicts..”
  1. Linus TorvaldsJul 1, 2006
  2. Junio C HamanoJul 1, 2006
  3. Linus TorvaldsJul 1, 2006
  4. Linus TorvaldsJul 1, 2006
  5. Rene ScharfeJul 1, 2006
  6. Johannes SchindelinJul 1, 2006
  7. Linus TorvaldsJul 1, 2006
  8. Rene ScharfeJul 1, 2006
  9. J. Bruce FieldsJul 1, 2006
  10. Linus TorvaldsJul 1, 2006
  11. Daniel BarkalowJul 1, 2006
  12. Linus TorvaldsJul 1, 2006
  13. Daniel BarkalowJul 1, 2006
  14. Daniel BarkalowJul 1, 2006
  15. Rene ScharfeJul 2, 2006
  16. Daniel BarkalowJul 2, 2006
  17. Linus TorvaldsJul 2, 2006
  18. Jakub NarebskiJul 1, 2006
  19. Linus TorvaldsJul 1, 2006
  20. Junio C HamanoJul 1, 2006
  21. Rene ScharfeJul 1, 2006
  22. Junio C HamanoJul 1, 2006
  23. Johannes SchindelinJul 1, 2006
  24. Linus TorvaldsJul 1, 2006
  25. Junio C HamanoJul 1, 2006
  26. Junio C HamanoJul 1, 2006
  27. 1/3 Add get_merge_bases_clean()Rene Scharfe, Jul 1, 2006
  28. Johannes SchindelinJul 1, 2006
  29. 2/3 Add '...' operator for revisionsRene Scharfe, Jul 1, 2006
  30. 3/3 Make clear_commit_marks() clean harderRene Scharfe, Jul 1, 2006
  31. Junio C HamanoJul 3, 2006
  32. Johannes SchindelinJul 3, 2006
  33. Linus TorvaldsJul 3, 2006
  34. Johannes SchindelinJul 3, 2006
  35. Junio C HamanoJul 3, 2006
  36. Johannes SchindelinJul 3, 2006
  37. Linus TorvaldsJul 3, 2006
  38. Johannes SchindelinJul 4, 2006
  39. Junio C HamanoJul 4, 2006
  40. 4/3 Fold get_merge_bases_clean() into get_merge_bases()Rene Scharfe, Jul 2, 2006
  41. Johannes SchindelinJul 2, 2006
  42. Linus TorvaldsJul 2, 2006
  43. Rene ScharfeJul 2, 2006
  44. Junio C HamanoJul 2, 2006
  45. Rene ScharfeJul 2, 2006
  46. Rene ScharfeJul 2, 2006
  47. Linus TorvaldsJul 2, 2006
  48. Linus TorvaldsJul 2, 2006
  49. Junio C HamanoJul 7, 2006

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.