Re: [RFH] revision limiting sometimes ignored

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Monday, February 4, 2008 - 10:32 am

On Sat, 2 Feb 2008, Jeff King wrote:

Ok, I agree that there is a bug, and your two-liner fix is a "fix" in that 
it works, but I think it's absolutely the wrogn fix because it is totally 
unacceptable from a performance angle. We obviously need to break out of 
the loop before we have walked the whole commit chain.


So I think the real problem here is not that the logic is wrong in 
general, but that there is one *special* case where the logic to break out 
is wrong.

And that special case is when we hit the root commit which isn't negative.

That case is special because *normally*, if we have a positive commit, we 
will always continue to walk the parents of that positive commit, so the 
"everybody_interesting()" check will not trigger. BUT! If we hit a root 
commit and it is positive, that won't happen (since, by definition, it has 
no parents to keep the list populated with), and now we break out early.

So I think your fix is wrong, but it's "close" to right: I suspect that we 
can fix it by marking the "we hit the root commit" case, and just 
disabling it for that case.

This patch is untested and obviously won't even compile (I didn't actually 
add the "hit_root" bitfield to the revision struct), but shows what I 
*think* should fix this issue, without the performance problem.

But maybe I haven't thought it entirely through, and there is some other 
case that can trigger this bug.

So please somebody double-check my thinking.

			Linus

---
diff --git a/revision.c b/revision.c
index 6e85aaa..0e90988 100644
--- a/revision.c
+++ b/revision.c
@@ -456,6 +456,9 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit, str
 
 	left_flag = (commit->object.flags & SYMMETRIC_LEFT);
 
+	if (!commit->parents)
+		revs->hit_root = 1;
+
 	rest = !revs->first_parent_only;
 	for (parent = commit->parents, add = 1; parent; add = rest) {
 		struct commit *p = parent->item;
@@ -579,7 +582,7 @@ static int limit_list(struct rev_info *revs)
 			return -1;
 		if (obj->flags & UNINTERESTING) {
 			mark_parents_uninteresting(commit);
-			if (everybody_uninteresting(list))
+			if (!revs->hit_root && everybody_uninteresting(list))
 				break;
 			continue;
 		}
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[BUG?] git log picks up bad commit, Tilman Sauerbeck, (Sat Feb 2, 5:21 am)
Re: [BUG?] git log picks up bad commit, Jeff King, (Sat Feb 2, 8:00 pm)
[RFH] revision limiting sometimes ignored, Jeff King, (Sat Feb 2, 9:33 pm)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Sat Feb 2, 11:24 pm)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Sat Feb 2, 11:39 pm)
Re: [RFH] revision limiting sometimes ignored, Jeff King, (Sun Feb 3, 12:13 am)
Re: [RFH] revision limiting sometimes ignored, Jeff King, (Sun Feb 3, 12:18 am)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Sun Feb 3, 12:40 am)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Sun Feb 3, 12:47 am)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Sun Feb 3, 1:18 am)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Mon Feb 4, 10:32 am)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Mon Feb 4, 10:37 am)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Mon Feb 4, 12:08 pm)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Mon Feb 4, 1:03 pm)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Mon Feb 4, 1:06 pm)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Mon Feb 4, 1:50 pm)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Tue Feb 5, 12:14 am)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Tue Feb 5, 2:23 pm)
Re: [RFH] revision limiting sometimes ignored, Johannes Schindelin, (Tue Feb 5, 3:34 pm)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Tue Feb 5, 4:59 pm)
Re: [RFH] revision limiting sometimes ignored, Nicolas Pitre, (Tue Feb 5, 6:22 pm)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Tue Feb 5, 6:51 pm)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Tue Feb 5, 11:05 pm)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Tue Feb 5, 11:17 pm)
Re: [RFH] revision limiting sometimes ignored, Tilman Sauerbeck, (Wed Feb 6, 9:43 am)
Re: [RFH] revision limiting sometimes ignored, Nicolas Pitre, (Wed Feb 6, 10:28 am)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Wed Feb 6, 10:42 am)
Re: [RFH] revision limiting sometimes ignored, Nicolas Pitre, (Wed Feb 6, 10:48 am)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Wed Feb 6, 12:26 pm)