Skip to content

Commit a22347c

Browse files
chriscoolgitster
authored andcommitted
bisect: rework some rev related functions to make them more reusable
This patches changes the "bisect_rev_setup" and "bisect_common" functions to make it easier to reuse them in a later patch. Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0871984 commit a22347c

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

bisect.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,9 @@ struct commit_list *filter_skipped(struct commit_list *list,
553553
return filtered;
554554
}
555555

556-
static void bisect_rev_setup(struct rev_info *revs, const char *prefix)
556+
static void bisect_rev_setup(struct rev_info *revs, const char *prefix,
557+
const char *bad_format, const char *good_format,
558+
int read_paths)
557559
{
558560
struct argv_array rev_argv = { NULL, 0, 0 };
559561
int i;
@@ -564,26 +566,24 @@ static void bisect_rev_setup(struct rev_info *revs, const char *prefix)
564566

565567
/* rev_argv.argv[0] will be ignored by setup_revisions */
566568
argv_array_push(&rev_argv, xstrdup("bisect_rev_setup"));
567-
argv_array_push_sha1(&rev_argv, current_bad_sha1, "%s");
569+
argv_array_push_sha1(&rev_argv, current_bad_sha1, bad_format);
568570
for (i = 0; i < good_revs.sha1_nr; i++)
569-
argv_array_push_sha1(&rev_argv, good_revs.sha1[i], "^%s");
571+
argv_array_push_sha1(&rev_argv, good_revs.sha1[i],
572+
good_format);
570573
argv_array_push(&rev_argv, xstrdup("--"));
571-
read_bisect_paths(&rev_argv);
574+
if (read_paths)
575+
read_bisect_paths(&rev_argv);
572576
argv_array_push(&rev_argv, NULL);
573577

574578
setup_revisions(rev_argv.argv_nr, rev_argv.argv, revs, NULL);
575-
revs->limited = 1;
576579
}
577580

578-
static void bisect_common(struct rev_info *revs, int *reaches, int *all)
581+
static void bisect_common(struct rev_info *revs)
579582
{
580583
if (prepare_revision_walk(revs))
581584
die("revision walk setup failed");
582585
if (revs->tree_objects)
583586
mark_edges_uninteresting(revs->commits, revs, NULL);
584-
585-
revs->commits = find_bisection(revs->commits, reaches, all,
586-
!!skipped_revs.sha1_nr);
587587
}
588588

589589
static void exit_if_skipped_commits(struct commit_list *tried,
@@ -843,10 +843,13 @@ int bisect_next_all(const char *prefix)
843843

844844
check_good_are_ancestors_of_bad(prefix);
845845

846-
bisect_rev_setup(&revs, prefix);
846+
bisect_rev_setup(&revs, prefix, "%s", "^%s", 1);
847+
revs.limited = 1;
847848

848-
bisect_common(&revs, &reaches, &all);
849+
bisect_common(&revs);
849850

851+
revs.commits = find_bisection(revs.commits, &reaches, &all,
852+
!!skipped_revs.sha1_nr);
850853
revs.commits = filter_skipped(revs.commits, &tried, 0);
851854

852855
if (!revs.commits) {

0 commit comments

Comments
 (0)