summaryrefslogtreecommitdiff
path: root/trace.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-06-16 13:23:20 -0400
committerJunio C Hamano <gitster@pobox.com>2015-06-16 13:24:22 -0700
commit323598387d900263c4980b43b8a96c43cdd7b6c7 (patch)
tree3d52379c0cabf02e52a05586ab9c2baa6e3a68f7 /trace.c
parentd6d1a75e51cf90650ac6e2cdcd8d108324b6fdb9 (diff)
downloadgit-323598387d900263c4980b43b8a96c43cdd7b6c7.tar.gz
pkt-line: support tracing verbatim pack contentsjk/pkt-log-pack
When debugging the pack protocol, it is sometimes useful to store the verbatim pack that we sent or received on the wire. Looking at the on-disk result is often not helpful for a few reasons: 1. If the operation is a clone, we destroy the repo on failure, leaving nothing on disk. 2. If the pack is small, we unpack it immediately, and the full pack never hits the disk. 3. If we feed the pack to "index-pack --fix-thin", the resulting pack has the extra delta bases added to it. We already have a GIT_TRACE_PACKET mechanism for tracing packets. Let's extend it with GIT_TRACE_PACKFILE to dump the verbatim packfile. There are a few other positive fallouts that come from rearranging this code: - We currently disable the packet trace after seeing the PACK header, even though we may get human-readable lines on other sidebands; now we include them in the trace. - We currently try to print "PACK ..." in the trace to indicate that the packfile has started. But because we disable packet tracing, we never printed this line. We will now do so. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'trace.c')
-rw-r--r--trace.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/trace.c b/trace.c
index 3c3bd8fc98..7393926ebc 100644
--- a/trace.c
+++ b/trace.c
@@ -120,6 +120,13 @@ static int prepare_trace_line(const char *file, int line,
return 1;
}
+void trace_verbatim(struct trace_key *key, const void *buf, unsigned len)
+{
+ if (!trace_want(key))
+ return;
+ write_or_whine_pipe(get_trace_fd(key), buf, len, err_msg);
+}
+
static void print_trace_line(struct trace_key *key, struct strbuf *buf)
{
strbuf_complete_line(buf);