@matheusbsbs / matheus-bagliano / commits / 62d0b0daf1
Fork 0

bisect: when skipping, choose a commit away from a skipped commit

To do that a new function "apply_skip_ratio" is added and another function "managed_skipped" is created to wrap both "filter_skipped" and the previous one. In "managed_skipped" we detect when we should choose a commit away from a skipped one and then we automatically choose a skip ratio to pass to "apply_skip_ratio". The ratio is choosen so that it alternates between 1/5, 2/5 and 3/5. In "apply_skip_ratio", we ignore a given ratio of all the commits that could be tested. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Jun 6, 2009 at 06:41 UTC 62d0b0daf12239fdb898a0d197dfc49a5e2742b0
1 file changed +49 -1
bisect.c
+49 -1
@@ -585,6 +585,54 @@ struct commit_list *filter_skipped(struct commit_list *list,
585 return filtered;
586 }
587
588 +static struct commit_list *apply_skip_ratio(struct commit_list *list,
589 + int count,
590 + int skip_num, int skip_denom)
591 +{
592 + int index, i;
593 + struct commit_list *cur, *previous;
594 +
595 + cur = list;
596 + previous = NULL;
597 + index = count * skip_num / skip_denom;
598 +
599 + for (i = 0; cur; cur = cur->next, i++) {
600 + if (i == index) {
601 + if (hashcmp(cur->item->object.sha1, current_bad_sha1))
602 + return cur;
603 + if (previous)
604 + return previous;
605 + return list;
606 + }
607 + previous = cur;
608 + }
609 +
610 + return list;
611 +}
612 +
613 +static struct commit_list *managed_skipped(struct commit_list *list,
614 + struct commit_list **tried)
615 +{
616 + int count, skipped_first;
617 + int skip_num, skip_denom;
618 +
619 + *tried = NULL;
620 +
621 + if (!skipped_revs.sha1_nr)
622 + return list;
623 +
624 + list = filter_skipped(list, tried, 0, &count, &skipped_first);
625 +
626 + if (!skipped_first)
627 + return list;
628 +
629 + /* Use alternatively 1/5, 2/5 and 3/5 as skip ratio. */
630 + skip_num = count % 3 + 1;
631 + skip_denom = 5;
632 +
633 + return apply_skip_ratio(list, count, skip_num, skip_denom);
634 +}
635 +
636 static void bisect_rev_setup(struct rev_info *revs, const char *prefix,
637 const char *bad_format, const char *good_format,
638 int read_paths)
@@ -897,7 +945,7 @@ int bisect_next_all(const char *prefix)
945
946 revs.commits = find_bisection(revs.commits, &reaches, &all,
947 !!skipped_revs.sha1_nr);
900 - revs.commits = filter_skipped(revs.commits, &tried, 0, NULL, NULL);
948 + revs.commits = managed_skipped(revs.commits, &tried);
949
950 if (!revs.commits) {
951 /*