Tag: dvcs

解码git对象/“块长度与其补码不匹配”错误

我陷入了非常简单但烦人的问题,并且无法在互联网上找到答案。 希望你能指出我,我做错了什么。 我正在尝试从Git存储库中解码对象。 根据ProGit ,文件名及其内容在提交期间已被缩小。 我正在使用C#将SHA1指示的对象读入流中,将其充气并转换为字节数组。 这是代码: using System.IO.Compression; static internal byte[] GetObjectBySha(string storagePath, string sha) { string filePath = Path.Combine(storagePath, “objects”, sha.Substring(0, 2), sha.Substring(2, 38)); byte[] fileContent = null; using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { using (MemoryStream ms = new MemoryStream()) { using (DeflateStream gs = new DeflateStream(fs, CompressionMode.Decompress)) { gs.CopyTo(ms); […]