Skip to content

Commit 002b726

Browse files
Philip Oakleygitster
authored andcommitted
builtin/help.c: add list_common_guides_help() function
This implements what "help -g" introduced in the previous step does. Signed-off-by: Philip Oakley <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 65f9835 commit 002b726

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

builtin/help.c

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,37 @@ static void show_html_page(const char *git_cmd)
415415
open_html(page_path.buf);
416416
}
417417

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+
418449
int cmd_help(int argc, const char **argv, const char *prefix)
419450
{
420451
int nongit;
@@ -432,9 +463,8 @@ int cmd_help(int argc, const char **argv, const char *prefix)
432463
list_commands(colopts, &main_cmds, &other_cmds);
433464
}
434465

435-
if (show_guides) {
436-
/* do action - next patch */
437-
}
466+
if (show_guides)
467+
list_common_guides_help();
438468

439469
if (show_all || show_guides) {
440470
printf("%s\n", _(git_more_info_string));

0 commit comments

Comments
 (0)