git尝试在搜索仓库时尝试统计//HEAD,从而导致Cygwin出现大量延迟 [英] git tries to stat //HEAD when searching for a repo, leading to huge delays on Cygwin

查看:68
本文介绍了git尝试在搜索仓库时尝试统计//HEAD,从而导致Cygwin出现大量延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个漂亮的shell提示,它会执行 git rev-parse --is-inside-work-tree 以确定我们当前是否在工作目录中.这将导致git在目录层次结构中查找包含git repo的内容.例如,当从我的主目录调用时,它按顺序统计以下路径:

I have a fancy shell prompt that executes git rev-parse --is-inside-work-tree to determine whether we're currently inside a working directory. This causes git to walk up the directory hierarchy looking for a containing git repo. For example, when invoked from my home directory, it stats the following paths, in order:

/home/me/.git
/home/me/.git/HEAD
/home/me/HEAD
/home
/home/.git
/home/.git/HEAD
/home/HEAD
/
/.git
/.git/HEAD
//HEAD

姓氏(//HEAD )与Cygwin交互不良,后者将其解释为UNC文件共享,因此需要加载大量额外的DLL,并尝试解析/联系服务器名为 HEAD .这显然不能很好地工作,尤其是在网络连接速度慢的情况下.

The last name (//HEAD) interacts badly with Cygwin, which interprets it as a UNC file share, and so demand-loads a bunch of extra DLLs and attempts to resolve/contact the server named HEAD. This obviously doesn't work too well, especially over a slow network link.

这闻起来像git中的错误,尽管在没有//奇怪解释的平台上,这可能是无害的,所以我正在寻找一种解决方法.

This smells like a bug in git, albeit one that's probably harmless on platforms without the strange interpretation of //, so I'm looking for a workaround.

我已经使用最新的Cygwin git(2.15.0)进行了测试;以前的版本中也有.

I've tested with the latest Cygwin git (2.15.0); this was also present in a prior version.

推荐答案

git尝试统计//HEAD

对于Git 2.15.x/2.16(2018年第一季度),它确实已在上游修复,并且它纠正了启动顺序,以便可以将存储库再次立即放置在根目录下(在大约Git 2.13).

It has indeed been fixed in upstream, for Git 2.15.x/2.16 (Q1 2018), and it corrects the start-up sequence so that a repository could be placed immediately under the root directory again (which was broken at around Git 2.13).

请参见提交fa4d8c7 (2017年11月3日),作者为 Junio C Hamano合并- gitster -提交57dd3dd ,2017年11月9日)

See commit fa4d8c7 (03 Nov 2017) by Jeff King (peff).
(Merged by Junio C Hamano -- gitster -- in commit 57dd3dd, 09 Nov 2017)

设置:查找 HEAD

时避免双斜杠

Andrew Baumann报告说,当在任何Git工作树之外调用 git rev-parse --is-inside-work-tree 时,最终会尝试访问//HEAD ,即根目录中的任何 HEAD 文件,但带有双斜杠.

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.

此双斜杠不仅是无意的,而且POSIX标准允许其具有特殊含义.并且最值得注意的是在Windows上,它以///server/share/形式的UNC路径引用.

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/.

因此,前面提到的 rev-parse 调用不仅查找错误的内容,而且还会导致严重的延迟,因为Windows将尝试访问名为 HEAD <的服务器./code>.
让我们简单地避免意外的双斜杠.

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.

这篇关于git尝试在搜索仓库时尝试统计//HEAD,从而导致Cygwin出现大量延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆