git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>, git@vger.kernel.org
Subject: Re: [RFH] revision limiting sometimes ignored
Date: Mon, 4 Feb 2008 12:03:42 -0800 (PST)	[thread overview]
Message-ID: <alpine.LFD.1.00.0802041146060.3034@hp.linux-foundation.org> (raw)
In-Reply-To: <7vr6fsk08w.fsf@gitster.siamese.dyndns.org>



On Mon, 4 Feb 2008, Junio C Hamano wrote:
> 
> However, I am afraid that is not quite enough.  It is not just
> "when we hit the root".

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;
 		}

  reply	other threads:[~2008-02-04 20:05 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-02 12:21 [BUG?] git log picks up bad commit Tilman Sauerbeck
2008-02-03  3:00 ` Jeff King
2008-02-03  4:33   ` [RFH] revision limiting sometimes ignored Jeff King
2008-02-03  6:24     ` Junio C Hamano
2008-02-03  6:39     ` Junio C Hamano
2008-02-03  7:13       ` Jeff King
2008-02-03  7:18         ` Jeff King
2008-02-03  7:40           ` Junio C Hamano
2008-02-03  7:47             ` Junio C Hamano
2008-02-03  8:18           ` Junio C Hamano
2008-02-04 17:32     ` Linus Torvalds
2008-02-04 17:37       ` Linus Torvalds
2008-02-04 19:08       ` Junio C Hamano
2008-02-04 20:03         ` Linus Torvalds [this message]
2008-02-04 20:06           ` Linus Torvalds
2008-02-04 20:50           ` Linus Torvalds
2008-02-05  7:14             ` Junio C Hamano
2008-02-05 21:23               ` Linus Torvalds
2008-02-05 22:34                 ` Johannes Schindelin
2008-02-05 23:59                   ` Linus Torvalds
2008-02-06 16:43                     ` Tilman Sauerbeck
2008-02-06 17:28                       ` Nicolas Pitre
2008-02-06 17:42                         ` Linus Torvalds
2008-02-06 17:48                           ` Nicolas Pitre
2008-02-06 19:26                       ` Linus Torvalds
2008-02-06  1:22                   ` Nicolas Pitre
2008-02-06  1:51                   ` Junio C Hamano
2008-02-06  6:05                     ` Junio C Hamano
2008-02-06  6:17                       ` Junio C Hamano
2008-02-05 23:44                 ` Junio C Hamano
2008-02-06  0:52                   ` Linus Torvalds
2008-02-06  5:30                     ` Junio C Hamano
2008-02-06  8:16                       ` Karl Hasselström
2008-02-06 10:34                       ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.1.00.0802041146060.3034@hp.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).