MCPcopy Create free account
hub / github.com/go-git/go-git / verifyFileHeader

Method verifyFileHeader

plumbing/format/commitgraph/file.go:76–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

74}
75
76func (fi *fileIndex) verifyFileHeader() error {
77 // Verify file signature
78 signature := make([]byte, 4)
79 if _, err := fi.reader.ReadAt(signature, 0); err != nil {
80 return err
81 }
82 if !bytes.Equal(signature, commitFileSignature) {
83 return ErrMalformedCommitGraphFile
84 }
85
86 // Read and verify the file header
87 header := make([]byte, 4)
88 if _, err := fi.reader.ReadAt(header, 4); err != nil {
89 return err
90 }
91 if header[0] != 1 {
92 return ErrUnsupportedVersion
93 }
94 if hash.CryptoType == crypto.SHA1 {
95 if header[1] != 1 {
96 return ErrUnsupportedVersion
97 }
98 } else if hash.CryptoType == crypto.SHA256 {
99 if header[1] != 2 {
100 return ErrUnsupportedVersion
101 }
102 } else {
103 // Unknown hash type
104 return ErrUnsupportedVersion
105 }
106
107 return nil
108}
109
110func (fi *fileIndex) readChunkHeaders() error {
111 chunkID := make([]byte, 4)

Callers 1

OpenFileIndexFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected