简体   繁体   English

当目标是网络驱动器时,git clone 失败

[英]git clone fails when destination is a network drive

I'm having issues cloning a git repository on Windows using git in a MINGW32 shell.我在 MINGW32 shell 中使用 git 在 Windows 上克隆 git 存储库时遇到问题。 The basic symptom is that cloning this specific repository works fine when the destination is on my local disk but the identical command fails when the clone destination is on a network drive.基本症状是,当目标位于我的本地磁盘上时,克隆此特定存储库工作正常,但当克隆目标位于网络驱动器上时,相同的命令将失败。 Here is the local clone command (with the repo name redacted):这是本地克隆命令(已编辑存储库名称):

drichards@LT-DR MINGW32 /c/temp
$ git clone -v --progress <repo> gitrepo
Cloning into 'gitrepo'...
POST git-upload-pack (250 bytes)
remote: Counting objects: 82, done.
remote: Compressing objects: 100% (71/71), done.
remote: Total 82 (delta 26), reused 0 (delta 0)
Unpacking objects: 100% (82/82), done.
Checking connectivity... done.

Trying exactly the same procedure on a network drive results in failure.在网络驱动器上尝试完全相同的过程会导致失败。 In this case drive S: is mapped to a network location.在这种情况下,驱动器 S: 映射到网络位置。

drichards@LT-DR MINGW32 /s/temp
$ git clone -v --progress <repo> gitrepo
Cloning into 'gitrepo'...
POST git-upload-pack (250 bytes)
remote: Counting objects: 82, done.
remote: Compressing objects: 100% (71/71), done.
fatal: failed to read object 9b081a422a5f7d06ff5a2cb4889d26b4f18c6181: Permission denied
fatal: unpack-objects failed

The folder 'gitrepo' is temporarily created and then cleaned up on failure, so I can't easily pick through it to find out what went wrong.文件夹 'gitrepo' 是临时创建的,然后在失败时清理,所以我不能轻易地通过它找出问题所在。 It seemed like a fairly straightforward permissions issue, so I thought attaching ProcMon would be a good solution to finding out where it had gone wrong, however, when ProcMon is running, the clone works with no problems.这似乎是一个相当简单的权限问题,所以我认为附加ProcMon是找出哪里出错的一个很好的解决方案,但是,当 ProcMon 运行时,克隆工作没有问题。

This seems to imply that there is some kind of consistency problem or race condition which is occurring when the destination is a network drive.这似乎意味着当目标是网络驱动器时,存在某种一致性问题或竞争条件。 I have collected the output when the destination is the network drive with GIT_TRACE set to 1 and ProcMon not connected - that doesn't reveal anything interesting to my eyes.当目标是 GIT_TRACE 设置为 1 且 ProcMon 未连接的网络驱动器时,我已经收集了输出 - 这不会让我看到任何有趣的东西。 Here is the failure moment:这是失败的时刻:

11:07:48.262535 run-command.c:336       trace: run_command: 'unpack-objects' '--pack_header=2,82'
11:07:48.324578 git.c:350               trace: built-in: git 'unpack-objects' '--pack_header=2,82'
fatal: failed to read object 9b081a422a5f7d06ff5a2cb4889d26b4f18c6181: Permission denied
fatal: unpack-objects failed

I have also tried asking git to validate objects by adding git clone -c transfer.fsckObjects=1 but that doesn't change the symptoms.我还尝试通过添加git clone -c transfer.fsckObjects=1来要求 git 验证对象,但这并没有改变症状。

As alluded to earlier, the problem seems specific to a repository.如前所述,该问题似乎特定于存储库。 Here are a few other data points:以下是一些其他数据点:

  • The code hosting server (which is separate from all the other machines mentioned so far) has many repositories and I've cloned several others onto the network with no issue.代码托管服务器(与目前提到的所有其他机器分开)有许多存储库,我已经将其他几个存储库克隆到网络上,没有任何问题。
  • The issue occurs regardless of whether a regular or bare clone is made无论是制作常规克隆还是裸克隆,都会出现此问题
  • There doesn't appear to be anything special about the object which causes the failure (the packed size is intermediate - 727 bytes)导致失败的对象似乎没有什么特别之处(打包大小是中间的 - 727 字节)
  • If I attach ProcMon and disconnect whilst git is unpacking, the process still fails, usually on a different object.如果我在 git 解包时附加 ProcMon 并断开连接,该过程仍然失败,通常是在不同的对象上。
  • A colleague also experiences the same success / fail patterns depending on the destination location.根据目标位置,同事也会经历相同的成功/失败模式。
  • The process still fails if I execute git from a local directory, specifying the target directory as a UNC path如果我从本地目录执行 git,将目标目录指定为 UNC 路径,该过程仍然失败

Here are a few vital stats on my local machine:以下是我本地机器上的一些重要统计信息:

$ systeminfo
<snip>
OS Name:                   Microsoft Windows 8.1 Pro
OS Version:                6.3.9600 N/A Build 9600
<snip>
$ uname -a
MINGW32_NT-6.3-WOW LT-DR 2.5.0(0.295/5/3) 2016-03-31 18:26 i686 Msys
$ git --version
git version 2.8.3.windows.1

The server hosting the target directories in question runs Windows Server 2008. The code server is running gitlab-ce 8.9.3.托管目标目录的服务器运行 Windows Server 2008。代码服务器运行 gitlab-ce 8.9.3。

This is where the notion of " promissor remote " comes in.这就是“ promissor remote ”的概念出现的地方。

That notion is used with the transfer.fsckobjects configuration: it tells " git fetch " to validate the data and connected-ness of objects in the received pack;该概念与transfer.fsckobjects配置一起使用:它告诉“ git fetch ”验证接收到的包中对象的数据和连接性; the code to perform this check has been taught about the narrow clone's convention that missing objects that are reachable from objects in a pack that came from a promissor remote is OK.执行此检查的代码已被教导关于窄克隆的约定,即丢失可从来自promissor 遥控器的包中的对象访问的对象是可以的。

Before Git 2.29 (Q4 2020), while packing many objects in a repository with a promissor remote, lazily fetching missing objects from the promissor remote one by one may be inefficient.在 Git 2.29(2020 年第 4 季度)之前,虽然将许多对象打包到一个具有承诺者远程的存储库中,但从承诺者远程一个接一个地懒惰地获取丢失的对象可能效率低下。

The code now attempts to fetch all the missing objects in batch (obviously this won't work for a lazy clone that lazily fetches tree objects as you cannot even enumerate what blobs are missing until you learn which trees are missing).代码现在尝试批量获取所有丢失的对象(显然这不适用于懒惰地获取树对象的懒惰克隆,因为在您了解丢失了哪些树之前,您甚至无法枚举丢失的 blob)。

That might help with your git clone from a network drive.这可能有助于您从网络驱动器克隆 git。

See commit e00549a , commit 8d5cf95 (20 Jul 2020) by Jonathan Tan ( jhowtan ) .请参阅Jonathan Tan ( jhowtan ) 提交的 e00549a提交 8d5cf95 (2020 年 7 月 20 日
(Merged by Junio C Hamano -- gitster -- in commit 5c454b3 , 04 Aug 2020) (由Junio C gitster -- gitster --commit 5c454b3 中合并,2020 年 8 月 4 日)

pack-objects : prefetch objects to be packed pack-objects : 预取要打包的对象

Signed-off-by: Jonathan Tan签字人:Jonathan Tan

When an object to be packed is noticed to be missing, prefetch all to-be-packed objects in one batch.当发现某个待打包对象丢失时,一次性预取所有待打包对象。


And still with Git 2.29 (Q4 2020), " git fetch " ( man ) works better when the packfile URI capability is in use.在 Git 2.29(2020 年第 4 季度)中,当使用 packfile URI 功能时,“ git fetch( man )效果更好。

See commit 0bd96be , commit ece9aea , commit 42d418d (17 Aug 2020) by Jonathan Tan ( jhowtan ) .请参阅Jonathan Tan ( jhowtan ) 的commit 0bd96becommit ece9aeacommit 42d418d (2020 年 8 月 17 日
(Merged by Junio C Hamano -- gitster -- in commit bdccf5e , 03 Sep 2020) (由Junio C gitster -- gitster --提交 bdccf5e 中合并,2020 年 9 月 3 日)

fetch-pack : make packfile URIs work with transfer.fsckobjects fetch-pack :使fetch-pack文件 URI 与transfer.fsckobjects

Signed-off-by: Jonathan Tan签字人:Jonathan Tan

When fetching with packfile URIs and transfer.fsckobjects=1 , use the --fsck-objects instead of the --strict flag when invoking index-pack so that links are not checked, only objects.当使用 packfile URI 和transfer.fsckobjects=1获取时,在调用index-pack时使用--fsck-objects而不是--strict标志,以便不检查链接,只检查对象。

This is because incomplete links are expected.这是因为需要不完整的链接。 (A subsequent connectivity check will be done when all the packs have been downloaded regardless of whether transfer.fsckobjects is set.) (无论是否设置了transfer.fsckobjects当所有包都下载后,将进行后续连接检查。)

This is similar to 98a2ea46c2 (" fetch-pack : do not check links for partial fetch", 2018-03-15, Git v2.17.0-rc1 -- merge ), but for packfile URIs instead of partial clones.这类似于98a2ea46c2 (“ fetch-pack : do not check links for partial fetch”, 2018-03-15, Git v2.17.0-rc1 -- merge ),但用于包文件 URI 而不是部分克隆。


With Git 2.31 (Q1 2021), we know more about the packfiles downloaded with the packfile URI feature.在 Git 2.31(2021 年第一季度)中,我们对使用 packfile URI 功能下载的包文件有了更多了解。

See commit bfc2a36 (20 Jan 2021) by Jonathan Tan ( jhowtan ) .请参阅Jonathan Tan ( jhowtan ) 提交的 bfc2a36 (20 Jan 2021 )
(Merged by Junio C Hamano -- gitster -- in commit d03553e , 03 Feb 2021) (由Junio C gitster合并-- gitster -- in commit d03553e ,2021 年 2 月 3 日)

Doc : clarify contents of packfile sent as URI Doc :阐明作为 URI 发送的包Doc内容

Signed-off-by: Jonathan Tan签字人:Jonathan Tan

Clarify that, when the packfile-uri feature is used, the client should not assume that the extra packfiles downloaded would only contain a single blob, but support packfiles containing multiple objects of all types.澄清一下,当使用 packfile-uri 功能时,客户端不应假设下载的额外包文件仅包含单个 blob,而是支持包含所有类型的多个对象的包文件。

technical/packfile-uri now includes in its man page : technical/packfile-uri现在包含在其手册页中

blobs are excluded, replaced with URIs. blob 被排除在外,替换为 URI。 As noted in "Future work" below, the server can evolve in the future to support excluding other objects (or other implementations of servers could be made that support excluding other objects) without needing a protocol change, so clients should not expect that packfiles downloaded in this way only contain single blobs.正如下面的“未来工作”中所述,服务器可以在未来发展以支持排除其他对象(或者可以制作支持排除其他对象的其他服务器实现),而无需更改协议,因此客户端不应期望下载的包文件以这种方式只包含单个 blob。


With Git 2.33 (Q3 2021), the description of uploadpack.blobPackfileUri of a packfile-uri (used for fetching, including with a network drive path as in the OP) is enhanced:在 Git 2.33(2021 年第三季度)中,packfile-uri(用于获取,包括 OP 中的网络驱动器路径)的uploadpack.blobPackfileUri的描述得到了增强:

See commit 3127ff9 (13 May 2021) by Teng Long ( dyrone ) .参见Teng Long ( dyrone ) 的commit 3127ff9 (13 May 2021 )
(Merged by Junio C Hamano -- gitster -- in commit 8e1d2fc , 10 Jun 2021) (由Junio C gitster合并-- gitster -- in commit 8e1d2fc ,2021 年 6 月 10 日)

packfile-uri.txt : fix blobPackfileUri description packfile-uri.txt : 修复 blobPackfileUri 描述

Signed-off-by: Teng Long签字人:腾龙
Reviewed-by: Jonathan Tan审核人:Jonathan Tan

Fix the 'uploadpack.blobPackfileUri' description in packfile-uri.txt and the correct format also can be seen in t5702.修复 packfile-uri.txt 中的 'uploadpack.blobPackfileUri' 描述,在 t5702 中也可以看到正确的格式。

technical/packfile-uri now includes in its man page : technical/packfile-uri现在包含在其手册页中

server to be configured by one or more uploadpack.blobPackfileUri= <object-hash> <pack-hash> <uri> entries.服务器由一个或多个uploadpack.blobPackfileUri= <object-hash> <pack-hash> <uri>条目配置。

Whenever the list of objects to be sent is assembled, all such blobs are excluded, replaced with URIs.每当组装要发送的对象列表时,所有此类 blob 都会被排除,并替换为 URI。

As noted in "Future work" below, the server can evolve in the future to support excluding other objects (or other implementations of servers could be made that support excluding other objects) without needing a protocol change, so clients should not expect that packfiles downloaded in this way only contain single blobs.正如下面的“未来工作”中所述,服务器可以在未来发展以支持排除其他对象(或可以支持排除其他对象的其他服务器实现),而无需更改协议,因此客户端不应期望下载的包文件以这种方式只包含单个 blob。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM