From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: pclouds@gmail.com
Cc: git@vger.kernel.org, gitster@pobox.com, sunshine@sunshineco.com,
szeder.dev@gmail.com
Subject: [PATCH v6 10/13] help: use command-list.txt for the source of guides
Date: Mon, 7 May 2018 19:52:19 +0200 [thread overview]
Message-ID: <20180507175222.12114-11-pclouds@gmail.com> (raw)
In-Reply-To: <20180507175222.12114-1-pclouds@gmail.com>
The help command currently hard codes the list of guides and their
summary in C. Let's move this list to command-list.txt. This lets us
extract summary lines from Documentation/git*.txt. This also
potentially lets us list guides in git.txt, but I'll leave that for
now.
---
Documentation/gitattributes.txt | 2 +-
Documentation/gitmodules.txt | 2 +-
Documentation/gitrevisions.txt | 2 +-
Makefile | 2 +-
builtin/help.c | 32 --------------------------
command-list.txt | 16 +++++++++++++
contrib/completion/git-completion.bash | 15 ++++++++----
help.c | 21 +++++++++++++----
help.h | 1 +
t/t0012-help.sh | 6 +++++
10 files changed, 54 insertions(+), 45 deletions(-)
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index 1094fe2b5b..083c2f380d 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -3,7 +3,7 @@ gitattributes(5)
NAME
----
-gitattributes - defining attributes per path
+gitattributes - Defining attributes per path
SYNOPSIS
--------
diff --git a/Documentation/gitmodules.txt b/Documentation/gitmodules.txt
index db5d47eb19..4d63def206 100644
--- a/Documentation/gitmodules.txt
+++ b/Documentation/gitmodules.txt
@@ -3,7 +3,7 @@ gitmodules(5)
NAME
----
-gitmodules - defining submodule properties
+gitmodules - Defining submodule properties
SYNOPSIS
--------
diff --git a/Documentation/gitrevisions.txt b/Documentation/gitrevisions.txt
index 27dec5b91d..1f6cceaefb 100644
--- a/Documentation/gitrevisions.txt
+++ b/Documentation/gitrevisions.txt
@@ -3,7 +3,7 @@ gitrevisions(7)
NAME
----
-gitrevisions - specifying revisions and ranges for Git
+gitrevisions - Specifying revisions and ranges for Git
SYNOPSIS
--------
diff --git a/Makefile b/Makefile
index a60a78ee67..1efb751e46 100644
--- a/Makefile
+++ b/Makefile
@@ -1937,7 +1937,7 @@ $(BUILT_INS): git$X
command-list.h: generate-cmdlist.sh command-list.txt
-command-list.h: $(wildcard Documentation/git-*.txt)
+command-list.h: $(wildcard Documentation/git*.txt)
$(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh command-list.txt >$@+ && mv $@+ $@
SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\
diff --git a/builtin/help.c b/builtin/help.c
index 0e0af8426a..5727fb5e51 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -402,38 +402,6 @@ static void show_html_page(const char *git_cmd)
open_html(page_path.buf);
}
-static struct {
- const char *name;
- const char *help;
-} common_guides[] = {
- { "attributes", N_("Defining attributes per path") },
- { "everyday", N_("Everyday Git With 20 Commands Or So") },
- { "glossary", N_("A Git glossary") },
- { "ignore", N_("Specifies intentionally untracked files to ignore") },
- { "modules", N_("Defining submodule properties") },
- { "revisions", N_("Specifying revisions and ranges for Git") },
- { "tutorial", N_("A tutorial introduction to Git (for version 1.5.1 or newer)") },
- { "workflows", N_("An overview of recommended workflows with Git") },
-};
-
-static void list_common_guides_help(void)
-{
- int i, longest = 0;
-
- for (i = 0; i < ARRAY_SIZE(common_guides); i++) {
- if (longest < strlen(common_guides[i].name))
- longest = strlen(common_guides[i].name);
- }
-
- puts(_("The common Git guides are:\n"));
- for (i = 0; i < ARRAY_SIZE(common_guides); i++) {
- printf(" %s ", common_guides[i].name);
- mput_char(' ', longest - strlen(common_guides[i].name));
- puts(_(common_guides[i].help));
- }
- putchar('\n');
-}
-
static const char *check_git_cmd(const char* cmd)
{
char *alias;
diff --git a/command-list.txt b/command-list.txt
index 3bd23201a6..99ddc231c1 100644
--- a/command-list.txt
+++ b/command-list.txt
@@ -139,3 +139,19 @@ gitweb ancillaryinterrogators
git-whatchanged ancillaryinterrogators
git-worktree mainporcelain
git-write-tree plumbingmanipulators
+gitattributes guide
+gitcli guide
+gitcore-tutorial guide
+gitcvs-migration guide
+gitdiffcore guide
+giteveryday guide
+gitglossary guide
+githooks guide
+gitignore guide
+gitmodules guide
+gitnamespaces guide
+gitrepository-layout guide
+gitrevisions guide
+gittutorial-2 guide
+gittutorial guide
+gitworkflows guide
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 62ca8641f4..4e724a5b76 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1575,6 +1575,13 @@ _git_grep ()
__git_complete_refs
}
+__git_all_guides=
+__git_compute_all_guides ()
+{
+ test -n "$__git_all_guides" ||
+ __git_all_guides=$(git --list-cmds=list-guide)
+}
+
_git_help ()
{
case "$cur" in
@@ -1584,11 +1591,9 @@ _git_help ()
;;
esac
__git_compute_all_commands
- __gitcomp "$__git_all_commands $(__git_aliases)
- attributes cli core-tutorial cvs-migration
- diffcore everyday gitk glossary hooks ignore modules
- namespaces repository-layout revisions tutorial tutorial-2
- workflows
+ __git_compute_all_guides
+ __gitcomp "$__git_all_commands $(__git_aliases) $__git_all_guides
+ gitk
"
}
diff --git a/help.c b/help.c
index c7df1d2338..23924dd300 100644
--- a/help.c
+++ b/help.c
@@ -39,12 +39,14 @@ static struct category_description main_categories[] = {
{ 0, NULL }
};
-static const char *drop_prefix(const char *name)
+static const char *drop_prefix(const char *name, uint32_t category)
{
const char *new_name;
if (skip_prefix(name, "git-", &new_name))
return new_name;
+ if (category == CAT_guide && skip_prefix(name, "git", &new_name))
+ return new_name;
return name;
}
@@ -66,7 +68,7 @@ static void extract_cmds(struct cmdname_help **p_cmds, uint32_t mask)
continue;
cmds[nr] = *cmd;
- cmds[nr].name = drop_prefix(cmd->name);
+ cmds[nr].name = drop_prefix(cmd->name, cmd->category);
nr++;
}
@@ -358,11 +360,22 @@ void list_cmds_by_category(struct string_list *list,
for (i = 0; i < n; i++) {
struct cmdname_help *cmd = command_list + i;
- if (cmd->category & cat_id)
- string_list_append(list, drop_prefix(cmd->name));
+ if (!(cmd->category & cat_id))
+ continue;
+ string_list_append(list, drop_prefix(cmd->name, cmd->category));
}
}
+void list_common_guides_help(void)
+{
+ struct category_description catdesc[] = {
+ { CAT_guide, N_("The common Git guides are:") },
+ { 0, NULL }
+ };
+ print_cmd_by_category(catdesc);
+ putchar('\n');
+}
+
void list_all_cmds_help(void)
{
print_cmd_by_category(main_categories);
diff --git a/help.h b/help.h
index 40917fc38c..b2293e99be 100644
--- a/help.h
+++ b/help.h
@@ -20,6 +20,7 @@ static inline void mput_char(char c, unsigned int num)
extern void list_common_cmds_help(void);
extern void list_all_cmds_help(void);
+extern void list_common_guides_help(void);
extern void list_all_main_cmds(struct string_list *list);
extern void list_all_other_cmds(struct string_list *list);
diff --git a/t/t0012-help.sh b/t/t0012-help.sh
index 060df24c2d..bc27df7f38 100755
--- a/t/t0012-help.sh
+++ b/t/t0012-help.sh
@@ -66,6 +66,12 @@ test_expect_success 'git help' '
test_i18ngrep "^ commit " help.output &&
test_i18ngrep "^ fetch " help.output
'
+test_expect_success 'git help -g' '
+ git help -g >help.output &&
+ test_i18ngrep "^ attributes " help.output &&
+ test_i18ngrep "^ everyday " help.output &&
+ test_i18ngrep "^ tutorial " help.output
+'
test_expect_success 'generate builtin list' '
git --list-cmds=builtins >builtins
--
2.17.0.705.g3525833791
next prev parent reply other threads:[~2018-05-07 17:53 UTC|newest]
Thread overview: 137+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-26 16:55 [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Nguyễn Thái Ngọc Duy
2018-03-26 16:55 ` [PATCH/RFC 1/5] git.c: convert --list-builtins to --list-cmds=builtins Nguyễn Thái Ngọc Duy
2018-03-26 16:55 ` [PATCH/RFC 2/5] git.c: implement --list-cmds=all and use it in git-completion.bash Nguyễn Thái Ngọc Duy
2018-04-09 3:32 ` Eric Sunshine
2018-03-26 16:55 ` [PATCH/RFC 3/5] generate-cmdlist.sh: keep all information in common-cmds.h Nguyễn Thái Ngọc Duy
2018-04-09 4:59 ` Eric Sunshine
2018-04-09 5:12 ` Eric Sunshine
2018-04-09 16:16 ` Duy Nguyen
2018-04-15 16:04 ` Duy Nguyen
2018-03-26 16:55 ` [PATCH/RFC 4/5] git.c: implement --list-cmds=porcelain Nguyễn Thái Ngọc Duy
2018-03-26 16:55 ` [PATCH/RFC 5/5] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
2018-04-09 5:08 ` Eric Sunshine
2018-04-09 9:47 ` Junio C Hamano
2018-04-09 9:55 ` Eric Sunshine
2018-04-09 15:15 ` Duy Nguyen
2018-04-09 5:17 ` [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Eric Sunshine
2018-04-11 22:06 ` Philip Oakley
2018-04-14 15:44 ` Duy Nguyen
2018-04-15 21:21 ` Philip Oakley
2018-04-17 16:24 ` Duy Nguyen
2018-04-17 16:48 ` Duy Nguyen
2018-04-17 22:47 ` Philip Oakley
2018-04-18 6:38 ` Philip Oakley
2018-04-18 15:33 ` Duy Nguyen
2018-04-19 7:47 ` Philip Oakley
2018-04-15 16:42 ` [PATCH v2 0/6] " Nguyễn Thái Ngọc Duy
2018-04-15 16:42 ` [PATCH v2 1/6] git.c: convert --list-builtins to --list-cmds=builtins Nguyễn Thái Ngọc Duy
2018-04-15 16:42 ` [PATCH v2 2/6] git.c: implement --list-cmds=all and use it in git-completion.bash Nguyễn Thái Ngọc Duy
2018-04-16 2:30 ` Junio C Hamano
2018-04-15 16:42 ` [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h Nguyễn Thái Ngọc Duy
2018-04-16 2:38 ` Junio C Hamano
2018-04-23 8:23 ` Øystein Walle
2018-04-23 9:59 ` SZEDER Gábor
2018-04-16 6:28 ` Junio C Hamano
2018-04-16 15:43 ` Duy Nguyen
2018-04-16 15:43 ` SZEDER Gábor
2018-04-16 16:25 ` Ramsay Jones
2018-04-16 22:42 ` Junio C Hamano
2018-04-15 16:42 ` [PATCH v2 4/6] git.c: implement --list-cmds=porcelain Nguyễn Thái Ngọc Duy
2018-04-15 16:42 ` [PATCH v2 5/6] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
2018-04-15 16:42 ` [PATCH v2 6/6] help: use command-list.txt for the source of guides Nguyễn Thái Ngọc Duy
2018-04-21 16:54 ` [PATCH v3 0/6] Keep all info in command-list.txt in git binary Nguyễn Thái Ngọc Duy
2018-04-21 16:54 ` [PATCH v3 1/6] git.c: convert --list-*builtins to --list-cmds=* Nguyễn Thái Ngọc Duy
2018-04-21 16:54 ` [PATCH v3 2/6] git.c: implement --list-cmds=all and use it in git-completion.bash Nguyễn Thái Ngọc Duy
2018-04-23 11:20 ` SZEDER Gábor
2018-04-21 16:54 ` [PATCH v3 3/6] generate-cmdlist.sh: keep all information in common-cmds.h Nguyễn Thái Ngọc Duy
2018-04-21 16:54 ` [PATCH v3 4/6] git.c: implement --list-cmds=porcelain Nguyễn Thái Ngọc Duy
2018-04-23 13:32 ` SZEDER Gábor
2018-04-24 16:12 ` Duy Nguyen
2018-04-24 16:17 ` Duy Nguyen
2018-04-25 13:46 ` SZEDER Gábor
2018-04-25 14:44 ` Duy Nguyen
2018-04-25 13:06 ` SZEDER Gábor
2018-04-25 14:39 ` Duy Nguyen
2018-04-21 16:54 ` [PATCH v3 5/6] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
2018-04-21 16:54 ` [PATCH v3 6/6] help: use command-list.txt for the source of guides Nguyễn Thái Ngọc Duy
2018-04-23 6:07 ` Eric Sunshine
2018-04-21 16:56 ` [PATCH v3 0/6] Keep all info in command-list.txt in git binary Duy Nguyen
2018-04-22 14:45 ` Ramsay Jones
2018-04-22 15:22 ` Duy Nguyen
2018-04-22 15:58 ` Ramsay Jones
2018-04-22 16:12 ` Duy Nguyen
2018-04-22 16:36 ` Ramsay Jones
2018-04-25 16:30 ` [PATCH v4/wip 00/12] " Nguyễn Thái Ngọc Duy
2018-04-25 16:30 ` [PATCH v4/wip 01/12] generate-cmds.sh: factor out synopsis extract code Nguyễn Thái Ngọc Duy
2018-04-25 17:59 ` Eric Sunshine
2018-04-25 18:13 ` SZEDER Gábor
2018-04-25 16:30 ` [PATCH v4/wip 02/12] generate-cmds.sh: export all commands to command-list.h Nguyễn Thái Ngọc Duy
2018-04-25 18:07 ` Eric Sunshine
2018-04-29 16:11 ` Duy Nguyen
2018-04-25 16:30 ` [PATCH v4/wip 03/12] help: use command-list.h for common command list Nguyễn Thái Ngọc Duy
2018-04-25 16:30 ` [PATCH v4/wip 04/12] Remove common-cmds.h Nguyễn Thái Ngọc Duy
2018-04-25 16:31 ` [PATCH v4/wip 05/12] git.c: convert --list-*builtins to --list-cmds=* Nguyễn Thái Ngọc Duy
2018-04-25 16:31 ` [PATCH v4/wip 06/12] git: accept multiple --list-cmds options Nguyễn Thái Ngọc Duy
2018-04-25 18:12 ` Eric Sunshine
2018-04-25 16:31 ` [PATCH v4/wip 07/12] completion: implement and use --list-cmds=all Nguyễn Thái Ngọc Duy
2018-04-25 16:31 ` [PATCH v4/wip 08/12] git: support --list-cmds=<category> Nguyễn Thái Ngọc Duy
2018-04-25 18:16 ` Eric Sunshine
2018-04-25 16:31 ` [PATCH v4/wip 09/12] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
2018-04-25 16:31 ` [PATCH v4/wip 10/12] help: use command-list.txt for the source of guides Nguyễn Thái Ngọc Duy
2018-04-25 18:22 ` Eric Sunshine
2018-04-25 16:31 ` [PATCH v4/wip 11/12] command-list.txt: add new category "complete" Nguyễn Thái Ngọc Duy
2018-04-25 16:31 ` [PATCH v4/wip 12/12] completion: let git provide the completable command list Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 00/10] Keep all info in command-list.txt in git binary Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 01/10] generate-cmds.sh: factor out synopsis extract code Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 02/10] generate-cmds.sh: export all commands to command-list.h Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 03/10] help: use command-list.h for common command list Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 04/10] Remove common-cmds.h Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 05/10] git.c: convert --list-*builtins to --list-cmds=* Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 06/10] completion: implement and use --list-cmds=main,others Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 07/10] git: support --list-cmds=list-<category> Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 08/10] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 09/10] help: use command-list.txt for the source of guides Nguyễn Thái Ngọc Duy
2018-04-29 18:23 ` Duy Nguyen
2018-04-29 18:18 ` [PATCH v5 10/10] completion: let git provide the completable command list Nguyễn Thái Ngọc Duy
2018-04-30 15:53 ` [PATCH v5 00/10] Keep all info in command-list.txt in git binary Duy Nguyen
2018-05-07 17:52 ` [PATCH v6 00/13] " Nguyễn Thái Ngọc Duy
2018-05-07 17:52 ` [PATCH v6 01/13] generate-cmds.sh: factor out synopsis extract code Nguyễn Thái Ngọc Duy
2018-05-07 17:52 ` [PATCH v6 02/13] generate-cmds.sh: export all commands to command-list.h Nguyễn Thái Ngọc Duy
2018-05-08 3:47 ` Junio C Hamano
2018-05-07 17:52 ` [PATCH v6 03/13] help: use command-list.h for common command list Nguyễn Thái Ngọc Duy
2018-05-07 17:52 ` [PATCH v6 04/13] Remove common-cmds.h Nguyễn Thái Ngọc Duy
2018-05-07 17:52 ` [PATCH v6 05/13] git.c: convert --list-* to --list-cmds=* Nguyễn Thái Ngọc Duy
2018-05-08 3:50 ` Junio C Hamano
2018-05-07 17:52 ` [PATCH v6 06/13] git --list-cmds: collect command list in a string_list Nguyễn Thái Ngọc Duy
2018-05-07 17:52 ` [PATCH v6 07/13] completion: implement and use --list-cmds=main,others Nguyễn Thái Ngọc Duy
2018-05-07 17:52 ` [PATCH v6 08/13] git: support --list-cmds=list-<category> Nguyễn Thái Ngọc Duy
2018-05-08 4:00 ` Junio C Hamano
2018-05-07 17:52 ` [PATCH v6 09/13] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
2018-05-07 17:52 ` Nguyễn Thái Ngọc Duy [this message]
2018-05-08 4:04 ` [PATCH v6 10/13] help: use command-list.txt for the source of guides Junio C Hamano
2018-05-07 17:52 ` [PATCH v6 11/13] command-list.txt: documentation and guide line Nguyễn Thái Ngọc Duy
2018-05-12 17:50 ` Philip Oakley
2018-05-07 17:52 ` [PATCH v6 12/13] completion: let git provide the completable command list Nguyễn Thái Ngọc Duy
2018-05-07 17:52 ` [PATCH v6 13/13] completion: allow to customize " Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 00/13] Keep all info in command-list.txt in git binary Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 01/13] generate-cmds.sh: factor out synopsis extract code Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 02/13] generate-cmds.sh: export all commands to command-list.h Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 03/13] help: use command-list.h for common command list Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 04/13] Remove common-cmds.h Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 05/13] git.c: convert --list-* to --list-cmds=* Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 06/13] git --list-cmds: collect command list in a string_list Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 07/13] completion: implement and use --list-cmds=main,others Nguyễn Thái Ngọc Duy
2018-05-11 14:06 ` SZEDER Gábor
2018-05-11 14:32 ` SZEDER Gábor
2018-05-11 16:33 ` Duy Nguyen
2018-05-10 8:46 ` [PATCH v7 08/13] git: support --list-cmds=list-<category> Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 09/13] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 10/13] help: use command-list.txt for the source of guides Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 11/13] command-list.txt: documentation and guide line Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 12/13] completion: let git provide the completable command list Nguyễn Thái Ngọc Duy
2018-05-11 15:05 ` SZEDER Gábor
2018-05-13 6:50 ` Duy Nguyen
2018-05-10 8:46 ` [PATCH v7 13/13] completion: allow to customize " Nguyễn Thái Ngọc Duy
2018-04-19 10:37 ` [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Simon Ruderich
2018-04-19 11:26 ` SZEDER Gábor
2018-04-20 7:05 ` Simon Ruderich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180507175222.12114-11-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sunshine@sunshineco.com \
--cc=szeder.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).