@@ -1277,6 +1277,117 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
1277
1277
return res ;
1278
1278
}
1279
1279
1280
+ static int cmd_bisect__reset (int argc , const char * * argv , const char * prefix UNUSED )
1281
+ {
1282
+ if (argc > 1 )
1283
+ return error (_ ("--bisect-reset requires either no argument or a commit" ));
1284
+ return bisect_reset (argc ? argv [0 ] : NULL );
1285
+ }
1286
+
1287
+ static int cmd_bisect__terms (int argc , const char * * argv , const char * prefix UNUSED )
1288
+ {
1289
+ int res ;
1290
+ struct bisect_terms terms = { 0 };
1291
+
1292
+ if (argc > 1 )
1293
+ return error (_ ("--bisect-terms requires 0 or 1 argument" ));
1294
+ res = bisect_terms (& terms , argc == 1 ? argv [0 ] : NULL );
1295
+ free_terms (& terms );
1296
+ return res ;
1297
+ }
1298
+
1299
+ static int cmd_bisect__start (int argc , const char * * argv , const char * prefix UNUSED )
1300
+ {
1301
+ int res ;
1302
+ struct bisect_terms terms = { 0 };
1303
+
1304
+ set_terms (& terms , "bad" , "good" );
1305
+ res = bisect_start (& terms , argv , argc );
1306
+ free_terms (& terms );
1307
+ return res ;
1308
+ }
1309
+
1310
+ static int cmd_bisect__next (int argc , const char * * argv UNUSED , const char * prefix )
1311
+ {
1312
+ int res ;
1313
+ struct bisect_terms terms = { 0 };
1314
+
1315
+ if (argc )
1316
+ return error (_ ("--bisect-next requires 0 arguments" ));
1317
+ get_terms (& terms );
1318
+ res = bisect_next (& terms , prefix );
1319
+ free_terms (& terms );
1320
+ return res ;
1321
+ }
1322
+
1323
+ static int cmd_bisect__state (int argc , const char * * argv , const char * prefix UNUSED )
1324
+ {
1325
+ int res ;
1326
+ struct bisect_terms terms = { 0 };
1327
+
1328
+ set_terms (& terms , "bad" , "good" );
1329
+ get_terms (& terms );
1330
+ res = bisect_state (& terms , argv , argc );
1331
+ free_terms (& terms );
1332
+ return res ;
1333
+ }
1334
+
1335
+ static int cmd_bisect__log (int argc , const char * * argv UNUSED , const char * prefix UNUSED )
1336
+ {
1337
+ if (argc )
1338
+ return error (_ ("--bisect-log requires 0 arguments" ));
1339
+ return bisect_log ();
1340
+ }
1341
+
1342
+ static int cmd_bisect__replay (int argc , const char * * argv , const char * prefix UNUSED )
1343
+ {
1344
+ int res ;
1345
+ struct bisect_terms terms = { 0 };
1346
+
1347
+ if (argc != 1 )
1348
+ return error (_ ("no logfile given" ));
1349
+ set_terms (& terms , "bad" , "good" );
1350
+ res = bisect_replay (& terms , argv [0 ]);
1351
+ free_terms (& terms );
1352
+ return res ;
1353
+ }
1354
+
1355
+ static int cmd_bisect__skip (int argc , const char * * argv , const char * prefix UNUSED )
1356
+ {
1357
+ int res ;
1358
+ struct bisect_terms terms = { 0 };
1359
+
1360
+ set_terms (& terms , "bad" , "good" );
1361
+ get_terms (& terms );
1362
+ res = bisect_skip (& terms , argv , argc );
1363
+ free_terms (& terms );
1364
+ return res ;
1365
+ }
1366
+
1367
+ static int cmd_bisect__visualize (int argc , const char * * argv , const char * prefix UNUSED )
1368
+ {
1369
+ int res ;
1370
+ struct bisect_terms terms = { 0 };
1371
+
1372
+ get_terms (& terms );
1373
+ res = bisect_visualize (& terms , argv , argc );
1374
+ free_terms (& terms );
1375
+ return res ;
1376
+ }
1377
+
1378
+ static int cmd_bisect__run (int argc , const char * * argv , const char * prefix UNUSED )
1379
+ {
1380
+ int res ;
1381
+ struct bisect_terms terms = { 0 };
1382
+
1383
+ if (!argc )
1384
+ return error (_ ("bisect run failed: no command provided." ));
1385
+ get_terms (& terms );
1386
+ res = bisect_run (& terms , argv , argc );
1387
+ free_terms (& terms );
1388
+ return res ;
1389
+ }
1390
+
1280
1391
int cmd_bisect__helper (int argc , const char * * argv , const char * prefix )
1281
1392
{
1282
1393
enum {
@@ -1316,8 +1427,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
1316
1427
N_ ("use <cmd>... to automatically bisect" ), BISECT_RUN ),
1317
1428
OPT_END ()
1318
1429
};
1319
- struct bisect_terms terms = { .term_good = NULL , .term_bad = NULL };
1320
-
1321
1430
argc = parse_options (argc , argv , prefix , options ,
1322
1431
git_bisect_helper_usage ,
1323
1432
PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_UNKNOWN_OPT );
@@ -1327,60 +1436,38 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
1327
1436
1328
1437
switch (cmdmode ) {
1329
1438
case BISECT_RESET :
1330
- if (argc > 1 )
1331
- return error (_ ("--bisect-reset requires either no argument or a commit" ));
1332
- res = bisect_reset (argc ? argv [0 ] : NULL );
1439
+ res = cmd_bisect__reset (argc , argv , prefix );
1333
1440
break ;
1334
1441
case BISECT_TERMS :
1335
- if (argc > 1 )
1336
- return error (_ ("--bisect-terms requires 0 or 1 argument" ));
1337
- res = bisect_terms (& terms , argc == 1 ? argv [0 ] : NULL );
1442
+ res = cmd_bisect__terms (argc , argv , prefix );
1338
1443
break ;
1339
1444
case BISECT_START :
1340
- set_terms (& terms , "bad" , "good" );
1341
- res = bisect_start (& terms , argv , argc );
1445
+ res = cmd_bisect__start (argc , argv , prefix );
1342
1446
break ;
1343
1447
case BISECT_NEXT :
1344
- if (argc )
1345
- return error (_ ("--bisect-next requires 0 arguments" ));
1346
- get_terms (& terms );
1347
- res = bisect_next (& terms , prefix );
1448
+ res = cmd_bisect__next (argc , argv , prefix );
1348
1449
break ;
1349
1450
case BISECT_STATE :
1350
- set_terms (& terms , "bad" , "good" );
1351
- get_terms (& terms );
1352
- res = bisect_state (& terms , argv , argc );
1451
+ res = cmd_bisect__state (argc , argv , prefix );
1353
1452
break ;
1354
1453
case BISECT_LOG :
1355
- if (argc )
1356
- return error (_ ("--bisect-log requires 0 arguments" ));
1357
- res = bisect_log ();
1454
+ res = cmd_bisect__log (argc , argv , prefix );
1358
1455
break ;
1359
1456
case BISECT_REPLAY :
1360
- if (argc != 1 )
1361
- return error (_ ("no logfile given" ));
1362
- set_terms (& terms , "bad" , "good" );
1363
- res = bisect_replay (& terms , argv [0 ]);
1457
+ res = cmd_bisect__replay (argc , argv , prefix );
1364
1458
break ;
1365
1459
case BISECT_SKIP :
1366
- set_terms (& terms , "bad" , "good" );
1367
- get_terms (& terms );
1368
- res = bisect_skip (& terms , argv , argc );
1460
+ res = cmd_bisect__skip (argc , argv , prefix );
1369
1461
break ;
1370
1462
case BISECT_VISUALIZE :
1371
- get_terms (& terms );
1372
- res = bisect_visualize (& terms , argv , argc );
1463
+ res = cmd_bisect__visualize (argc , argv , prefix );
1373
1464
break ;
1374
1465
case BISECT_RUN :
1375
- if (!argc )
1376
- return error (_ ("bisect run failed: no command provided." ));
1377
- get_terms (& terms );
1378
- res = bisect_run (& terms , argv , argc );
1466
+ res = cmd_bisect__run (argc , argv , prefix );
1379
1467
break ;
1380
1468
default :
1381
1469
BUG ("unknown subcommand %d" , cmdmode );
1382
1470
}
1383
- free_terms (& terms );
1384
1471
1385
1472
/*
1386
1473
* Handle early success
0 commit comments