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)
| 127 | // list-of-refs is coming, and the hash will be followed by the first |
| 128 | // advertised ref. |
| 129 | func 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 |
| 157 | func decodeSkipNoRefs(p *advRefsDecoder) decoderStateFn { |