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

Re: [PATCH v5 2/6] help.c: output the typical Git workflow

From
Eric Sunshine <sunshine@sunshineco.com>
Date
May 11, 2015, 06:24 UTC
Message-ID
<CAPig+cR46K2h+hk4riwXcty=T+RBoT1Za9rqOwB9EgvUReUhmg@mail.gmail.com>
In-Reply-To
<1431191856-10949-3-git-send-email-sebastien.guimmara@gmail.com>

On Sat, May 9, 2015 at 1:17 PM, Sébastien Guimmara <sebastien.guimmara@gmail.com> wrote:

Show 20 quoted lines
> 'git help' shows common commands in alphabetical order:
>
> The most commonly used git commands are:
>    add        Add file contents to the index
>    bisect     Find by binary search the change that introduced a bug
>    branch     List, create, or delete branches
>    checkout   Checkout a branch or paths to the working tree
>    clone      Clone a repository into a new directory
>    commit     Record changes to the repository
>    [...]
>
> without any indication of how commands relate to high-level
> concepts or each other. Revise the output to explain their relationship
> with the typical Git workflow:
>
> The typical Git workflow includes:
>
>    * start a working area (see also: git help tutorial):
>       clone      Clone a repository into a new directory
>       init       Create an empty Git repository or reinitialize [...]

In practice, I find the indented bulleted header items somewhat unsightly. More importantly, indenting them wastes precious horizontal screen real-estate (for those of who use 80-column terminals). Since the headers are already distinguished by being bulleted, you could easily drop the indentation; and then reduce the indentation of the commands themselves.

Show 59 quoted lines
>    * work on the current change (see also: git help everyday):
>       add        Add file contents to the index
>       reset      Reset current HEAD to the specified state
>
>    * examine the history and state (see also: git help revisions):
>       log        Show commit logs
>       status     Show the working tree status
>
>    [...]
>
> Helped-by: Eric Sunshine <sunshine@sunshineco.com>
> Signed-off-by: Sébastien Guimmara <sebastien.guimmara@gmail.com>
> ---
> diff --git a/help.c b/help.c
> index 2072a87..1df205f 100644
> --- a/help.c
> +++ b/help.c
> @@ -218,6 +218,18 @@ void list_commands(unsigned int colopts,
>         }
>  }
>
> +int cmd_group_cmp(const void *elem1, const void *elem2)
> +{
> +       const struct cmdname_help *e1 = elem1;
> +       const struct cmdname_help *e2 = elem2;
> +
> +       if (e1->group < e2->group)
> +               return -1;
> +       if (e1->group > e2->group)
> +               return 1;
> +       return strcmp(e1->name, e2->name);
> +}
> +
>  void list_common_cmds_help(void)
>  {
>         int i, longest = 0;
> @@ -227,9 +239,18 @@ void list_common_cmds_help(void)
>                         longest = strlen(common_cmds[i].name);
>         }
>
> -       puts(_("The most commonly used git commands are:"));
> +       qsort(common_cmds, ARRAY_SIZE(common_cmds),
> +               sizeof(common_cmds[0]), cmd_group_cmp);
> +
> +       puts(_("The typical Git workflow includes:"));
> +
>         for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
> -               printf("   %s   ", common_cmds[i].name);
> +               if (common_cmds[i].group != current_grp) {
> +                       printf("\n   * %s:\n", _(common_cmd_groups[common_cmds[i].group]));
> +                       current_grp = common_cmds[i].group;
> +               }
> +
> +               printf("      %s   ", common_cmds[i].name);
>                 mput_char(' ', longest - strlen(common_cmds[i].name));
>                 puts(_(common_cmds[i].help));
>         }
> --
> 2.4.0
Previous: Sébastien GuimmaraNext: Sébastien Guimmara
Message 5 of 14 in “git help: group common commands by theme”
  1. 0/6 git help: group common commands by themeSébastien Guimmara, May 9, 2015
  2. 1/6 generate-cmdlist: parse common group commandsSébastien Guimmara, May 9, 2015
  3. Eric SunshineMay 11, 2015
  4. 2/6 help.c: output the typical Git workflowSébastien Guimmara, May 9, 2015
  5. Eric SunshineMay 11, 2015
  6. 3/6 command-list.txt: group common commands by themeSébastien Guimmara, May 9, 2015
  7. Eric SunshineMay 11, 2015
  8. 4/6 Makefile: update to new command-list.txt formatSébastien Guimmara, May 9, 2015
  9. Eric SunshineMay 11, 2015
  10. 5/6 new-command.txt: mention the common command groupsSébastien Guimmara, May 9, 2015
  11. Eric SunshineMay 11, 2015
  12. 6/6 cmd-list.perl: ignore all lines until [commands]Sébastien Guimmara, May 9, 2015
  13. Eric SunshineMay 11, 2015
  14. Eric SunshineMay 11, 2015

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.