521
return strbuf_detach(&joined_hexs, NULL);
522
}
523
524
+/*
525
+ * In this function, passing a not NULL skipped_first is very special.
526
+ * It means that we want to know if the first commit in the list is
527
+ * skipped because we will want to test a commit away from it if it is
528
+ * indeed skipped.
529
+ * So if the first commit is skipped, we cannot take the shortcut to
530
+ * just "return list" when we find the first non skipped commit, we
531
+ * have to return a fully filtered list.
532
+ *
533
+ * We use (*skipped_first == -1) to mean "it has been found that the
534
+ * first commit is not skipped". In this case *skipped_first is set back
535
+ * to 0 just before the function returns.
536
+ */
537
struct commit_list *filter_skipped(struct commit_list *list,
538
struct commit_list **tried,
526
- int show_all)
539
+ int show_all,
540
+ int *count,
541
+ int *skipped_first)
542
{
543
struct commit_list *filtered = NULL, **f = &filtered;
544
545
*tried = NULL;
546
547
+ if (skipped_first)
548
+ *skipped_first = 0;
549
+ if (count)
550
+ *count = 0;
551
+
552
if (!skipped_revs.sha1_nr)
553
return list;
554
557
list->next = NULL;
558
if (0 <= lookup_sha1_array(&skipped_revs,
559
list->item->object.sha1)) {
560
+ if (skipped_first && !*skipped_first)
561
+ *skipped_first = 1;
562
/* Move current to tried list */
563
*tried = list;
564
tried = &list->next;
565
} else {
544
- if (!show_all)
545
- return list;
566
+ if (!show_all) {
567
+ if (!skipped_first || !*skipped_first)
568
+ return list;
569
+ } else if (skipped_first && !*skipped_first) {
570
+ /* This means we know it's not skipped */
571
+ *skipped_first = -1;
572
+ }
573
/* Move current to filtered list */
574
*f = list;
575
f = &list->next;
576
+ if (count)
577
+ (*count)++;
578
}
579
list = next;
580
}
581
582
+ if (skipped_first && *skipped_first == -1)
583
+ *skipped_first = 0;
584
+
585
return filtered;
586
}
587
897
898
revs.commits = find_bisection(revs.commits, &reaches, &all,
899
!!skipped_revs.sha1_nr);
868
- revs.commits = filter_skipped(revs.commits, &tried, 0);
900
+ revs.commits = filter_skipped(revs.commits, &tried, 0, NULL, NULL);
901
902
if (!revs.commits) {
903
/*