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

Re: [PATCH v7 3/5] generate-cmdlist: parse common group commands

From
Eric Sunshine <sunshine@sunshineco.com>
Date
May 15, 2015, 21:34 UTC
Message-ID
<CAPig+cS+u18AvrFY2Xf+XH9Rma3A-F_bY4frYEx2DZ=MNeFQsQ@mail.gmail.com>
In-Reply-To
<1431714904-16599-4-git-send-email-sebastien.guimmara@gmail.com>

On Fri, May 15, 2015 at 2:35 PM, Sébastien Guimmara <sebastien.guimmara@gmail.com> wrote:

Show 47 quoted lines
> From: Eric Sunshine <sunshine@sunshineco.com>
>
> Parse the [common] block to create the array of group descriptions:
> [...]
> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
> Signed-off-by: Sébastien Guimmara <sebastien.guimmara@gmail.com>
> ---
> diff --git a/generate-cmdlist.awk b/generate-cmdlist.awk
> new file mode 100644
> index 0000000..b5cc789
> --- /dev/null
> +++ b/generate-cmdlist.awk
> @@ -0,0 +1,39 @@
> +BEGIN {
> +       print "/* Automatically generated by generate-cmdlist.awk */\n"
> +       print "struct cmdname_help {"
> +       print "\tchar name[16];"
> +       print "\tchar help[80];"
> +       print "\tunsigned char group;"
> +       print "};\n"
> +       print "static char *common_cmd_groups[] = {"
> +}
> +/^#/ || /^[    ]*$/ { next }
> +state == 2 {
> +       for (i = 2; i <= NF; i++)
> +               if (grp[$i]) {
> +                       f = "Documentation/"$1".txt"
> +                       while (getline s <f > 0)
> +                               if (match(s, $1" - ")) {
> +                                       t = substr(s, length($1" - ") + 1)
> +                                       break
> +                               }
> +                       close(f)
> +                       printf "\t{\"%s\", N_(\"%s\"), %s},\n",
> +                               substr($1, length("git-") + 1), t, grp[$i] - 1
> +                       break
> +               }
> +}
> +/\[commands\]/ {
> +       print "};\n\nstatic struct cmdname_help common_cmds[] = {"
> +       state = 2
> +}
> +state == 1 {
> +       grp[$1] = ++n
> +       sub($1"[        ][      ]*", "")
> +       printf "\tN_(\"%s\"),\n", $0
> +       next

It probably would be best to drop this unnecessary and potentially confusing "next" line[1].

[1]: http://thread.gmane.org/gmane.comp.version-control.git/268348/focus=268599
Show 5 quoted lines
> +}
> +/\[common\]/ {
> +       state = 1
> +}
> +END { print "};" }
Previous: Sébastien GuimmaraNext: Sébastien Guimmara
Message 16 of 23 in “git help: group common commands by theme”
  1. 0/5 git help: group common commands by themeSébastien Guimmara, May 15, 2015
  2. 1/5 command-list.txt: prepare with [commands] headerSébastien Guimmara, May 15, 2015
  3. Junio C HamanoMay 15, 2015
  4. Sébastien GuimmaraMay 15, 2015
  5. Junio C HamanoMay 15, 2015
  6. Eric SunshineMay 15, 2015
  7. Junio C HamanoMay 15, 2015
  8. Eric SunshineMay 15, 2015
  9. Sébastien GuimmaraMay 18, 2015
  10. Eric SunshineMay 15, 2015
  11. Philip OakleyMay 16, 2015
  12. Sébastien GuimmaraMay 16, 2015
  13. 2/5 command-list.txt: add a [common] blockSébastien Guimmara, May 15, 2015
  14. Eric SunshineMay 15, 2015
  15. 3/5 generate-cmdlist: parse common group commandsSébastien Guimmara, May 15, 2015
  16. Eric SunshineMay 15, 2015
  17. 4/5 command-list.txt: drop the common tagSébastien Guimmara, May 15, 2015
  18. Eric SunshineMay 15, 2015
  19. 5/5 help.c: output the typical Git workflowSébastien Guimmara, May 15, 2015
  20. Eric SunshineMay 15, 2015
  21. Eric SunshineMay 15, 2015
  22. Junio C HamanoMay 15, 2015
  23. Sébastien GuimmaraMay 15, 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.