@matheusbsbs / matheus-bagliano / commits / 2b020695e4
Fork 0

bisect: remove too much function nesting

This patch moves some function calls into "bisect_next_exit" so that functions are nesting less. The call to "bisect_rev_setup" is moved from "bisect_common" into "bisect_next_exit" and the call to "read_bisect_refs" from "bisect_rev_setup" into "bisect_next_exit". While at it, "rev_argv" is moved into "bisect_rev_setup". This will make it easier and cleaner to implement checking merge bases. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed May 9, 2009 at 17:55 UTC 2b020695e4db8dbaee7997090aec08760903291b
1 file changed +8 -10
bisect.c
+8 -10
@@ -26,8 +26,6 @@ struct argv_array {
26 int argv_alloc;
27 };
28
29 -struct argv_array rev_argv;
30 -
29 static const char *argv_diff_tree[] = {"diff-tree", "--pretty", NULL, NULL};
30 static const char *argv_checkout[] = {"checkout", "-q", NULL, "--", NULL};
31 static const char *argv_show_branch[] = {"show-branch", NULL, NULL};
@@ -539,15 +537,13 @@ struct commit_list *filter_skipped(struct commit_list *list,
537
538 static void bisect_rev_setup(struct rev_info *revs, const char *prefix)
539 {
540 + struct argv_array rev_argv = { NULL, 0, 0 };
541 int i;
542
543 init_revisions(revs, prefix);
544 revs->abbrev = 0;
545 revs->commit_format = CMIT_FMT_UNSPECIFIED;
546
548 - if (read_bisect_refs())
549 - die("reading bisect refs failed");
550 -
547 /* rev_argv.argv[0] will be ignored by setup_revisions */
548 argv_array_push(&rev_argv, xstrdup("bisect_rev_setup"));
549 argv_array_push_sha1(&rev_argv, current_bad_sha1, "%s");
@@ -561,11 +557,8 @@ static void bisect_rev_setup(struct rev_info *revs, const char *prefix)
557 revs->limited = 1;
558 }
559
564 -static void bisect_common(struct rev_info *revs, const char *prefix,
565 - int *reaches, int *all)
560 +static void bisect_common(struct rev_info *revs, int *reaches, int *all)
561 {
567 - bisect_rev_setup(revs, prefix);
568 -
562 if (prepare_revision_walk(revs))
563 die("revision walk setup failed");
564 if (revs->tree_objects)
@@ -636,7 +629,12 @@ int bisect_next_exit(const char *prefix)
629 const unsigned char *bisect_rev;
630 char bisect_rev_hex[41];
631
639 - bisect_common(&revs, prefix, &reaches, &all);
632 + if (read_bisect_refs())
633 + die("reading bisect refs failed");
634 +
635 + bisect_rev_setup(&revs, prefix);
636 +
637 + bisect_common(&revs, &reaches, &all);
638
639 revs.commits = filter_skipped(revs.commits, &tried, 0);
640