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

Re: [PATCH v5 6/6] cmd-list.perl: ignore all lines until [commands]

From
Eric Sunshine <sunshine@sunshineco.com>
Date
May 11, 2015, 06:59 UTC
Message-ID
<CAPig+cRSPENt8QamfSOSgVFf_nmRKnfYkiOpf09WR=6--fLaEw@mail.gmail.com>
In-Reply-To
<1431191856-10949-7-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 18 quoted lines
> command-list.txt contains a [common] block that should be ignored
> by the Documentation checker cmd-list.perl.
>
> Filter out this block before the actual processing of the command list.
>
> Signed-off-by: Sébastien Guimmara <sebastien.guimmara@gmail.com>
> ---
> diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl
> index 04f9977..d581378 100755
> --- a/Documentation/cmd-list.perl
> +++ b/Documentation/cmd-list.perl
> @@ -38,8 +38,14 @@ sub format_one {
>         }
>  }
>
> +my @filtered = ();
> +while (<>)
> +{
Style: while (<>) {
> +       push (@filtered, $_) unless 1../^\[commands\]/;
> +}

Why collect the lines into @filtered when you could instead merely skip the unwanted ones outright?

    while (<>) {
        last if /^\[commands\]/;
    }
And, then you don't need to touch the following 'for' loop at all.
Show 8 quoted lines
>  my %cmds = ();
> -for (sort <>) {
> +for (sort @filtered) {
>         next if /^#/;
>
>         chomp;
> --
> 2.4.0
Previous: Sébastien GuimmaraNext: Eric Sunshine
Message 13 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.