首先我输入 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
最佳答案
当我手动下载过时的 git 完成脚本时,我遇到了同样的问题。我能够通过使用自制软件获取最新版本来修复它。
brew install git bash-completion
删除您在“.profile”中可能拥有的旧链接。替换为使用来自 brew 的脚本
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
现在,当我点击时,它会正确完成。 (git stash show stash@{0 .. 给出 git stash show stash@{0})
关于git - 输入 git stash show stash@{1} 时出现自动完成问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16261472/