With Git 2.31 (Q1 2021), the bash completion (in contrib/
) is updated to make it easier for end-users to add completion for their custom "git
" subcommands.
Thank to FelipeC (who wrote a previous answer on that same page)
See commit 5a067ba, commit 0e02bdc, commit 810df0e, commit 7f94b78 (30 Dec 2020) by Felipe Contreras (felipec
).
(Merged by Junio C Hamano -- gitster
-- in commit f9fb906, 15 Jan 2021)
completion
: add proper public __git_complete
Signed-off-by: Felipe Contreras
When __git_complete
was introduced, it was meant to be temporarily, while a proper guideline for public shell functions was established (tentatively _GIT_complete
), but since that never happened, people in the wild started to use __git_complete
, even though it was marked as not public.
Eight years is more than enough wait, let's mark this function as public, and make it a bit more user-friendly.
So that instead of doing:
__git_complete gk __gitk_main
The user can do:
__git_complete gk gitk
And instead of:
__git_complete gf _git_fetch
Do:
__git_complete gf git_fetch
Backwards compatibility is maintained.
gitpull mas<TAB>
it doesn't complete tomaster
like it should. – Infer