git 在搜索 repo 时尝试统计 //HEAD,导致 Cygwin 的巨大延迟
git tries to stat //HEAD when searching for a repo, leading to huge delays on Cygwin
我有一个奇特的 shell 提示执行 git rev-parse --is-inside-work-tree
来确定我们当前是否在工作目录中。这会导致 git 在目录层次结构中向上查找包含 git 的回购协议。例如,当从我的主目录调用时,它按顺序统计以下路径:
/home/me/.git
/home/me/.git/HEAD
/home/me/HEAD
/home
/home/.git
/home/.git/HEAD
/home/HEAD
/
/.git
/.git/HEAD
//HEAD
姓氏 (//HEAD
) 与 Cygwin 的交互很糟糕,Cygwin 将其解释为 UNC 文件共享,因此按需加载一堆额外的 DLL 并尝试 resolve/contact 名为的服务器HEAD
。这显然不能很好地工作,尤其是在慢速网络上 link.
这闻起来像 git 中的错误,尽管在没有对 // 的奇怪解释的平台上可能是无害的,所以我正在寻找解决方法。
我已经使用最新的 Cygwin git (2.15.0) 进行了测试;这也出现在以前的版本中。
Cygwin 似乎无法关闭 UNC 路径支持,但您可以通过在您的环境中设置 GIT_CEILING_DIRECTORIES
来缩短搜索。我的 .zshenv
有:
export GIT_CEILING_DIRECTORIES=/:$HOME
这会终止在 /(避免 //HEAD)和 $HOME 处的任何搜索,因为我知道它不在存储库中。
这看起来会在上游 git 中修复。参考:discussion thread, patch
git tries to stat //HEAD
它确实已在上游修复,对于 Git 2.15.x/2.16(2018 年第一季度),它更正了启动顺序,以便可以立即将存储库放置在再次进入根目录(在 Git 2.13 左右被破坏)。
参见 commit fa4d8c7 (03 Nov 2017) by Jeff King (peff
)。
(由 Junio C Hamano -- gitster
-- in commit 57dd3dd 合并,2017 年 11 月 9 日)
setup
: avoid double slashes when looking for HEAD
Andrew Baumann reported that when called outside of any Git worktree, git rev-parse --is-inside-work-tree
eventually tries to access //HEAD
, i.e. any HEAD
file in the root directory, but with a double slash.
This double slash is not only unintentional, but is allowed by the POSIX standard to have a special meaning. And most notably on Windows, it does, where it refers to a UNC path of the form //server/share/
.
As a consequence, afore-mentioned rev-parse
call not only looks for the wrong thing, but it also causes serious delays, as Windows will try to access a server called HEAD
.
Let's simply avoid the unintended double slash.
我有一个奇特的 shell 提示执行 git rev-parse --is-inside-work-tree
来确定我们当前是否在工作目录中。这会导致 git 在目录层次结构中向上查找包含 git 的回购协议。例如,当从我的主目录调用时,它按顺序统计以下路径:
/home/me/.git
/home/me/.git/HEAD
/home/me/HEAD
/home
/home/.git
/home/.git/HEAD
/home/HEAD
/
/.git
/.git/HEAD
//HEAD
姓氏 (//HEAD
) 与 Cygwin 的交互很糟糕,Cygwin 将其解释为 UNC 文件共享,因此按需加载一堆额外的 DLL 并尝试 resolve/contact 名为的服务器HEAD
。这显然不能很好地工作,尤其是在慢速网络上 link.
这闻起来像 git 中的错误,尽管在没有对 // 的奇怪解释的平台上可能是无害的,所以我正在寻找解决方法。
我已经使用最新的 Cygwin git (2.15.0) 进行了测试;这也出现在以前的版本中。
Cygwin 似乎无法关闭 UNC 路径支持,但您可以通过在您的环境中设置 GIT_CEILING_DIRECTORIES
来缩短搜索。我的 .zshenv
有:
export GIT_CEILING_DIRECTORIES=/:$HOME
这会终止在 /(避免 //HEAD)和 $HOME 处的任何搜索,因为我知道它不在存储库中。
这看起来会在上游 git 中修复。参考:discussion thread, patch
git tries to stat
//HEAD
它确实已在上游修复,对于 Git 2.15.x/2.16(2018 年第一季度),它更正了启动顺序,以便可以立即将存储库放置在再次进入根目录(在 Git 2.13 左右被破坏)。
参见 commit fa4d8c7 (03 Nov 2017) by Jeff King (peff
)。
(由 Junio C Hamano -- gitster
-- in commit 57dd3dd 合并,2017 年 11 月 9 日)
setup
: avoid double slashes when looking forHEAD
Andrew Baumann reported that when called outside of any Git worktree,
git rev-parse --is-inside-work-tree
eventually tries to access//HEAD
, i.e. anyHEAD
file in the root directory, but with a double slash.This double slash is not only unintentional, but is allowed by the POSIX standard to have a special meaning. And most notably on Windows, it does, where it refers to a UNC path of the form
//server/share/
.As a consequence, afore-mentioned
rev-parse
call not only looks for the wrong thing, but it also causes serious delays, as Windows will try to access a server calledHEAD
.
Let's simply avoid the unintended double slash.