首先我输入git stash show
。
然后输入s和tab,它会显示git stash show stash@{
,到目前为止一切正常。
但是当我输入1和tab时,它变成了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
}
有谁知道如何修复它?
Bash版本:GNU bash,版本4.2.37(2)-release(i386-apple-darwin12.0.0)。
Git版本:1.8.0.3
4.1.10(1)
。我在我的/etc/bash-completion.d/git-completion.sh
中定义了相同的完成函数,并且完成在我的端上正常工作。你能否提供有关你的bash版本的详细信息?如果你能够发布一个链接(可能是到gist的链接)到你完整的git-completion.sh
,这可能有助于比较。 - Tuxdude