MCPcopy Index your code
hub / github.com/go-git/go-git / decodeFirstHash

Function decodeFirstHash

plumbing/protocol/packp/advrefs_decode.go:129–154  ·  view source on GitHub ↗

If the first hash is zero, then a no-refs is coming. Otherwise, a list-of-refs is coming, and the hash will be followed by the first advertised ref.

(p *advRefsDecoder)

Source from the content-addressed store, hash-verified

127// list-of-refs is coming, and the hash will be followed by the first
128// advertised ref.
129func decodeFirstHash(p *advRefsDecoder) decoderStateFn {
130 // If the repository is empty, we receive a flush here (HTTP).
131 if isFlush(p.line) {
132 p.err = ErrEmptyAdvRefs
133 return nil
134 }
135
136 // TODO: Use object-format (when available) for hash size. Git 2.41+
137 if len(p.line) < hashSize {
138 p.error("cannot read hash, pkt-line too short")
139 return nil
140 }
141
142 if _, err := hex.Decode(p.hash[:], p.line[:hashSize]); err != nil {
143 p.error("invalid hash text: %s", err)
144 return nil
145 }
146
147 p.line = p.line[hashSize:]
148
149 if p.hash.IsZero() {
150 return decodeSkipNoRefs
151 }
152
153 return decodeFirstRef
154}
155
156// Skips SP "capabilities^{}" NUL
157func decodeSkipNoRefs(p *advRefsDecoder) decoderStateFn {

Callers

nothing calls this directly

Calls 4

isFlushFunction · 0.85
DecodeMethod · 0.65
IsZeroMethod · 0.65
errorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…