{"thread":{"id":"12397","subject":"[PATCH v2 5/7] Teach upload-pack to log the received need lines to fd 3","startedAt":"2008-03-01T05:25:19Z","lastAt":"2008-03-01T05:25:19Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":2,"patchTotal":7},"messages":[{"id":"70473","messageId":"20080301052519.GE27300@spearce.org","threadId":"12397","inReplyTo":null,"subject":"[PATCH v2 5/7] Teach upload-pack to log the received need lines to fd 3","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-03-01T05:25:19Z","receivedAt":"2008-03-01T05:25:19Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"To facilitate testing and verification of the requests sent by git-fetch\nto the remote side we permit logging the received packet lines to file\ndescriptor 3 if GIT_DEBUG_SEND_PACK has been set.  Special start and\nend lines are included to indicate the start and end of each connection.\n\n  $ GIT_DEBUG_SEND_PACK=1 git fetch 3>UPLOAD_LOG\n  $ cat UPLOAD_LOG\n  #S\n  want 8e10cf4e007ad7e003463c30c34b1050b039db78 multi_ack side-band-64k thin-pack ofs-delta\n  want ddfa4a33562179aca1ace2bcc662244a17d0b503\n  #E\n  #S\n  want 3253df4d1cf6fb138b52b1938473bcfec1483223 multi_ack side-band-64k thin-pack ofs-delta\n  #E\n\n>From the above trace the first connection opened by git-fetch was to\ndownload two refs (with values 8e and dd) and the second connection\nwas opened to automatically follow an annotated tag (32).\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n upload-pack.c |    7 +++++++\n 1 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/upload-pack.c b/upload-pack.c\nindex b26d053..4e14020 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -444,7 +444,10 @@ static void receive_needs(void)\n \tstruct object_array shallows = {0, 0, NULL};\n \tstatic char line[1000];\n \tint len, depth = 0;\n+\tint debug_needs = !!getenv(\"GIT_DEBUG_SEND_PACK\");\n \n+\tif (debug_needs)\n+\t\twrite_in_full(3, \"#S\\n\", 3);\n \tfor (;;) {\n \t\tstruct object *o;\n \t\tunsigned char sha1_buf[20];\n@@ -452,6 +455,8 @@ static void receive_needs(void)\n \t\treset_timeout();\n \t\tif (!len)\n \t\t\tbreak;\n+\t\tif (debug_needs)\n+\t\t\twrite_in_full(3, line, len);\n \n \t\tif (!prefixcmp(line, \"shallow \")) {\n \t\t\tunsigned char sha1[20];\n@@ -507,6 +512,8 @@ static void receive_needs(void)\n \t\t\tadd_object_array(o, NULL, &want_obj);\n \t\t}\n \t}\n+\tif (debug_needs)\n+\t\twrite_in_full(3, \"#E\\n\", 3);\n \tif (depth == 0 && shallows.nr == 0)\n \t\treturn;\n \tif (depth > 0) {\n-- \n1.5.4.3.409.g88113\n\n"}]}