git bash 自动完成在 Windows 7 x64 上很慢

标签 git bash zsh git-bash

我有两台机器,其中 git bash 自动完成的速度非常慢。当我点击 Tab 键时,完成文件名可能需要 8 到 10 秒。这似乎只发生在自动完成是 git 命令的一部分时。 cd 的自动完成工作正常。 git 命令的实际执行运行良好。

我正在使用 git version 1.8.3-preview20130601

$ git count-objects -vH
count: 9
size: 10.23 KiB
in-pack: 2488
packs: 1
size-pack: 18.68 MiB
prune-packable: 0
garbage: 0
size-garbage: 0 bytes

这可能是什么原因造成的?有什么可能的解决办法吗?

编辑:我更新到 Git(版本 1.8.4-preview20130916),问题仍然存在。我确实注意到,当在 ConEmu 中运行 bash shell 时,在长时间暂停期间底部显示的命令是 uniq.exe。似乎是对该可执行文件的调用占用了时间。

编辑:更新到 git version 1.9.0.msysgit.0 已经缓解了很多问题。延迟现在只有 1 到 2 秒。 cd 等其他命令仍然几乎是即时的(< 0.5 秒)。我也没有看到 uniq.exe 正在运行,只有 sh.exe

最佳答案

Git 2.13(2017 年第 2 季度)应该改进 Git bash 补全,因为大量 refs 的 refs 补全已经加快,部分是通过放弃消除歧义 refs,部分是通过消除“git for-”之间的大部分 shell 处理each-ref' 和 'ls-remote' 以及 Bash 的完成工具。

参见 commit 227307a , commit 745d655 , commit fef56eb , commit 400a755 , commit 824388d , commit e8cb023 , commit e896369 , commit b2b6811 , commit 3ad8ea7 , commit aed3881 , commit aa0644f , commit 2ea328a , commit 15b4a16 (2017 年 3 月 23 日),以及 commit c977eef (2017 年 2 月 3 日)作者:SZEDER Gábor ( szeder ) .
(由 Junio C Hamano -- gitster -- merge 于 commit bf65060 ,2017 年 3 月 30 日)

例如:

completion: speed up branch and tag completion

Modify __git_heads() and __git_tags() and the few callsites they have, so we can let 'git for-each-ref' do all the hard work and these functions' output won't need any further processing or filtering before being handed over to Bash, resulting in faster branch and tag completion. These are some of the same tricks used in the previous commits to speed up refs completion, namely:

  • Extend both functions to accept prefix, current word and suffix positional parameters, all optional and all empty by default to keep the parameterless behavior unaltered.

  • Specify appropriate globbing patterns to 'git for-each-ref' to list only branches or tags matching the given current word parameter.

  • Modify the 'git for-each-ref --format=<...>' to include the given prefix and suffix.

  • Adjust all callsites to specify the proper prefix, current word and suffix parameters, and to fill COMPREPLY using __gitcomp_direct().


注意:Git 2.18(2018 年第 2 季度)改进了文件名完成的性能:参见“Git bash-completion with filename support?

关于git bash 自动完成在 Windows 7 x64 上很慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19936050/

相关文章:

function - 新定义的别名在函数内不起作用(zsh)

zsh - 如何在命令行中获得前一个命令的第 n 个参数?

git - 克隆没有从 GitHub 获取我的所有分支

javascript - Heroku Node 应用推送失败

user-interface - 如何为 bash 脚本制作 GUI?

bash - 如何发布带有需要转义字符的 curl 的 json 字符串?

ruby - 无法在 Mac 上解析 zsh 和 oh-my-zsh 的 "rbenv init"指令

git - 让 buildbot 轮询 git 存储库以获取新提交?

git - .gitignore subdir/* 和 subdir/有什么区别?

bash - 期待函数 bash