MCPcopy Create free account
hub / github.com/git/git / packet_read_with_status

Function packet_read_with_status

pkt-line.c:413–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

411}
412
413enum packet_read_status packet_read_with_status(int fd, char **src_buffer,
414 size_t *src_len, char *buffer,
415 unsigned size, int *pktlen,
416 int options)
417{
418 int len;
419 char linelen[4];
420 const char *uri_path_start;
421
422 if (get_packet_data(fd, src_buffer, src_len, linelen, 4, options) < 0) {
423 *pktlen = -1;
424 return PACKET_READ_EOF;
425 }
426
427 len = packet_length(linelen, sizeof(linelen));
428
429 if (len < 0) {
430 if (options & PACKET_READ_GENTLE_ON_READ_ERROR)
431 return error(_("protocol error: bad line length "
432 "character: %.4s"), linelen);
433 die(_("protocol error: bad line length character: %.4s"), linelen);
434 } else if (!len) {
435 packet_trace("0000", 4, 0);
436 *pktlen = 0;
437 return PACKET_READ_FLUSH;
438 } else if (len == 1) {
439 packet_trace("0001", 4, 0);
440 *pktlen = 0;
441 return PACKET_READ_DELIM;
442 } else if (len == 2) {
443 packet_trace("0002", 4, 0);
444 *pktlen = 0;
445 return PACKET_READ_RESPONSE_END;
446 } else if (len < 4) {
447 if (options & PACKET_READ_GENTLE_ON_READ_ERROR)
448 return error(_("protocol error: bad line length %d"),
449 len);
450 die(_("protocol error: bad line length %d"), len);
451 }
452
453 len -= 4;
454 if ((unsigned)len >= size) {
455 if (options & PACKET_READ_GENTLE_ON_READ_ERROR)
456 return error(_("protocol error: bad line length %d"),
457 len);
458 die(_("protocol error: bad line length %d"), len);
459 }
460
461 if (get_packet_data(fd, src_buffer, src_len, buffer, len, options) < 0) {
462 *pktlen = -1;
463 return PACKET_READ_EOF;
464 }
465
466 if ((options & PACKET_READ_CHOMP_NEWLINE) &&
467 len && buffer[len-1] == '\n') {
468 if (options & PACKET_READ_USE_SIDEBAND) {
469 int band = *buffer & 0xff;
470 switch (band) {

Callers 4

rpc_read_from_outFunction · 0.85
packet_readFunction · 0.85
recv_sidebandFunction · 0.85
packet_reader_readFunction · 0.85

Calls 10

get_packet_dataFunction · 0.85
packet_lengthFunction · 0.85
errorFunction · 0.85
packet_traceFunction · 0.85
find_packfile_uri_pathFunction · 0.85
strbuf_insertFunction · 0.85
strbuf_spliceFunction · 0.85
strbuf_releaseFunction · 0.85
starts_withFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected