@matheusbsbs / matheus-bagliano / commits / 7d004199d1
Fork 0

Make revision limiting more robust against occasional bad commit dates

The revision limiter uses the commit date to decide when it has seen enough commits to finalize the revision list, but that can get confused if there are incorrect dates far in the past on some commits. This makes the logic a bit more robust by - we always walk an extra SLOP commits from the source list even if we decide that the source list is probably all done (unless the source is entirely empty, of course, because then we really can't do anything at all) - we keep track of the date of the last commit we added to the destination list (this will *generally* be the oldest entry we've seen so far) - we compare that with the youngest entry (the first one) of the source list, and if the destination is older than the source, we know we want to look at the source. which causes occasional date mishaps to be handled cleanly. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Linus Torvalds committed Mar 17, 2008 at 18:56 UTC 7d004199d134c9d465e013064f72dbc04507f6c0
2 files changed +39 -11
revision.c
+38 -10
@@ -564,14 +564,39 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
564 free_patch_ids(&ids);
565 }
566
567 -static void add_to_list(struct commit_list **p, struct commit *commit, struct commit_list *n)
567 +/* How many extra uninteresting commits we want to see.. */
568 +#define SLOP 5
569 +
570 +static int still_interesting(struct commit_list *src, unsigned long date, int slop)
571 {
569 - p = &commit_list_insert(commit, p)->next;
570 - *p = n;
572 + /*
573 + * No source list at all? We're definitely done..
574 + */
575 + if (!src)
576 + return 0;
577 +
578 + /*
579 + * Does the destination list contain entries with a date
580 + * before the source list? Definitely _not_ done.
581 + */
582 + if (date < src->item->date)
583 + return SLOP;
584 +
585 + /*
586 + * Does the source list still have interesting commits in
587 + * it? Definitely not done..
588 + */
589 + if (!everybody_uninteresting(src))
590 + return SLOP;
591 +
592 + /* Ok, we're closing in.. */
593 + return slop-1;
594 }
595
596 static int limit_list(struct rev_info *revs)
597 {
598 + int slop = SLOP;
599 + unsigned long date = ~0ul;
600 struct commit_list *list = revs->commits;
601 struct commit_list *newlist = NULL;
602 struct commit_list **p = &newlist;
@@ -591,16 +616,19 @@ static int limit_list(struct rev_info *revs)
616 return -1;
617 if (obj->flags & UNINTERESTING) {
618 mark_parents_uninteresting(commit);
594 - if (everybody_uninteresting(list)) {
595 - if (revs->show_all)
596 - add_to_list(p, commit, list);
597 - break;
598 - }
599 - if (!revs->show_all)
600 - continue;
619 + if (revs->show_all)
620 + p = &commit_list_insert(commit, p)->next;
621 + slop = still_interesting(list, date, slop);
622 + if (slop)
623 + continue;
624 + /* If showing all, add the whole pending list to the end */
625 + if (revs->show_all)
626 + *p = list;
627 + break;
628 }
629 if (revs->min_age != -1 && (commit->date > revs->min_age))
630 continue;
631 + date = commit->date;
632 p = &commit_list_insert(commit, p)->next;
633
634 show = show_early_output;
t/t6009-rev-list-parent.sh
+1 -1
@@ -27,7 +27,7 @@ test_expect_success setup '
27 git log --pretty=oneline --abbrev-commit
28 '
29
30 -test_expect_failure 'one is ancestor of others and should not be shown' '
30 +test_expect_success 'one is ancestor of others and should not be shown' '
31
32 git rev-list one --not four >result &&
33 >expect &&