git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, "SZEDER Gábor" <szeder.dev@gmail.com>
Subject: Re: [PATCH 1/2] parse-options: support --git-completion-helper
Date: Tue, 16 Jan 2018 15:46:37 -0800	[thread overview]
Message-ID: <xmqq4lnltlia.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20180116103700.4505-2-pclouds@gmail.com> ("Nguyễn Thái Ngọc Duy"'s message of "Tue, 16 Jan 2018 17:36:59 +0700")

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> This option is designed to be used by git-completion.bash. For many
> simple cases, what we do in there is usually
>
>     __gitcomp "lots of completion options"
>
> which has to be manually updated when a new user-visible option is
> added. With support from parse-options, we can write
>
>     __gitcomp "$(git command --git-completion-helper)"
>
> and get that list directly from the parser for free. Dangerous/Unpopular
> options could be hidden with the new "NO_GITCOMP" flag.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  parse-options.c | 37 +++++++++++++++++++++++++++++++++++++
>  parse-options.h |  6 ++++--
>  2 files changed, 41 insertions(+), 2 deletions(-)

I do not know if you need PARSE_OPT_NO_INTERNAL_GITCOMP.  The only
way to trigger this is by passing a rather long option (intended to
be used only by scripts), so unlike PARSE_OPT_NO_INTERNAL_HELP which
was an escape hatch to free a short-and-sweet "-h" to be retargetted
by a selected few commands, there may not be need for it.

Some day when everybody uses parse-options, it would be trivially
correct to declare that this is the right approach ;-) I am not sure
how much of the current completion script's hardcoded option list
can be reduced with this approach with today's code, given that the
bigger ones (diff and log family) are not using parse-options API at
all, but for the ones that already do use parse-options, I think
this makes sense.

Thanks for a fun read ;-)


  parent reply	other threads:[~2018-01-16 23:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-16 10:36 [PATCH/RFC 0/2] Automate updating git-completion.bash a bit Nguyễn Thái Ngọc Duy
2018-01-16 10:36 ` [PATCH 1/2] parse-options: support --git-completion-helper Nguyễn Thái Ngọc Duy
2018-01-16 18:25   ` Jacob Keller
2018-01-17  0:21     ` Duy Nguyen
2018-01-16 23:46   ` Junio C Hamano [this message]
2018-01-17  0:27     ` Duy Nguyen
2018-01-16 10:37 ` [PATCH 2/2] git-completion: use --git-completion-helper Nguyễn Thái Ngọc Duy
2018-01-17  0:51 ` [PATCH/RFC 0/2] Automate updating git-completion.bash a bit SZEDER Gábor
2018-01-17  9:16   ` Duy Nguyen
2018-01-17  9:34     ` Duy Nguyen
2018-01-22 18:03       ` SZEDER Gábor
2018-01-23  9:59         ` Duy Nguyen
2019-04-11 11:10   ` Duy Nguyen
2019-04-11 11:11     ` Duy Nguyen

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq4lnltlia.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    --cc=szeder.dev@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).