MCPcopy
hub / github.com/git-lfs/git-lfs / DecodeFrom

Function DecodeFrom

lfs/pointer.go:129–152  ·  view source on GitHub ↗

DecodeFrom decodes an *lfs.Pointer from the given io.Reader, "reader". If the pointer encoded in the reader could successfully be read and decoded, it will be returned with a nil error. If the pointer could not be decoded, an io.Reader containing the entire blob's data will be returned, along with

(reader io.Reader)

Source from the content-addressed store, hash-verified

127// If the pointer could not be decoded, an io.Reader containing the entire
128// blob's data will be returned, along with a parse error.
129func DecodeFrom(reader io.Reader) (*Pointer, io.Reader, error) {
130 buf := make([]byte, blobSizeCutoff)
131 n, err := reader.Read(buf)
132 buf = buf[:n]
133
134 var contents io.Reader = bytes.NewReader(buf)
135 if err != io.EOF {
136 contents = io.MultiReader(contents, reader)
137 }
138
139 if err != nil && err != io.EOF {
140 return nil, contents, err
141 }
142
143 if len(buf) == 0 {
144 return EmptyPointer(), contents, nil
145 }
146
147 p, err := decodeKV(bytes.TrimSpace(buf))
148 if err == nil && p != nil {
149 p.Canonical = p.Encoded() == string(buf)
150 }
151 return p, contents, err
152}
153
154func verifyVersion(version string) error {
155 if len(version) == 0 {

Callers 5

delayedSmudgeFunction · 0.92
smudgeFunction · 0.92
copyToTempMethod · 0.85
DecodePointerFunction · 0.85

Calls 4

EmptyPointerFunction · 0.85
decodeKVFunction · 0.85
EncodedMethod · 0.80
ReadMethod · 0.45

Tested by 1