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

Method verifyFileHeader

plumbing/format/commitgraph/v2/file.go:113–138  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

111}
112
113func (fi *fileIndex) verifyFileHeader() error {
114 // Verify file signature
115 signature := make([]byte, szSignature)
116 if _, err := fi.reader.ReadAt(signature, 0); err != nil {
117 return err
118 }
119 if !bytes.Equal(signature, commitFileSignature) {
120 return ErrMalformedCommitGraphFile
121 }
122
123 // Read and verify the file header
124 header := make([]byte, szHeader)
125 if _, err := fi.reader.ReadAt(header, szHeader); err != nil {
126 return err
127 }
128 if header[0] != 1 {
129 return ErrUnsupportedVersion
130 }
131 if !(hash.CryptoType == crypto.SHA1 && header[1] == 1) &&
132 !(hash.CryptoType == crypto.SHA256 && header[1] == 2) {
133 // Unknown hash type / unsupported hash type
134 return ErrUnsupportedHash
135 }
136
137 return nil
138}
139
140func (fi *fileIndex) readChunkHeaders() error {
141 // The chunk table is a list of 4-byte chunk signatures and uint64 offsets into the file

Callers 1

OpenFileIndexWithParentFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected