Expand git autocomplete function for plumbing teams

As a continuation of this question, I asked myself if git could be told to provide it with an autocomplete function (branches, etc.) for a further command, in particular plumbing teams such as update-ref .

Although update-ref provides more flexibility than branch -f , it is rather complicated, since you always need to enter the full name of the link. Which in turn does not make me want to use it.

Any ideas on this?

+2
git autocomplete git-plumbing
source share
1 answer

You can enable plumbing commands, but you will need to provide part of the implementation yourself.

Find the git-completion.sh script that you are using.

In my /users/andrewc/.bashrc I have

 # GIT STUFF if [ -f ~/.git-completion.bash ] then . ~/.git-completion.bash fi 

So I pull up /users/andrewc/git-completion.bash

Find the __git_list_porcelain_command()) function and comment out the line for update-ref

  #update-ref) : plumbing;; 

This will allow update-ref to autocomplete itself. the script does not know how to populate any of the update-ref arguments. It looks like you need to provide an implementation for __git_update_ref to achieve this. I would use a similar command (`__git_branch perhaps) as a template and from there.

+5
source share

All Articles