@matheusbsbs / matheus-bagliano / commits / a22347c6c8
Fork 0

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 <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed May 17, 2009 at 17:36 UTC a22347c6c866c94e9e941b1b39d57ea43218af96
1 file changed +14 -11
bisect.c
+14 -11
@@ -553,7 +553,9 @@ struct commit_list *filter_skipped(struct commit_list *list,
553 return filtered;
554 }
555
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)
559 {
560 struct argv_array rev_argv = { NULL, 0, 0 };
561 int i;
@@ -564,26 +566,24 @@ static void bisect_rev_setup(struct rev_info *revs, const char *prefix)
566
567 /* rev_argv.argv[0] will be ignored by setup_revisions */
568 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);
570 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);
573 argv_array_push(&rev_argv, xstrdup("--"));
571 - read_bisect_paths(&rev_argv);
574 + if (read_paths)
575 + read_bisect_paths(&rev_argv);
576 argv_array_push(&rev_argv, NULL);
577
578 setup_revisions(rev_argv.argv_nr, rev_argv.argv, revs, NULL);
575 - revs->limited = 1;
579 }
580
578 -static void bisect_common(struct rev_info *revs, int *reaches, int *all)
581 +static void bisect_common(struct rev_info *revs)
582 {
583 if (prepare_revision_walk(revs))
584 die("revision walk setup failed");
585 if (revs->tree_objects)
586 mark_edges_uninteresting(revs->commits, revs, NULL);
584 -
585 - revs->commits = find_bisection(revs->commits, reaches, all,
586 - !!skipped_revs.sha1_nr);
587 }
588
589 static void exit_if_skipped_commits(struct commit_list *tried,
@@ -843,10 +843,13 @@ int bisect_next_all(const char *prefix)
843
844 check_good_are_ancestors_of_bad(prefix);
845
846 - bisect_rev_setup(&revs, prefix);
846 + bisect_rev_setup(&revs, prefix, "%s", "^%s", 1);
847 + revs.limited = 1;
848
848 - bisect_common(&revs, &reaches, &all);
849 + bisect_common(&revs);
850
851 + revs.commits = find_bisection(revs.commits, &reaches, &all,
852 + !!skipped_revs.sha1_nr);
853 revs.commits = filter_skipped(revs.commits, &tried, 0);
854
855 if (!revs.commits) {