Skip to content

Commit 2b02069

Browse files
chriscoolgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1c953a1 commit 2b02069

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

bisect.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ struct argv_array {
2626
int argv_alloc;
2727
};
2828

29-
struct argv_array rev_argv;
30-
3129
static const char *argv_diff_tree[] = {"diff-tree", "--pretty", NULL, NULL};
3230
static const char *argv_checkout[] = {"checkout", "-q", NULL, "--", NULL};
3331
static const char *argv_show_branch[] = {"show-branch", NULL, NULL};
@@ -539,15 +537,13 @@ struct commit_list *filter_skipped(struct commit_list *list,
539537

540538
static void bisect_rev_setup(struct rev_info *revs, const char *prefix)
541539
{
540+
struct argv_array rev_argv = { NULL, 0, 0 };
542541
int i;
543542

544543
init_revisions(revs, prefix);
545544
revs->abbrev = 0;
546545
revs->commit_format = CMIT_FMT_UNSPECIFIED;
547546

548-
if (read_bisect_refs())
549-
die("reading bisect refs failed");
550-
551547
/* rev_argv.argv[0] will be ignored by setup_revisions */
552548
argv_array_push(&rev_argv, xstrdup("bisect_rev_setup"));
553549
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)
561557
revs->limited = 1;
562558
}
563559

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)
566561
{
567-
bisect_rev_setup(revs, prefix);
568-
569562
if (prepare_revision_walk(revs))
570563
die("revision walk setup failed");
571564
if (revs->tree_objects)
@@ -636,7 +629,12 @@ int bisect_next_exit(const char *prefix)
636629
const unsigned char *bisect_rev;
637630
char bisect_rev_hex[41];
638631

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);
640638

641639
revs.commits = filter_skipped(revs.commits, &tried, 0);
642640

0 commit comments

Comments
 (0)