All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Thiago Perrotta <tbperrotta@gmail.com>
Cc: carenas@gmail.com, gitster@pobox.com, bagasdotme@gmail.com,
	git@vger.kernel.org
Subject: Re: [PATCH v7 0/3] send-email: shell completion improvements
Date: Mon, 11 Oct 2021 15:46:20 +0200	[thread overview]
Message-ID: <87fst7lkjx.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <20211011041033.20004-1-tbperrotta@gmail.com>


On Mon, Oct 11 2021, Thiago Perrotta wrote:

> Differences from V6:
>
> 2/3: Addresses all of Carlos's comments:
>   - make indentation consistent (tabs): note that there's a giant diff
>     for the largest GetOptions now, it adds a bit of noise to the patch

I took Carlo's suggestion to mean to indent your uniq function, not to
re-indent a bunch of existing code while at it...

>   - do not reuse the options variable, for improved readability.

...I think that re-indentation is better left alone for the patch
readability.

Anyway, sorry about not looking at this sooner after my off-the-cuff
[1]; I think this looks mostly good-ish, but there's a few broken things
here:

First, in your 1/3 you're adding a \n, but in 2/3 we end up with \n\n. I
think you can just skip 1/3, maybe mention "how it also has a "\n" in
the commit message.

I.e. you start implicitly picking up the newline because you changed
from a "print" to a "split", and latter imposes Perl's scalar context on
its argument, but the former doesn't. That's a combination of some Perl
trivia and our own Git.pm being overly clever about wantarray(), but
there you go.

More importantly in [1] I meant that last paragraph as a "and as an
excercise for the reader..".

I.e. we should not simply strip the trailing "=" etc., we need to parse
those out of the Perl GetOptions arguments, and come up with mapping to
what we do in parse-options.c. I think that's basically adding a "=" at
the end of all options that end with "=s", ":i", "=d", ":s" etc.

You then strip out "--" arguments from the combined list, but isn't this
something we do need to emit? I.e. it's used as syntax by the bash
completion isn't it? (I just skimmed the relevant C code in
parse-options.c).
    
    $ git clone --git-completion-helper | tr ' ' '\n' | grep -C2 -- ^--$
    --hardlinks
    --tags
    --
    --no-verbose
    --no-quiet

For --no-foo arguments we emit both a --foo and --no-foo in it, that
sort of (maybe entirely) works in your version because some/all (I
haven't checked all) options have corresponding "foo" arguments for
"no-foo", so maybe it sort of works out, but does the ordering
before/after the "--", and that we strip out the "--" but e.g. "git
clone" will emit it?

We then don't want to emit "-h", but you strip out "--h", first we
mapped "h" to "--h" in the loop above, so we should do that there. But
better yet we have a "%dump_aliases_options" already, maybe it +
"git-completion-helper" can be moved to another "%not_for_completion"
hash or something.

The map/map/keys loop also will silently do something odd if it starts
getting input data it didn't expect, i.e. it would be more reliable as a
regex check, and then die() if we start getting somethnig we don't
expect, i.e. if someone adds an option not covered by our regex.

That it's a map/map/keys is just some off-the-cuff Perl hacking on my
part, I think for validation etc. it's usually better to just turn it
into a plain old boring for-loop.

1. https://lore.kernel.org/git/87bl4h3fgv.fsf@evledraar.gmail.com/

  reply	other threads:[~2021-10-11 14:29 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-20  0:46 [PATCH v2 0/3] send-email: shell completion improvements Thiago Perrotta
2021-08-20  0:46 ` [PATCH v2 1/3] send-email: print newline for --git-completion-helper Thiago Perrotta
2021-08-20 20:17   ` Junio C Hamano
2021-08-28  3:08     ` [PATCH v3 0/3] send-email: shell completion improvements Thiago Perrotta
2021-08-28  3:08     ` [PATCH v3 1/3] send-email: terminate --git-completion-helper with LF Thiago Perrotta
2021-08-28  3:08     ` [PATCH v3 2/3] send-email: move bash completions to core script Thiago Perrotta
2021-08-28  5:25       ` Carlo Arenas
2021-09-07  0:16         ` [PATCH] " Thiago Perrotta
2021-09-07  1:28           ` Carlo Arenas
2021-09-21 15:51             ` [PATCH v4 0/3] send-email: shell completion improvements Thiago Perrotta
2021-09-21 15:51               ` [PATCH v4 1/3] send-email: terminate --git-completion-helper with LF Thiago Perrotta
2021-09-21 15:51               ` [PATCH v4 2/3] send-email: move bash completions to core script Thiago Perrotta
2021-09-21 15:51               ` [PATCH v4 3/3] send-email docs: add format-patch options Thiago Perrotta
2021-09-23 14:02               ` [PATCH v4 0/3] send-email: shell completion improvements Ævar Arnfjörð Bjarmason
2021-09-24  2:46                 ` [PATCH v5 " Thiago Perrotta
2021-09-24 20:02                   ` Ævar Arnfjörð Bjarmason
2021-09-30  3:10                     ` Thiago Perrotta
2021-10-07  3:36                       ` [PATCH v6 " Thiago Perrotta
2021-10-07  3:36                       ` [PATCH v6 1/3] send-email: terminate --git-completion-helper with LF Thiago Perrotta
2021-10-07  3:36                       ` [PATCH v6 2/3] send-email: programmatically generate bash completions Thiago Perrotta
2021-10-09  6:38                         ` Carlo Marcelo Arenas Belón
2021-10-11  4:10                           ` [PATCH v7 0/3] send-email: shell completion improvements Thiago Perrotta
2021-10-11 13:46                             ` Ævar Arnfjörð Bjarmason [this message]
2021-10-11 17:12                               ` [DRAFT/WIP PATCH] send-email: programmatically generate bash completions Thiago Perrotta
2021-10-25 21:27                               ` [PATCH v8 0/2] send-email: shell completion improvements Thiago Perrotta
2021-10-25 22:44                                 ` Ævar Arnfjörð Bjarmason
2021-10-26  0:48                                   ` Ævar Arnfjörð Bjarmason
2021-10-28 16:31                                     ` Junio C Hamano
2021-10-25 21:27                               ` [PATCH v8 1/2] send-email: programmatically generate bash completions Thiago Perrotta
2021-10-25 21:27                               ` [PATCH v8 2/2] send-email docs: add format-patch options Thiago Perrotta
2021-10-11  4:10                           ` [PATCH v7 1/3] send-email: terminate --git-completion-helper with LF Thiago Perrotta
2021-10-11  4:10                           ` [PATCH v7 2/3] send-email: programmatically generate bash completions Thiago Perrotta
2021-10-11  4:10                           ` [PATCH v7 3/3] send-email docs: add format-patch options Thiago Perrotta
2021-10-07  3:36                       ` [PATCH v6 " Thiago Perrotta
2021-10-09  8:31                         ` [RFC PATCH] Documentation: better document format-patch options in send-email Carlo Marcelo Arenas Belón
2021-10-09  8:57                           ` Bagas Sanjaya
2021-10-09  9:32                             ` Carlo Arenas
2021-10-09 11:04                               ` Bagas Sanjaya
2021-10-10 21:33                               ` Junio C Hamano
2021-09-24  2:46                 ` [PATCH v5 1/3] send-email: terminate --git-completion-helper with LF Thiago Perrotta
2021-09-24  2:46                 ` [PATCH v5 2/3] send-email: programmatically generate bash completions Thiago Perrotta
2021-09-24  2:46                 ` [PATCH v5 3/3] send-email docs: add format-patch options Thiago Perrotta
2021-09-24  4:36                   ` Bagas Sanjaya
2021-09-24  4:53                     ` Carlo Arenas
2021-09-24  6:19                       ` Bagas Sanjaya
2021-09-24  6:56                         ` Carlo Arenas
2021-09-24 15:33                       ` Junio C Hamano
2021-09-24 17:34                         ` Carlo Arenas
2021-09-24 20:03                           ` Junio C Hamano
2021-09-25  3:03                             ` Bagas Sanjaya
2021-09-25  4:07                               ` Junio C Hamano
2021-09-25  6:13                                 ` Carlo Marcelo Arenas Belón
2021-09-29 21:20                                   ` Junio C Hamano
2021-08-28  3:08     ` [PATCH v3 " Thiago Perrotta
2021-08-28  5:22       ` Bagas Sanjaya
2021-08-20  0:46 ` [PATCH v2 2/3] send-email: move bash completions to the perl script Thiago Perrotta
2021-08-20  0:46 ` [PATCH v2 3/3] send-email docs: mention format-patch options Thiago Perrotta
2021-08-20 20:32   ` Junio C Hamano

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=87fst7lkjx.fsf@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=bagasdotme@gmail.com \
    --cc=carenas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=tbperrotta@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.