1
1
#include "builtin.h"
2
2
#include "cache.h"
3
- #include "parse-options.h"
4
3
#include "bisect.h"
5
4
#include "refs.h"
6
5
#include "dir.h"
@@ -20,20 +19,46 @@ static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES")
20
19
static GIT_PATH_FUNC (git_path_bisect_first_parent , "BISECT_FIRST_PARENT ")
21
20
static GIT_PATH_FUNC (git_path_bisect_run , "BISECT_RUN ")
22
21
23
- static const char * const git_bisect_helper_usage [] = {
24
- N_ ("git bisect--helper --bisect-reset [<commit>]" ),
25
- "git bisect--helper --bisect-terms [--term-good | --term-old | --term-bad | --term-new]" ,
26
- N_ ("git bisect--helper --bisect-start [--term-{new,bad}=<term> --term-{old,good}=<term>]"
27
- " [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<paths>...]" ),
28
- "git bisect--helper --bisect-next" ,
29
- N_ ("git bisect--helper [--bisect-state] (bad|new) [<rev>]" ),
30
- N_ ("git bisect--helper [--bisect-state] (good|old) [<rev>...]" ),
31
- N_ ("git bisect--helper --bisect-replay <filename>" ),
32
- N_ ("git bisect--helper --bisect-skip [(<rev>|<range>)...]" ),
33
- "git bisect--helper --bisect-visualize" ,
34
- N_ ("git bisect--helper --bisect-run <cmd>..." ),
35
- NULL
36
- };
22
+ static const char * bisect_usage =
23
+ N_ ("git bisect [help|start|bad|good|new|old|terms|skip|next|reset|"
24
+ "visualize|view|replay|log|run]" );
25
+
26
+ static const char * bisect_long_usage =
27
+ N_ ("git bisect [help|start|bad|good|new|old|terms|skip|next|reset|"
28
+ "visualize|view|replay|log|run]\n"
29
+ "\n"
30
+ "git bisect help\n"
31
+ "\tprint this long help message.\n"
32
+ "git bisect start [--term-{new,bad}=<term> "
33
+ "--term-{old,good}=<term>]\n"
34
+ "\t [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] "
35
+ "[<pathspec>...]\n"
36
+ "\treset bisect state and start bisection.\n"
37
+ "git bisect (bad|new) [<rev>]\n"
38
+ "\tmark <rev> a known-bad revision/\n"
39
+ "\t a revision after change in a given property.\n"
40
+ "git bisect (good|old) [<rev>...]\n"
41
+ "\tmark <rev>... known-good revisions/\n"
42
+ "\t revisions before change in a given property.\n"
43
+ "git bisect terms [--term-good | --term-bad]\n"
44
+ "\tshow the terms used for old and new commits "
45
+ "(default: bad, good)\n"
46
+ "git bisect skip [(<rev>|<range>)...]\n"
47
+ "\tmark <rev>... untestable revisions.\n"
48
+ "git bisect next\n"
49
+ "\tfind next bisection to test and check it out.\n"
50
+ "git bisect reset [<commit>]\n"
51
+ "\tfinish bisection search and go back to commit.\n"
52
+ "git bisect (visualize|view)\n"
53
+ "\tshow bisect status in gitk.\n"
54
+ "git bisect replay <logfile>\n"
55
+ "\treplay bisection log.\n"
56
+ "git bisect log\n"
57
+ "\tshow bisect log.\n"
58
+ "git bisect run <cmd>...\n"
59
+ "\tuse <cmd>... to automatically bisect.\n"
60
+ "\n"
61
+ "Please use \"git help bisect\" to get the full man page." );
37
62
38
63
struct add_bisect_ref_data {
39
64
struct rev_info * revs ;
@@ -1277,14 +1302,11 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
1277
1302
int cmd_bisect__helper (int argc , const char * * argv , const char * prefix )
1278
1303
{
1279
1304
int res = 0 ;
1280
- struct option options [] = {
1281
- OPT_END ()
1282
- };
1283
1305
struct bisect_terms terms = { .term_good = NULL , .term_bad = NULL };
1284
1306
const char * command = argc > 1 ? argv [1 ] : "help" ;
1285
1307
1286
1308
if (!strcmp ("-h" , command ) || !strcmp ("help" , command ))
1287
- usage_with_options ( git_bisect_helper_usage , options );
1309
+ usage ( bisect_long_usage );
1288
1310
1289
1311
argc -= 2 ;
1290
1312
argv += 2 ;
@@ -1327,12 +1349,13 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
1327
1349
get_terms (& terms );
1328
1350
res = bisect_run (& terms , argv , argc );
1329
1351
} else {
1352
+ if (!file_is_not_empty (git_path_bisect_start ()) &&
1353
+ !one_of (command , "bad" , "good" , "new" , "old" , NULL ))
1354
+ usage (bisect_usage );
1330
1355
set_terms (& terms , "bad" , "good" );
1331
1356
get_terms (& terms );
1332
- if (check_and_set_terms (& terms , command )) {
1333
- char * msg = xstrfmt (_ ("unknown command: '%s'" ), command );
1334
- usage_msg_opt (msg , git_bisect_helper_usage , options );
1335
- }
1357
+ if (check_and_set_terms (& terms , command ))
1358
+ usage (bisect_usage );
1336
1359
/* shift the `command` back in */
1337
1360
argc ++ ;
1338
1361
argv -- ;
0 commit comments