Re: Custom git completion
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:48:07
"Shawn O. Pearce" [off-list ref] writes:
David Rhodes Clymer [off-list ref] wrote:quoted
Unless I read it incorrectly, the completion script included with git-core does not make it easy for users to write completion scripts for custom git commands. I can extend git itself by creating a command "git-foo", and placing it in my path.git config --global alias.foo /home/me/bin/my-git-foo git foo will now complete correctly. No need to modify the completion code.
Yes. Aliases and custom subcommands are found from 'git help" output just
fine (you need to install new subcommand in exec-path).
But.
How does the completion code learn what options and arguments such aliases
and subcommands (e.g. "git foo") take without being told?
An alias that uses another git subcommand (i.e. the ones that do not start
with a bang "!") seems to be handled correctly, but one of my aliases is
this:
[alias]
lgm = "!sh -c 'GIT_NOTES_REF=refs/notes/amlog git log \"$@\" || :' -"
and the completion code doesn't (and it is unfair to expect it to) notice
that "git log" is run under the hood. I cannot say "git lgm sp/<TAB>" and
choose from the list of topics from you.