git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Fix interesting git-rev-list corner case
@ 2005-07-29 22:50 Linus Torvalds
  2005-07-30  0:11 ` Ryan Anderson
  2005-07-30 10:10 ` Peter Osterlund
  0 siblings, 2 replies; 15+ messages in thread
From: Linus Torvalds @ 2005-07-29 22:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List


This corner-case was triggered by a kernel commit that was not in date
order, due to a misconfigured time zone that made the commit appear three
hours older than it was.

That caused git-rev-list to traverse the commit tree in a non-obvious
order, and made it parse several of the _parents_ of the misplaced commit
before it actually parsed the commit itself. That's fine, but it meant 
that the grandparents of the commit didn't get marked uninteresting, 
because they had been reached through an "interesting" branch.

The reason was that "mark_parents_uninteresting()" (which is supposed to 
mark all existing parents as being uninteresting - duh) didn't actually 
traverse more than one level down the parent chain.

NORMALLY this is fine, since with the date-based traversal order,
grandparents won't ever even have been looked at before their parents (so
traversing the chain down isn't needed, because the next time around when 
we pick out the parent we'll mark _its_ parents uninteresting), but since 
we'd gotten out of order, we'd already seen the parent and thus never got 
around to mark the grandparents.

Anyway, the fix is simple. Just traverse parent chains recursively.  
Normally the chain won't even exist (since the parent hasn't been parsed
yet), so this is not actually going to trigger except in this strange 
corner-case.

Add a comment to the simple one-liner, since this was a bit subtle, and I 
had to really think things through to understand how it could happen.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
diff --git a/rev-list.c b/rev-list.c
--- a/rev-list.c
+++ b/rev-list.c
@@ -228,6 +228,17 @@ static void mark_parents_uninteresting(s
 		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);
+
+		/*
 		 * A missing commit is ok iff its parent is marked 
 		 * uninteresting.
 		 *

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2005-07-31  5:34 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-29 22:50 Fix interesting git-rev-list corner case Linus Torvalds
2005-07-30  0:11 ` Ryan Anderson
2005-07-30  1:08   ` A Large Angry SCM
2005-07-30  1:20   ` Linus Torvalds
2005-07-30  1:28     ` Linus Torvalds
2005-07-30 10:10 ` Peter Osterlund
2005-07-30 16:18   ` Linus Torvalds
2005-07-30 20:50     ` Peter Osterlund
2005-07-30 20:56       ` Linus Torvalds
2005-07-30 21:01         ` Peter Osterlund
2005-07-30 21:32           ` Linus Torvalds
2005-07-30 22:10             ` Linus Torvalds
2005-07-30 23:11               ` Peter Osterlund
2005-07-31  4:44                 ` Linus Torvalds
2005-07-31  5:32                   ` Junio C Hamano

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).