git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v5 09/10] help: use command-list.txt for the source of guides

From
Duy Nguyen <pclouds@gmail.com>
Date
Apr 29, 2018, 18:23 UTC
Message-ID
<CACsJy8ADj-bTMYDHxRNLOMppOEdPbVwL49u3XCfNBCmoLLZo+A@mail.gmail.com>
In-Reply-To
<20180429181844.21325-10-pclouds@gmail.com>

Phillip (and others) the changes in this patch make "git help -g" now lists a lot more guides than just the "common" one as advertised (see below for the exact list). The man page for "git help -g" also mentions that it would list "useful" guides, not all guides. But we have no way to list all guides as far as I can tell.

I guess we have two options forward:
- keep "help -g" to common guide (we can tag common guides in
command-list.txt) and add a new option to list all guides ("help
-ag"?)
- reword the man page to make "help -g" list all guides
I'm ok with either direction. What's your preference?
For comparison, this is the new output
The common Git guides are:
   attributes          Defining attributes per path
   cli                 Git command-line interface and conventions
   core-tutorial       A Git core tutorial for developers
   cvs-migration       Git for CVS users
   diffcore            Tweaking diff output
   everyday            A useful minimum set of commands for Everyday
Git
   glossary            A Git Glossary
   hooks               Hooks used by Git
   ignore              Specifies intentionally untracked files to
ignore
   modules             Defining submodule properties
   namespaces          Git namespaces
   repository-layout   Git Repository Layout
   revisions           Specifying revisions and ranges for Git
   tutorial            A tutorial introduction to Git
   tutorial-2          A tutorial introduction to Git: part two
   workflows           An overview of recommended workflows with Git
compared to the old version
The common Git guides are:
   attributes   Defining attributes per path
   everyday     Everyday Git With 20 Commands Or So
   glossary     A Git glossary
   ignore       Specifies intentionally untracked files to ignore
   modules      Defining submodule properties
   revisions    Specifying revisions and ranges for Git
   tutorial     A tutorial introduction to Git (for version 1.5.1 or
newer)
   workflows    An overview of recommended workflows with Git
On Sun, Apr 29, 2018 at 8:18 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 255 quoted lines
> 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.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  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                                 | 18 ++++++++++++---
>  help.h                                 |  1 +
>  t/t0012-help.sh                        |  6 +++++
>  10 files changed, 52 insertions(+), 44 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 71b5b594cd..18696e35b0 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1939,7 +1939,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 83a7d73afe..b58e8d5f6a 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 77cfb8a20b..50d14a93dc 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1570,6 +1570,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
> @@ -1579,11 +1586,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 f9da0214f1..f4629d0ee1 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,10 +360,20 @@ void list_cmds_by_category(const char *cat)
>                 struct cmdname_help *cmd = command_list + i;
>
>                 if (cmd->category & cat_id)
> -                       puts(drop_prefix(cmd->name));
> +                       puts(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 090d46ba01..5d27368fe4 100644
> --- a/help.h
> +++ b/help.h
> @@ -18,6 +18,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(void);
>  extern void list_all_other_cmds(void);
>  extern void list_cmds_by_category(const char *category);
> 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.664.g8924eee37a
>
-- 
Duy
Previous: Nguyễn Thái Ngọc DuyNext: Duy Nguyen
Message 95 of 137 in “Keep all info in command-list.txt in git binary”
  1. 0/5 Keep all info in command-list.txt in git binaryNguyễn Thái Ngọc Duy, Mar 26, 2018
  2. 2/5 git.c: implement --list-cmds=all and use it in git-completion.bashNguyễn Thái Ngọc Duy, Mar 26, 2018
  3. Eric SunshineApr 9, 2018
  4. 1/5 git.c: convert --list-builtins to --list-cmds=builtinsNguyễn Thái Ngọc Duy, Mar 26, 2018
  5. 3/5 generate-cmdlist.sh: keep all information in common-cmds.hNguyễn Thái Ngọc Duy, Mar 26, 2018
  6. Eric SunshineApr 9, 2018
  7. Eric SunshineApr 9, 2018
  8. Duy NguyenApr 9, 2018
  9. Duy NguyenApr 15, 2018
  10. 5/5 help: add "-a --verbose" to list all commands with synopsisNguyễn Thái Ngọc Duy, Mar 26, 2018
  11. Eric SunshineApr 9, 2018
  12. Junio C HamanoApr 9, 2018
  13. Eric SunshineApr 9, 2018
  14. Duy NguyenApr 9, 2018
  15. 4/5 git.c: implement --list-cmds=porcelainNguyễn Thái Ngọc Duy, Mar 26, 2018
  16. Eric SunshineApr 9, 2018
  17. Philip OakleyApr 11, 2018
  18. Duy NguyenApr 14, 2018
  19. Philip OakleyApr 15, 2018
  20. Duy NguyenApr 17, 2018
  21. Duy NguyenApr 17, 2018
  22. Philip OakleyApr 17, 2018
  23. Philip OakleyApr 18, 2018
  24. Duy NguyenApr 18, 2018
  25. Philip OakleyApr 19, 2018
  26. 0/6 Keep all info in command-list.txt in git binaryNguyễn Thái Ngọc Duy, Apr 15, 2018
  27. 1/6 git.c: convert --list-builtins to --list-cmds=builtinsNguyễn Thái Ngọc Duy, Apr 15, 2018
  28. 4/6 git.c: implement --list-cmds=porcelainNguyễn Thái Ngọc Duy, Apr 15, 2018
  29. 3/6 generate-cmdlist.sh: keep all information in common-cmds.hNguyễn Thái Ngọc Duy, Apr 15, 2018
  30. Junio C HamanoApr 16, 2018
  31. Øystein WalleApr 23, 2018
  32. SZEDER GáborApr 23, 2018
  33. Junio C HamanoApr 16, 2018
  34. Duy NguyenApr 16, 2018
  35. SZEDER GáborApr 16, 2018
  36. Ramsay JonesApr 16, 2018
  37. Junio C HamanoApr 16, 2018
  38. 6/6 help: use command-list.txt for the source of guidesNguyễn Thái Ngọc Duy, Apr 15, 2018
  39. 2/6 git.c: implement --list-cmds=all and use it in git-completion.bashNguyễn Thái Ngọc Duy, Apr 15, 2018
  40. Junio C HamanoApr 16, 2018
  41. 5/6 help: add "-a --verbose" to list all commands with synopsisNguyễn Thái Ngọc Duy, Apr 15, 2018
  42. 0/6 Keep all info in command-list.txt in git binaryNguyễn Thái Ngọc Duy, Apr 21, 2018
  43. 1/6 git.c: convert --list-*builtins to --list-cmds=*Nguyễn Thái Ngọc Duy, Apr 21, 2018
  44. 2/6 git.c: implement --list-cmds=all and use it in git-completion.bashNguyễn Thái Ngọc Duy, Apr 21, 2018
  45. SZEDER GáborApr 23, 2018
  46. 3/6 generate-cmdlist.sh: keep all information in common-cmds.hNguyễn Thái Ngọc Duy, Apr 21, 2018
  47. 6/6 help: use command-list.txt for the source of guidesNguyễn Thái Ngọc Duy, Apr 21, 2018
  48. Eric SunshineApr 23, 2018
  49. 5/6 help: add "-a --verbose" to list all commands with synopsisNguyễn Thái Ngọc Duy, Apr 21, 2018
  50. 4/6 git.c: implement --list-cmds=porcelainNguyễn Thái Ngọc Duy, Apr 21, 2018
  51. SZEDER GáborApr 23, 2018
  52. Duy NguyenApr 24, 2018
  53. Duy NguyenApr 24, 2018
  54. SZEDER GáborApr 25, 2018
  55. Duy NguyenApr 25, 2018
  56. SZEDER GáborApr 25, 2018
  57. Duy NguyenApr 25, 2018
  58. Duy NguyenApr 21, 2018
  59. Ramsay JonesApr 22, 2018
  60. Duy NguyenApr 22, 2018
  61. Ramsay JonesApr 22, 2018
  62. Duy NguyenApr 22, 2018
  63. Ramsay JonesApr 22, 2018
  64. 00/12 Keep all info in command-list.txt in git binaryNguyễn Thái Ngọc Duy, Apr 25, 2018
  65. 01/12 generate-cmds.sh: factor out synopsis extract codeNguyễn Thái Ngọc Duy, Apr 25, 2018
  66. Eric SunshineApr 25, 2018
  67. SZEDER GáborApr 25, 2018
  68. 02/12 generate-cmds.sh: export all commands to command-list.hNguyễn Thái Ngọc Duy, Apr 25, 2018
  69. Eric SunshineApr 25, 2018
  70. Duy NguyenApr 29, 2018
  71. 03/12 help: use command-list.h for common command listNguyễn Thái Ngọc Duy, Apr 25, 2018
  72. 08/12 git: support --list-cmds=<category>Nguyễn Thái Ngọc Duy, Apr 25, 2018
  73. Eric SunshineApr 25, 2018
  74. 07/12 completion: implement and use --list-cmds=allNguyễn Thái Ngọc Duy, Apr 25, 2018
  75. 06/12 git: accept multiple --list-cmds optionsNguyễn Thái Ngọc Duy, Apr 25, 2018
  76. Eric SunshineApr 25, 2018
  77. 11/12 command-list.txt: add new category "complete"Nguyễn Thái Ngọc Duy, Apr 25, 2018
  78. 09/12 help: add "-a --verbose" to list all commands with synopsisNguyễn Thái Ngọc Duy, Apr 25, 2018
  79. 10/12 help: use command-list.txt for the source of guidesNguyễn Thái Ngọc Duy, Apr 25, 2018
  80. Eric SunshineApr 25, 2018
  81. 05/12 git.c: convert --list-*builtins to --list-cmds=*Nguyễn Thái Ngọc Duy, Apr 25, 2018
  82. 04/12 Remove common-cmds.hNguyễn Thái Ngọc Duy, Apr 25, 2018
  83. 12/12 completion: let git provide the completable command listNguyễn Thái Ngọc Duy, Apr 25, 2018
  84. 00/10 Keep all info in command-list.txt in git binaryNguyễn Thái Ngọc Duy, Apr 29, 2018
  85. 01/10 generate-cmds.sh: factor out synopsis extract codeNguyễn Thái Ngọc Duy, Apr 29, 2018
  86. 02/10 generate-cmds.sh: export all commands to command-list.hNguyễn Thái Ngọc Duy, Apr 29, 2018
  87. 03/10 help: use command-list.h for common command listNguyễn Thái Ngọc Duy, Apr 29, 2018
  88. 06/10 completion: implement and use --list-cmds=main,othersNguyễn Thái Ngọc Duy, Apr 29, 2018
  89. 05/10 git.c: convert --list-*builtins to --list-cmds=*Nguyễn Thái Ngọc Duy, Apr 29, 2018
  90. 10/10 completion: let git provide the completable command listNguyễn Thái Ngọc Duy, Apr 29, 2018
  91. 04/10 Remove common-cmds.hNguyễn Thái Ngọc Duy, Apr 29, 2018
  92. 07/10 git: support --list-cmds=list-<category>Nguyễn Thái Ngọc Duy, Apr 29, 2018
  93. 08/10 help: add "-a --verbose" to list all commands with synopsisNguyễn Thái Ngọc Duy, Apr 29, 2018
  94. 09/10 help: use command-list.txt for the source of guidesNguyễn Thái Ngọc Duy, Apr 29, 2018
  95. Duy NguyenApr 29, 2018
  96. Duy NguyenApr 30, 2018
  97. 00/13 Keep all info in command-list.txt in git binaryNguyễn Thái Ngọc Duy, May 7, 2018
  98. 01/13 generate-cmds.sh: factor out synopsis extract codeNguyễn Thái Ngọc Duy, May 7, 2018
  99. 02/13 generate-cmds.sh: export all commands to command-list.hNguyễn Thái Ngọc Duy, May 7, 2018
  100. Junio C HamanoMay 8, 2018
  101. 04/13 Remove common-cmds.hNguyễn Thái Ngọc Duy, May 7, 2018
  102. 06/13 git --list-cmds: collect command list in a string_listNguyễn Thái Ngọc Duy, May 7, 2018
  103. 07/13 completion: implement and use --list-cmds=main,othersNguyễn Thái Ngọc Duy, May 7, 2018
  104. 05/13 git.c: convert --list-* to --list-cmds=*Nguyễn Thái Ngọc Duy, May 7, 2018
  105. Junio C HamanoMay 8, 2018
  106. 09/13 help: add "-a --verbose" to list all commands with synopsisNguyễn Thái Ngọc Duy, May 7, 2018
  107. 12/13 completion: let git provide the completable command listNguyễn Thái Ngọc Duy, May 7, 2018
  108. 13/13 completion: allow to customize the completable command listNguyễn Thái Ngọc Duy, May 7, 2018
  109. 10/13 help: use command-list.txt for the source of guidesNguyễn Thái Ngọc Duy, May 7, 2018
  110. Junio C HamanoMay 8, 2018
  111. 08/13 git: support --list-cmds=list-<category>Nguyễn Thái Ngọc Duy, May 7, 2018
  112. Junio C HamanoMay 8, 2018
  113. 11/13 command-list.txt: documentation and guide lineNguyễn Thái Ngọc Duy, May 7, 2018
  114. Philip OakleyMay 12, 2018
  115. 03/13 help: use command-list.h for common command listNguyễn Thái Ngọc Duy, May 7, 2018
  116. 00/13 Keep all info in command-list.txt in git binaryNguyễn Thái Ngọc Duy, May 10, 2018
  117. 01/13 generate-cmds.sh: factor out synopsis extract codeNguyễn Thái Ngọc Duy, May 10, 2018
  118. 03/13 help: use command-list.h for common command listNguyễn Thái Ngọc Duy, May 10, 2018
  119. 02/13 generate-cmds.sh: export all commands to command-list.hNguyễn Thái Ngọc Duy, May 10, 2018
  120. 04/13 Remove common-cmds.hNguyễn Thái Ngọc Duy, May 10, 2018
  121. 11/13 command-list.txt: documentation and guide lineNguyễn Thái Ngọc Duy, May 10, 2018
  122. 10/13 help: use command-list.txt for the source of guidesNguyễn Thái Ngọc Duy, May 10, 2018
  123. 12/13 completion: let git provide the completable command listNguyễn Thái Ngọc Duy, May 10, 2018
  124. SZEDER GáborMay 11, 2018
  125. Duy NguyenMay 13, 2018
  126. 13/13 completion: allow to customize the completable command listNguyễn Thái Ngọc Duy, May 10, 2018
  127. 05/13 git.c: convert --list-* to --list-cmds=*Nguyễn Thái Ngọc Duy, May 10, 2018
  128. 06/13 git --list-cmds: collect command list in a string_listNguyễn Thái Ngọc Duy, May 10, 2018
  129. 07/13 completion: implement and use --list-cmds=main,othersNguyễn Thái Ngọc Duy, May 10, 2018
  130. SZEDER GáborMay 11, 2018
  131. SZEDER GáborMay 11, 2018
  132. Duy NguyenMay 11, 2018
  133. 08/13 git: support --list-cmds=list-<category>Nguyễn Thái Ngọc Duy, May 10, 2018
  134. 09/13 help: add "-a --verbose" to list all commands with synopsisNguyễn Thái Ngọc Duy, May 10, 2018
  135. Simon RuderichApr 19, 2018
  136. SZEDER GáborApr 19, 2018
  137. Simon RuderichApr 20, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.