git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: "Sébastien Guimmara" <sebastien.guimmara@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH v5 6/6] cmd-list.perl: ignore all lines until [commands]
Date: Mon, 11 May 2015 02:59:21 -0400	[thread overview]
Message-ID: <CAPig+cRSPENt8QamfSOSgVFf_nmRKnfYkiOpf09WR=6--fLaEw@mail.gmail.com> (raw)
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:
> 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.

>  my %cmds = ();
> -for (sort <>) {
> +for (sort @filtered) {
>         next if /^#/;
>
>         chomp;
> --
> 2.4.0

  reply	other threads:[~2015-05-11  6:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-09 17:17 [PATCH v5 0/6] git help: group common commands by theme Sébastien Guimmara
2015-05-09 17:17 ` [PATCH v5 1/6] generate-cmdlist: parse common group commands Sébastien Guimmara
2015-05-11  6:12   ` Eric Sunshine
2015-05-09 17:17 ` [PATCH v5 2/6] help.c: output the typical Git workflow Sébastien Guimmara
2015-05-11  6:24   ` Eric Sunshine
2015-05-09 17:17 ` [PATCH v5 3/6] command-list.txt: group common commands by theme Sébastien Guimmara
2015-05-11  6:20   ` Eric Sunshine
2015-05-09 17:17 ` [PATCH v5 4/6] Makefile: update to new command-list.txt format Sébastien Guimmara
2015-05-11  6:44   ` Eric Sunshine
2015-05-09 17:17 ` [PATCH v5 5/6] new-command.txt: mention the common command groups Sébastien Guimmara
2015-05-11  6:47   ` Eric Sunshine
2015-05-09 17:17 ` [PATCH v5 6/6] cmd-list.perl: ignore all lines until [commands] Sébastien Guimmara
2015-05-11  6:59   ` Eric Sunshine [this message]
2015-05-11  5:52 ` [PATCH v5 0/6] git help: group common commands by theme Eric Sunshine

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='CAPig+cRSPENt8QamfSOSgVFf_nmRKnfYkiOpf09WR=6--fLaEw@mail.gmail.com' \
    --to=sunshine@sunshineco.com \
    --cc=git@vger.kernel.org \
    --cc=sebastien.guimmara@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).