Auto-complete issue when entering git stash show stash @ {1}

First enter git stash show .

Then enter s and tab and it will show git stash show stash@ { , so far it works fine.

But after entering 1 and tab, it becomes git stash show stashstash@ {1} , and this is obviously wrong.

I think there might be something wrong with the following code in .git-completion.bash , but I can hardly read it.

 _git_stash () { local save_opts='--keep-index --no-keep-index --quiet --patch' local subcommands='save list show apply clear drop pop create branch' local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then case "$cur" in --*) __gitcomp "$save_opts" ;; *) if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then __gitcomp "$subcommands" else COMPREPLY=() fi ;; esac else case "$subcommand,$cur" in save,--*) __gitcomp "$save_opts" ;; apply,--*|pop,--*) __gitcomp "--index --quiet" ;; show,--*|drop,--*|branch,--*) COMPREPLY=() ;; show,*|apply,*|drop,*|pop,*|branch,*) __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ | sed -n -e 's/:.*//p')" ;; *) COMPREPLY=() ;; esac fi } 

Does anyone know how to fix this?

Bash version: GNU bash, version 4.2.37 (2) -release (i386-apple-darwin12.0.0).

git version: 1.8.0.3

whole source: https://gist.github.com/pktangyue/5477924

+6
source share
2 answers

Bash -Completion should be a separate package, more or less independent of Bash. For example, I have Bash version 4.1.10-4 and bash the full version 1.3-1 from Cygwin, and the termination you describe works as it should.

Check which version of bash -Completion you installed. You can also try installing the latest version directly from http://bash-completion.alioth.debian.org/ or try replacing only the /etc/bash_completion.d/git file /etc/bash_completion.d/git an upstream version.

0
source

I had the same problem when I manually downloaded the git script completion, which was deprecated. I was able to fix this by getting the last use of homegrown.

 brew install git bash-completion 

Remove the old links that you might have in your ".profile". Replace to use brew script

 if [ -f $(brew --prefix)/etc/bash_completion ]; then . $(brew --prefix)/etc/bash_completion fi 

Now when I enter, it runs correctly. (git stash show stash @ {0 .. gives git stash show stash @ {0})

0
source

Source: https://habr.com/ru/post/943808/


All Articles