Skip to content

Commit 6f97792

Browse files
avargitster
authored andcommitted
bisect--helper: make the order consistently argc, argv
In C, the natural order is for `argc` to come before `argv` by virtue of the `main()` function declaring the parameters in precisely that order. It is confusing & distracting, then, when readers familiar with the C language read code where that order is switched around. Let's just change the order and avoid that type of developer friction. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7a8d7aa commit 6f97792

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

builtin/bisect.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,8 @@ static enum bisect_error bisect_auto_next(struct bisect_terms *terms, const char
678678
return bisect_next(terms, prefix);
679679
}
680680

681-
static enum bisect_error bisect_start(struct bisect_terms *terms, const char **argv, int argc)
681+
static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
682+
const char **argv)
682683
{
683684
int no_checkout = 0;
684685
int first_parent_only = 0;
@@ -908,13 +909,13 @@ static int bisect_autostart(struct bisect_terms *terms)
908909
yesno = git_prompt(_("Do you want me to do it for you "
909910
"[Y/n]? "), PROMPT_ECHO);
910911
res = tolower(*yesno) == 'n' ?
911-
-1 : bisect_start(terms, empty_strvec, 0);
912+
-1 : bisect_start(terms, 0, empty_strvec);
912913

913914
return res;
914915
}
915916

916-
static enum bisect_error bisect_state(struct bisect_terms *terms, const char **argv,
917-
int argc)
917+
static enum bisect_error bisect_state(struct bisect_terms *terms, int argc,
918+
const char **argv)
918919
{
919920
const char *state;
920921
int i, verify_expected = 1;
@@ -1033,7 +1034,7 @@ static int process_replay_line(struct bisect_terms *terms, struct strbuf *line)
10331034
struct strvec argv = STRVEC_INIT;
10341035
int res;
10351036
sq_dequote_to_strvec(rev, &argv);
1036-
res = bisect_start(terms, argv.v, argv.nr);
1037+
res = bisect_start(terms, argv.nr, argv.v);
10371038
strvec_clear(&argv);
10381039
return res;
10391040
}
@@ -1083,7 +1084,8 @@ static enum bisect_error bisect_replay(struct bisect_terms *terms, const char *f
10831084
return bisect_auto_next(terms, NULL);
10841085
}
10851086

1086-
static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **argv, int argc)
1087+
static enum bisect_error bisect_skip(struct bisect_terms *terms, int argc,
1088+
const char **argv)
10871089
{
10881090
int i;
10891091
enum bisect_error res;
@@ -1113,13 +1115,14 @@ static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **ar
11131115
strvec_push(&argv_state, argv[i]);
11141116
}
11151117
}
1116-
res = bisect_state(terms, argv_state.v, argv_state.nr);
1118+
res = bisect_state(terms, argv_state.nr, argv_state.v);
11171119

11181120
strvec_clear(&argv_state);
11191121
return res;
11201122
}
11211123

1122-
static int bisect_visualize(struct bisect_terms *terms, const char **argv, int argc)
1124+
static int bisect_visualize(struct bisect_terms *terms, int argc,
1125+
const char **argv)
11231126
{
11241127
struct child_process cmd = CHILD_PROCESS_INIT;
11251128
struct strbuf sb = STRBUF_INIT;
@@ -1202,7 +1205,7 @@ static int verify_good(const struct bisect_terms *terms, const char *command)
12021205
return rc;
12031206
}
12041207

1205-
static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
1208+
static int bisect_run(struct bisect_terms *terms, int argc, const char **argv)
12061209
{
12071210
int res = BISECT_OK;
12081211
struct strbuf command = STRBUF_INIT;
@@ -1271,7 +1274,7 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
12711274
saved_stdout = dup(1);
12721275
dup2(temporary_stdout_fd, 1);
12731276

1274-
res = bisect_state(terms, &new_state, 1);
1277+
res = bisect_state(terms, 1, &new_state);
12751278

12761279
fflush(stdout);
12771280
dup2(saved_stdout, 1);
@@ -1328,7 +1331,7 @@ static int cmd_bisect__start(int argc, const char **argv, const char *prefix UNU
13281331
struct bisect_terms terms = { 0 };
13291332

13301333
set_terms(&terms, "bad", "good");
1331-
res = bisect_start(&terms, argv, argc);
1334+
res = bisect_start(&terms, argc, argv);
13321335
free_terms(&terms);
13331336
return res;
13341337
}
@@ -1372,7 +1375,7 @@ static int cmd_bisect__skip(int argc, const char **argv, const char *prefix UNUS
13721375

13731376
set_terms(&terms, "bad", "good");
13741377
get_terms(&terms);
1375-
res = bisect_skip(&terms, argv, argc);
1378+
res = bisect_skip(&terms, argc, argv);
13761379
free_terms(&terms);
13771380
return res;
13781381
}
@@ -1383,7 +1386,7 @@ static int cmd_bisect__visualize(int argc, const char **argv, const char *prefix
13831386
struct bisect_terms terms = { 0 };
13841387

13851388
get_terms(&terms);
1386-
res = bisect_visualize(&terms, argv, argc);
1389+
res = bisect_visualize(&terms, argc, argv);
13871390
free_terms(&terms);
13881391
return res;
13891392
}
@@ -1396,7 +1399,7 @@ static int cmd_bisect__run(int argc, const char **argv, const char *prefix UNUSE
13961399
if (!argc)
13971400
return error(_("'%s' failed: no command provided."), "git bisect run");
13981401
get_terms(&terms);
1399-
res = bisect_run(&terms, argv, argc);
1402+
res = bisect_run(&terms, argc, argv);
14001403
free_terms(&terms);
14011404
return res;
14021405
}
@@ -1432,7 +1435,7 @@ int cmd_bisect(int argc, const char **argv, const char *prefix)
14321435
if (check_and_set_terms(&terms, argv[0]))
14331436
usage_msg_optf(_("unknown command: '%s'"), git_bisect_usage,
14341437
options, argv[0]);
1435-
res = bisect_state(&terms, argv, argc);
1438+
res = bisect_state(&terms, argc, argv);
14361439
free_terms(&terms);
14371440
} else {
14381441
argc--;

0 commit comments

Comments
 (0)