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

Method ReadStatusWithLines

ssh/protocol.go:218–256  ·  view source on GitHub ↗

ReadStatusWithLines reads a status, arguments, and a set of text lines.

()

Source from the content-addressed store, hash-verified

216
217// ReadStatusWithLines reads a status, arguments, and a set of text lines.
218func (conn *PktlineConnection) ReadStatusWithLines() (int, []string, []string, error) {
219 args := make([]string, 0, 100)
220 lines := make([]string, 0, 100)
221 status := 0
222 seenDelim := false
223 seenStatus := false
224 for {
225 s, pktLen, err := conn.pl.ReadPacketTextWithLength()
226 if err != nil {
227 return 0, nil, nil, errors.NewProtocolError(tr.Tr.Get("error reading packet"), err)
228 }
229 switch {
230 case pktLen == 0:
231 if !seenStatus {
232 return 0, nil, nil, errors.NewProtocolError(tr.Tr.Get("no status seen"), nil)
233 }
234 return status, args, lines, nil
235 case seenDelim:
236 lines = append(lines, s)
237 case !seenStatus:
238 ok := false
239 if strings.HasPrefix(s, "status ") {
240 status, err = strconv.Atoi(s[7:])
241 ok = err == nil
242 }
243 if !ok {
244 return 0, nil, nil, errors.NewProtocolError(tr.Tr.Get("expected status line, got %q", s), err)
245 }
246 seenStatus = true
247 case pktLen == 1:
248 if seenDelim {
249 return 0, nil, nil, errors.NewProtocolError(tr.Tr.Get("unexpected delimiter packet"), nil)
250 }
251 seenDelim = true
252 default:
253 args = append(args, s)
254 }
255 }
256}

Callers 8

negotiateVersionMethod · 0.95
LockMethod · 0.80
UnlockMethod · 0.80
SearchMethod · 0.80
SearchVerifiableMethod · 0.80
batchInternalMethod · 0.80
verifyUploadMethod · 0.80
doUploadMethod · 0.80

Calls 3

NewProtocolErrorFunction · 0.92
GetMethod · 0.65

Tested by

no test coverage detected