首先我打字git stash show.
然后输入s和tab,它显示了git stash show stash@{,到现在它工作正常.
但经过I型1和tab,它becames git stash show stashstash@{1},这是明显错误的.
我认为.git-completion.bash中的以下代码可能有些错误,但我很难读到这一点.
_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
}
Run Code Online (Sandbox Code Playgroud)
有谁知道如何修理它?
Bash版本:GNU bash,版本4.2.37(2)-release(i386-apple-darwin12.0.0).
git版本:1.8.0.3
Bash-Completion 应该作为一个独立的包或多或少独立于 Bash 本身。例如,我有来自 Cygwin 的 bash 版本 4.1.10-4 和 bash-completion 版本 1.3-1,并且您描述的完成工作正常。
请检查您安装的 Bash-Completion 版本。您还可以尝试直接从http://bash-completion.alioth.debian.org/安装最新版本,或者尝试仅用/etc/bash_completion.d/git上游版本替换该文件。