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

Function packet_trace

pkt-line.c:40–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40static void packet_trace(const char *buf, unsigned int len, int write)
41{
42 struct strbuf out;
43 static int in_pack, sideband;
44
45 if (!trace_want(&trace_packet) && !trace_want(&trace_pack))
46 return;
47
48 if (in_pack) {
49 if (packet_trace_pack(buf, len, sideband))
50 return;
51 } else if (starts_with(buf, "PACK") || starts_with(buf, "\1PACK")) {
52 in_pack = 1;
53 sideband = *buf == '\1';
54 packet_trace_pack(buf, len, sideband);
55
56 /*
57 * Make a note in the human-readable trace that the pack data
58 * started.
59 */
60 buf = "PACK ...";
61 len = strlen(buf);
62 }
63
64 if (!trace_want(&trace_packet))
65 return;
66
67 /* +32 is just a guess for header + quoting */
68 strbuf_init(&out, len+32);
69
70 strbuf_addf(&out, "packet: %12s%c ",
71 get_trace_prefix(), write ? '>' : '<');
72
73 /* XXX we should really handle printable utf8 */
74 for (unsigned int i = 0; i < len; i++) {
75 /* suppress newlines */
76 if (buf[i] == '\n')
77 continue;
78 if (buf[i] >= 0x20 && buf[i] <= 0x7e)
79 strbuf_addch(&out, buf[i]);
80 else
81 strbuf_addf(&out, "\\%o", buf[i]);
82 }
83
84 strbuf_addch(&out, '\n');
85 trace_strbuf(&trace_packet, &out);
86 strbuf_release(&out);
87}
88
89/*
90 * If we buffered things up above (we don't, but we should),

Callers 11

packet_flushFunction · 0.85
packet_delimFunction · 0.85
packet_response_endFunction · 0.85
packet_flush_gentlyFunction · 0.85
packet_buf_flushFunction · 0.85
packet_buf_delimFunction · 0.85
format_packetFunction · 0.85
do_packet_writeFunction · 0.85
packet_fwriteFunction · 0.85
packet_fflushFunction · 0.85
packet_read_with_statusFunction · 0.85

Calls 8

trace_wantFunction · 0.85
packet_trace_packFunction · 0.85
starts_withFunction · 0.85
strbuf_initFunction · 0.85
strbuf_addfFunction · 0.85
get_trace_prefixFunction · 0.85
strbuf_addchFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected