Subject: Re: [PATCH v2 2/2] completion: add a GIT_COMPLETION_SHOW_ALL_COMMANDS

From: Junio C Hamano <[email-masked]>
Date: Sun, 06 Feb 2022 12:09:35 -0800

SZEDER Gábor <[email-masked]> writes:

> To complete only rarely used plumbing commands in a non-intrusive way,
> in my experience, it's best to first attempt to complete only
> porcelains and aliases, and fall back to complete all commands,
> plumbing included, only when no porcelains match the current word to
> be completed.  E.g.:
>
>   $ git d<TAB>
>   describe   diff   difftool
>   $ git diff-<TAB>
>   diff-files   diff-index   diff-tree

So after getting

    $ git diff<TAB>
    diff difftool

you _have_ to know, if you are not happy with these two, that the
next letter in the name of the command you forgot is a dash, to be
able to say

    $ git diff-<TAB>

which is a bit unfortunate, but I agree that it is much nicer than
getting all the plumbing when trying to complete "git d<TAB>".

I wonder if we can do better, and teach the completion logic an
ability to say this: "I gave 'diff and difftool' after being asked
for 'git diff<TAB>' and then the user is asking the same again
without choosing either. Perhaps I should add less frequent one to
the mix"?

I.e. the end-user session may look like

    $ git diff<TAB>
    diff difftool
    $ git diff<TAB>
    diff difftool diff-files diff-index diff-tree

?