@@ -36,10 +36,12 @@ enum help_format {
36
36
static const char * html_path ;
37
37
38
38
static int show_all = 0 ;
39
+ static int show_guides = 0 ;
39
40
static unsigned int colopts ;
40
41
static enum help_format help_format = HELP_FORMAT_NONE ;
41
42
static struct option builtin_help_options [] = {
42
- OPT_BOOLEAN ('a' , "all" , & show_all , N_ ("print all available commands" )),
43
+ OPT_BOOL ('a' , "all" , & show_all , N_ ("print all available commands" )),
44
+ OPT_BOOL ('g' , "guides" , & show_guides , N_ ("print list of useful guides" )),
43
45
OPT_SET_INT ('m' , "man" , & help_format , N_ ("show man page" ), HELP_FORMAT_MAN ),
44
46
OPT_SET_INT ('w' , "web" , & help_format , N_ ("show manual in web browser" ),
45
47
HELP_FORMAT_WEB ),
@@ -49,7 +51,7 @@ static struct option builtin_help_options[] = {
49
51
};
50
52
51
53
static const char * const builtin_help_usage [] = {
52
- N_ ("git help [--all] [--man|--web|--info] [command]" ),
54
+ N_ ("git help [--all] [--guides] [-- man|--web|--info] [command]" ),
53
55
NULL
54
56
};
55
57
@@ -413,6 +415,37 @@ static void show_html_page(const char *git_cmd)
413
415
open_html (page_path .buf );
414
416
}
415
417
418
+ static struct {
419
+ const char * name ;
420
+ const char * help ;
421
+ } common_guides [] = {
422
+ { "attributes" , "Defining attributes per path" },
423
+ { "glossary" , "A Git glossary" },
424
+ { "ignore" , "Specifies intentionally untracked files to ignore" },
425
+ { "modules" , "Defining submodule properties" },
426
+ { "revisions" , "Specifying revisions and ranges for Git" },
427
+ { "tutorial" , "A tutorial introduction to Git (for version 1.5.1 or newer)" },
428
+ { "workflows" , "An overview of recommended workflows with Git" },
429
+ };
430
+
431
+ static void list_common_guides_help (void )
432
+ {
433
+ int i , longest = 0 ;
434
+
435
+ for (i = 0 ; i < ARRAY_SIZE (common_guides ); i ++ ) {
436
+ if (longest < strlen (common_guides [i ].name ))
437
+ longest = strlen (common_guides [i ].name );
438
+ }
439
+
440
+ puts (_ ("The common Git guides are:\n" ));
441
+ for (i = 0 ; i < ARRAY_SIZE (common_guides ); i ++ ) {
442
+ printf (" %s " , common_guides [i ].name );
443
+ mput_char (' ' , longest - strlen (common_guides [i ].name ));
444
+ puts (_ (common_guides [i ].help ));
445
+ }
446
+ putchar ('\n' );
447
+ }
448
+
416
449
int cmd_help (int argc , const char * * argv , const char * prefix )
417
450
{
418
451
int nongit ;
@@ -428,7 +461,16 @@ int cmd_help(int argc, const char **argv, const char *prefix)
428
461
git_config (git_help_config , NULL );
429
462
printf (_ ("usage: %s%s" ), _ (git_usage_string ), "\n\n" );
430
463
list_commands (colopts , & main_cmds , & other_cmds );
464
+ }
465
+
466
+ if (show_guides )
467
+ list_common_guides_help ();
468
+
469
+ if (show_all || show_guides ) {
431
470
printf ("%s\n" , _ (git_more_info_string ));
471
+ /*
472
+ * We're done. Ignore any remaining args
473
+ */
432
474
return 0 ;
433
475
}
434
476
0 commit comments