键入git stash show stash@{1}时自动完成问题

键入git stash show stash@{1}时自动完成问题,git,autocomplete,Git,Autocomplete,第一个I类型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 --pat

第一个I类型
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版本:gnubash,版本4.2.37(2)-发布版(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的版本。您也可以尝试直接从安装最新版本,或者尝试仅用上游版本替换文件
/etc/Bash\u Completion.d/git

我手动下载过时的git Completion脚本时遇到了同样的问题。我能够修复它通过使用自制软件获取最新版本

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})

我正在使用bash
4.1.10(1)
。我在我的
/etc/bash completion.d/git completion.sh中定义了相同的完成函数,完成函数在我这方面很好。你能提供关于你的bash版本的详细信息吗?另外,如果你能发布一个链接(可能是要点?)对于您的完整
git completion.sh
来说,这可能有助于进行比较。@Tuxdude添加了更多信息。我推测您至少有10个存储库?我正在尝试复制您的情况。我在两个存储库(git 1.8.2.3、bash 4.2.45、Arch Linux x86_64)中没有遇到此问题编辑:实际上,即使有11个栈,我也不能复制它。我建议您考虑升级BASH版本,因为Git的<代码> Stase< /Cult>在1.80.3和1.82.3之间没有任何明显的变化。