Reputation: 8534
First I type git stash show
.
Then type s and tab, and it shows git stash show stash@{
, till now it works fine.
But after I type 1 and tab, it becames git stash show stashstash@{1}
, and it is obvious wrong.
I think there may be some wrong in the following code in .git-completion.bash, but I can hardly read this.
_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 it?
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
Upvotes: 8
Views: 435
Reputation: 11346
I had the same problem when I manually downloaded git completion script which was outdated. I was able to fix it by getting the latest using homebrew.
brew install git bash-completion
Remove old links that you may have in your ".profile". Replace to use the script from brew
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
Now when I tab on, it completes correctly. (git stash show stash@{0 .. gives git stash show stash@{0})
Upvotes: 3
Reputation: 7915
Bash-Completion should come as a separate package more or less independent of Bash itself. For example I have bash version 4.1.10-4 and bash-completion version 1.3-1 from Cygwin and the completion you describe works as it should.
Please check what version of Bash-Completion you have installed. You could also try to install the latest version directly from http://bash-completion.alioth.debian.org/ or try to replace only the file /etc/bash_completion.d/git
with the upstream version.
Upvotes: 0