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

[PATCH] Don't recurse into parents marked uninteresting.

From
Matthias Urlichs <smurf@smurf.noris.de>
Date
Mar 9, 2006, 04:04 UTC
Message-ID
<pan.2006.03.09.04.04.34.617873@smurf.noris.de>
In-Reply-To
<pan.2006.03.08.20.04.24.62170@smurf.noris.de>

revision.c:make_parents_uninteresting() is exponential with the number of merges in the tree. That's fine -- unless some other part of git already has pulled the whole commit tree into memory ...

---
... or, in other words, "Don't do that, please."

With this patch, all tests still succeed, and the "git push" which triggered the problem takes 5min instead of an estimated 10mio years.

---
 revision.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)
32c9750691d1ef225ca1641fdf6902e53c25fe5b
diff --git a/revision.c b/revision.c
index 2a33637..713f27e 100644
--- a/revision.c
+++ b/revision.c
@@ -82,18 +82,20 @@ void mark_parents_uninteresting(struct c
 
 	while (parents) {
 		struct commit *commit = parents->item;
-		commit->object.flags |= UNINTERESTING;
+		if (!(commit->object.flags & UNINTERESTING)) {
+			commit->object.flags |= UNINTERESTING;
 
-		/*
-		 * Normally we haven't parsed the parent
-		 * yet, so we won't have a parent of a parent
-		 * here. However, it may turn out that we've
-		 * reached this commit some other way (where it
-		 * wasn't uninteresting), in which case we need
-		 * to mark its parents recursively too..
-		 */
-		if (commit->parents)
-			mark_parents_uninteresting(commit);
+			/*
+			 * Normally we haven't parsed the parent
+			 * yet, so we won't have a parent of a parent
+			 * here. However, it may turn out that we've
+			 * reached this commit some other way (where it
+			 * wasn't uninteresting), in which case we need
+			 * to mark its parents recursively too..
+			 */
+			if (commit->parents)
+				mark_parents_uninteresting(commit);
+		}
 
 		/*
 		 * A missing commit is ok iff its parent is marked
-- 
Matthias Urlichs
Previous: Matthias UrlichsNext: Linus Torvalds
Message 2 of 4 in “endless loop: ?”
  1. Matthias UrlichsMar 8, 2006
  2. Don't recurse into parents marked uninteresting.Matthias Urlichs, Mar 9, 2006
  3. Linus TorvaldsMar 9, 2006
  4. smurf@smurf.noris.deMar 9, 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.