Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: "Rubén Justo" <rjusto@gmail.com>
To: Patrick Steinhardt <ps@pks.im>, git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v2] completion: adapt git-config(1) to complete subcommands
Date: Fri, 17 May 2024 18:27:54 +0200	[thread overview]
Message-ID: <c48488d1-3135-493d-a9e8-2f787bdd2b4c@gmail.com> (raw)
In-Reply-To: <8d43dee33289969a5afbbf7635ac40b7312d8e19.1715926344.git.ps@pks.im>

On Fri, May 17, 2024 at 08:13:36AM +0200, Patrick Steinhardt wrote:

>     ++	__git_resolve_builtins "config"

The __git_resolve_builtins() function executes "git config
--git-completion-helper" and caches the result for future calls.  And
on return ...

>     ++
>     ++	subcommands="$___git_resolved_builtins"

... it populates the ___git_resolved_builtins variable with the result:
the available subcommands for "git config".

>     ++	subcommand="$(__git_find_subcommand "$subcommands")"

Then, we look for a subcommand among those returned, at
${words[__git_cmd_idx+1]}, where a possible command must reside.

Nicely done.  This looks good to me.

I wonder, if we might consider the possibility of having "list" as
a default command:

-	subcommand="$(__git_find_subcommand "$subcommands")"
+	subcommand="$(__git_find_subcommand "$subcommands" list)"

These lines are only meant to express the idea, as other changes are
also necessary and the documentation needs to be updated.  Of course, it
could be done in a future series.

I think that "git config -h" is an intuitive enough way to offer the
help text and that using 'git config' as a shortcut for 'git config
list' can be convenient.

By the way, having used '__git_find_subcommand' instead of
'__git_find_on_cmdline' is reassuring when it comes to having a default
subcommand :-)

Anyway, as I said, this series looks good to me.  Thanks!

  reply	other threads:[~2024-05-17 16:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-16  4:56 [PATCH] completion: adapt git-config(1) to complete subcommands Patrick Steinhardt
2024-05-16 15:53 ` Junio C Hamano
2024-05-17  6:05   ` Patrick Steinhardt
2024-05-17  6:13 ` [PATCH v2] " Patrick Steinhardt
2024-05-17 16:27   ` Rubén Justo [this message]
2024-05-21  6:23     ` Patrick Steinhardt

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=c48488d1-3135-493d-a9e8-2f787bdd2b4c@gmail.com \
    --to=rjusto@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=ps@pks.im \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).