Re: [RFH] revision limiting sometimes ignored

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Junio C Hamano <gitster@...>
Cc: Jeff King <peff@...>, <git@...>
Date: Monday, February 4, 2008 - 4:03 pm

On Mon, 4 Feb 2008, Junio C Hamano wrote:

You're right. The proper test is actually "is the list of commits 
disconnected".

Which is not an entirely trivial thing to test for efficiently.

I suspect that we can solve it by not even bothering to be efficient, and 
instead just ask that question when we hit the "are all commits negative" 
query.

Gaah. This is that stupid apporach. The smarter one might be harder, 
especially for the special cases where you truly have two totally 
unconnected trees, ie:

	a -> b -> c

	d -> e -> f

and do

	git rev-list c f ^b ^e

were you actually do not _have_ a single connected graph at all, but you 
know the result should be "c" and "f" because they are *individually* 
connected to what we already know is uninteresting.

Not really tested at all, not really thought through. And that recursion 
avoidance could be smarter.

			Linus

---
 revision.c |   37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/revision.c b/revision.c
index 6e85aaa..26b2343 100644
--- a/revision.c
+++ b/revision.c
@@ -558,6 +558,41 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
 	free_patch_ids(&ids);
 }
 
+static inline int commit_is_connected(struct commit *commit)
+{
+	struct commit_list *parents;
+	for (;;) {
+		if (commit->object.flags & UNINTERESTING)
+			return 1;
+		parents = commit->parents;
+		if (!parents)
+			return 0;
+		if (parents->next)
+			break;
+		commit = parents->item;
+	}
+
+	do {
+		if (!commit_is_connected(parents->item))
+			return 0;
+		parents = parents->next;
+	} while (parents);
+	return 1;
+}
+
+/* Check that the positive list is connected to the negative one.. */
+static int is_connected(struct commit_list *list)
+{
+	while (list) {
+		struct commit *commit = list->item;
+
+		list = list->next;
+		if (!commit_is_connected(commit))
+			return 0;
+	}
+	return 1;
+}
+
 static int limit_list(struct rev_info *revs)
 {
 	struct commit_list *list = revs->commits;
@@ -579,7 +614,7 @@ static int limit_list(struct rev_info *revs)
 			return -1;
 		if (obj->flags & UNINTERESTING) {
 			mark_parents_uninteresting(commit);
-			if (everybody_uninteresting(list))
+			if (everybody_uninteresting(list) && is_connected(newlist))
 				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, 8:21 am)
Re: [BUG?] git log picks up bad commit, Jeff King, (Sat Feb 2, 11:00 pm)
[RFH] revision limiting sometimes ignored, Jeff King, (Sun Feb 3, 12:33 am)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Mon Feb 4, 1:32 pm)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Mon Feb 4, 3:08 pm)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Mon Feb 4, 4:03 pm)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Mon Feb 4, 4:50 pm)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Tue Feb 5, 3:14 am)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Tue Feb 5, 5:23 pm)
Re: [RFH] revision limiting sometimes ignored, Johannes Schindelin, (Tue Feb 5, 6:34 pm)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Tue Feb 5, 9:51 pm)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Wed Feb 6, 2:05 am)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Wed Feb 6, 2:17 am)
Re: [RFH] revision limiting sometimes ignored, Nicolas Pitre, (Tue Feb 5, 9:22 pm)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Tue Feb 5, 7:59 pm)
Re: [RFH] revision limiting sometimes ignored, Tilman Sauerbeck, (Wed Feb 6, 12:43 pm)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Wed Feb 6, 3:26 pm)
Re: [RFH] revision limiting sometimes ignored, Nicolas Pitre, (Wed Feb 6, 1:28 pm)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Wed Feb 6, 1:42 pm)
Re: [RFH] revision limiting sometimes ignored, Nicolas Pitre, (Wed Feb 6, 1:48 pm)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Mon Feb 4, 4:06 pm)
Re: [RFH] revision limiting sometimes ignored, Linus Torvalds, (Mon Feb 4, 1:37 pm)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Sun Feb 3, 2:39 am)
Re: [RFH] revision limiting sometimes ignored, Jeff King, (Sun Feb 3, 3:13 am)
Re: [RFH] revision limiting sometimes ignored, Jeff King, (Sun Feb 3, 3:18 am)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Sun Feb 3, 4:18 am)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Sun Feb 3, 3:40 am)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Sun Feb 3, 3:47 am)
Re: [RFH] revision limiting sometimes ignored, Junio C Hamano, (Sun Feb 3, 2:24 am)