共享目录中的索引文件错误 [英] Bad index file while in shared directory

查看:152
本文介绍了共享目录中的索引文件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 8上使用VMWare使用Ubuntu VM,在使用git时出现错误

I use an Ubuntu VM over Windows 8 using VMWare and while using git I got an error of

error: bad index file sha1 signature
fatal: index file corrupt

尝试commit时.

现在,我找到了解决此问题的方法(主要方法是删除.git/index并重试,这似乎有点解决方法),但我想了解是什么导致了此错误(部分是因为它们倾向于以随机方式工作) ).

Now, I found ways to fix this (the primary one, deleting .git/index and retrying, seems a bit of a workaround) but I want to understand what causes this error (Partly because they tend to work in a random way).

我做了一个实验,并在~/(常规目录)和/mnt/hgfs/Shared with host/(与Windows主机共享的目录,这是我的笔记本电脑)中运行了几个命令.

I made an experiment and run a couple of commands in ~/ (a regular directory) and in /mnt/hgfs/Shared with host/ (the shared directory with the Windows host, which is my laptop).

在常规目录中,它可以正常工作,但是在共享目录中,它会由于提交消息中的上述错误而失败.

In the regular directory it worked flawlessly, but in the shared directory it failed with the above error on the commit message.

命令是:

mkdir trial
cd trial
echo hello > world.txt
git init
git add .
git commit -m "msg"

现在我不知道,共享目录为什么很重要?
通常,什么原因导致此错误?与索引文件相比,哪个sha1签名(我在运行tree .git时没有发现任何可以存储这种签名的东西)?

Now I wonder, why does it matter that the directory is shared?
And in general, what causes this error? Which sha1 signature is the index file compared to (I didn't find anything that could store such a signature when running tree .git)?

推荐答案

爱德华·汤姆森(Edward Thomson)的评论是正确的-您可以从错误消息和

Edward Thomson's comment is correct—you can see this from the error message and the corresponding source code function verify_hdr, which includes these lines:

git_SHA1_Init(&c);
git_SHA1_Update(&c, hdr, size - 20);
git_SHA1_Final(sha1, &c);
if (hashcmp(sha1, (unsigned char *)hdr + size - 20))
        return error("bad index file sha1 signature");

(魔术常数20是计算出的SHA1的字节大小).

(the magic constant 20 is the size in bytes of the computed SHA1).

一点还不清楚的是,在共享文件时,是什么导致索引文件中的二进制数据被不适当地修改.但是很明显,它 的修改不当,并且这种VMWare共享机制不适用于这种情况.

What's not at all clear is what, in the sharing of the file, is causing the binary data in the index file to be modified inappropriately. But clearly it is being modified inappropriately, and this VMWare sharing mechanism does not work for this case.

这篇关于共享目录中的索引文件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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