git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] completion: add proper public __git_complete

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Dec 28, 2020, 19:26 UTC
Message-ID
<CAMP44s1e1P0KEG4O0wrgwK7GatxiufRM1d9b2kFms4-G_3zXOg@mail.gmail.com>
In-Reply-To
<20201228192302.80467-3-felipe.contreras@gmail.com>

On Mon, Dec 28, 2020 at 1:23 PM Felipe Contreras <felipe.contreras@gmail.com> wrote:

Show 42 quoted lines
>
> Back in 2012 I argued [1] for the introduction of a helper that would
> allow users to specify aliases like:
>
>   git_complete gf git_fetch
>
> Back then there was pushback because there was no clear guideline for
> public functions (git_complete vs _git_complete vs _GIT_complete), and
> some aliases didn't actually work.
>
> Fast-forward to 2020 and there's still no guideline for public
> functions, and those aliases still don't work (even though I sent the
> fixes).
>
> This has not prevented people from using this function that is clearly
> needed to setup custom aliases [2], and in fact it's the recommended
> way. But it is cumbersome that the user must type:
>
>   __git_complete gf _git_fetch
>
> Or worse:
>
>   __git_complete gk __gitk_main
>
> 8 years is more than enough time to stop waiting for the perfect to
> come; let's define a public function (with the same name) that is
> actually user-friendly:
>
>   __git_complete gf git_fetch
>   __git_complete gk gitk
>
> While also maintaining backwards compatibility.
>
> The logic is:
>
>  1. If $2 exists, use it directly
>  2. If not, check if __$2_main exists
>  3. If not, check if _$2 exists
>  4. If not, fail
>
> [1] https://lore.kernel.org/git/1334524814-13581-1-git-send-email-felipe.contreras@gmail.com/
> [2] https://stackoverflow.com/questions/342969/how-do-i-get-bash-completion-to-work-with-aliases
Fixed wrong address of SZEDER Gábor.
-- 
Felipe Contreras
Previous: Felipe Contreras
Message 7 of 7 in “completion: make __git_complete public”
  1. 0/2 completion: make __git_complete publicFelipe Contreras, Dec 28, 2020
  2. 1/2 test: completion: add tests for __git_completeFelipe Contreras, Dec 28, 2020
  3. Denton LiuDec 28, 2020
  4. Felipe ContrerasDec 29, 2020
  5. Felipe ContrerasDec 29, 2020
  6. 2/2 completion: add proper public __git_completeFelipe Contreras, Dec 28, 2020
  7. Felipe ContrerasDec 28, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.