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 <avarab@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Jan 12, 2023 at 16:19 UTC
6f977922853d7d1d99dc07f2f33ed0af54148834
1 file changed
+18
-15
builtin/bisect.c
+18
-15
@@ -678,7 +678,8 @@ static enum bisect_error bisect_auto_next(struct bisect_terms *terms, const char
678
return bisect_next(terms, prefix);
679
}
680
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)
683
{
684
int no_checkout = 0;
685
int first_parent_only = 0;
@@ -908,13 +909,13 @@ static int bisect_autostart(struct bisect_terms *terms)
909
yesno = git_prompt(_("Do you want me to do it for you "
910
"[Y/n]? "), PROMPT_ECHO);
911
res = tolower(*yesno) == 'n' ?
911
- -1 : bisect_start(terms, empty_strvec, 0);
912
+ -1 : bisect_start(terms, 0, empty_strvec);
913
914
return res;
915
}
916
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)
919
{
920
const char *state;
921
int i, verify_expected = 1;
@@ -1033,7 +1034,7 @@ static int process_replay_line(struct bisect_terms *terms, struct strbuf *line)
1034
struct strvec argv = STRVEC_INIT;
1035
int res;
1036
sq_dequote_to_strvec(rev, &argv);
1036
- res = bisect_start(terms, argv.v, argv.nr);
1037
+ res = bisect_start(terms, argv.nr, argv.v);
1038
strvec_clear(&argv);
1039
return res;
1040
}
@@ -1083,7 +1084,8 @@ static enum bisect_error bisect_replay(struct bisect_terms *terms, const char *f
1084
return bisect_auto_next(terms, NULL);
1085
}
1086
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)
1089
{
1090
int i;
1091
enum bisect_error res;
@@ -1113,13 +1115,14 @@ static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **ar
1115
strvec_push(&argv_state, argv[i]);
1116
}
1117
}
1116
- res = bisect_state(terms, argv_state.v, argv_state.nr);
1118
+ res = bisect_state(terms, argv_state.nr, argv_state.v);
1119
1120
strvec_clear(&argv_state);
1121
return res;
1122
}
1123
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)
1126
{
1127
struct child_process cmd = CHILD_PROCESS_INIT;
1128
struct strbuf sb = STRBUF_INIT;
@@ -1202,7 +1205,7 @@ static int verify_good(const struct bisect_terms *terms, const char *command)
1205
return rc;
1206
}
1207
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)
1209
{
1210
int res = BISECT_OK;
1211
struct strbuf command = STRBUF_INIT;
@@ -1271,7 +1274,7 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
1274
saved_stdout = dup(1);
1275
dup2(temporary_stdout_fd, 1);
1276
1274
- res = bisect_state(terms, &new_state, 1);
1277
+ res = bisect_state(terms, 1, &new_state);
1278
1279
fflush(stdout);
1280
dup2(saved_stdout, 1);
@@ -1328,7 +1331,7 @@ static int cmd_bisect__start(int argc, const char **argv, const char *prefix UNU
1331
struct bisect_terms terms = { 0 };
1332
1333
set_terms(&terms, "bad", "good");
1331
- res = bisect_start(&terms, argv, argc);
1334
+ res = bisect_start(&terms, argc, argv);
1335
free_terms(&terms);
1336
return res;
1337
}
@@ -1372,7 +1375,7 @@ static int cmd_bisect__skip(int argc, const char **argv, const char *prefix UNUS
1375
1376
set_terms(&terms, "bad", "good");
1377
get_terms(&terms);
1375
- res = bisect_skip(&terms, argv, argc);
1378
+ res = bisect_skip(&terms, argc, argv);
1379
free_terms(&terms);
1380
return res;
1381
}
@@ -1383,7 +1386,7 @@ static int cmd_bisect__visualize(int argc, const char **argv, const char *prefix
1386
struct bisect_terms terms = { 0 };
1387
1388
get_terms(&terms);
1386
- res = bisect_visualize(&terms, argv, argc);
1389
+ res = bisect_visualize(&terms, argc, argv);
1390
free_terms(&terms);
1391
return res;
1392
}
@@ -1396,7 +1399,7 @@ static int cmd_bisect__run(int argc, const char **argv, const char *prefix UNUSE
1399
if (!argc)
1400
return error(_("'%s' failed: no command provided."), "git bisect run");
1401
get_terms(&terms);
1399
- res = bisect_run(&terms, argv, argc);
1402
+ res = bisect_run(&terms, argc, argv);
1403
free_terms(&terms);
1404
return res;
1405
}
@@ -1432,7 +1435,7 @@ int cmd_bisect(int argc, const char **argv, const char *prefix)
1435
if (check_and_set_terms(&terms, argv[0]))
1436
usage_msg_optf(_("unknown command: '%s'"), git_bisect_usage,
1437
options, argv[0]);
1435
- res = bisect_state(&terms, argv, argc);
1438
+ res = bisect_state(&terms, argc, argv);
1439
free_terms(&terms);
1440
} else {
1441
argc--;