{"thread":{"id":"2221","subject":"[PATCH] fetch/upload: Fix corner case with few revs","startedAt":"2005-10-25T15:34:07Z","lastAt":"2005-10-26T18:34:12Z","messageCount":4,"participants":["Johannes Schindelin","Junio C Hamano","Alex Riesen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"10584","messageId":"Pine.LNX.4.63.0510251730200.12176@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2221","inReplyTo":null,"subject":"[PATCH] fetch/upload: Fix corner case with few revs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-10-25T15:34:07Z","receivedAt":"2005-10-25T15:34:07Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"When git-fetch-pack did not have enough revs to send, it did not realize \nthat the server actually speaks multi_ack. The server would now continue \nsending ack´s, but the client would try to unpack objects. Oops.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n\tI have a sizable collection of brown paper bags by now.\n\n fetch-pack.c  |   13 +++++++++----\n upload-pack.c |   15 +++++++++++----\n 2 files changed, 20 insertions(+), 8 deletions(-)\n\napplies-to: f4786932e8753bdd07e44829a97a47749b329ee8\n9a0ea94256236f1d038b16eb834fdfa5987f308c\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 7015dc5..b02a24a 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -224,12 +224,17 @@ done:\n \tif (retval != 0)\n \t\tflushes++;\n \twhile (flushes) {\n-\t\tif (get_ack(fd[0], result_sha1)) {\n+\t\tint ack = get_ack(fd[0], result_sha1);\n+\t\tif (ack) {\n \t\t\tif (verbose)\n-\t\t\t\tfprintf(stderr, \"got ack %s\\n\",\n+\t\t\t\tfprintf(stderr, \"got ack (%d) %s\\n\", ack,\n \t\t\t\t\tsha1_to_hex(result_sha1));\n-\t\t\tif (!multi_ack)\n-\t\t\t\treturn 0;\n+\t\t\tif (!multi_ack) {\n+\t\t\t\tif (ack == 2)\n+\t\t\t\t\tmulti_ack = 1;\n+\t\t\t\telse\n+\t\t\t\t\treturn 0;\n+\t\t\t}\n \t\t\tretval = 0;\n \t\t\tcontinue;\n \t\t}\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 25a343e..1dbde5f 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -116,7 +116,7 @@ static int get_common_commits(void)\n {\n \tstatic char line[1000];\n \tunsigned char sha1[20];\n-\tint len;\n+\tint len, last_sent_was_nak = 0;\n \n \ttrack_object_refs = 0;\n \tsave_commit_buffer = 0;\n@@ -126,23 +126,30 @@ static int get_common_commits(void)\n \t\treset_timeout();\n \n \t\tif (!len) {\n-\t\t\tif (multi_ack || nr_has == 0)\n+\t\t\tif (multi_ack || nr_has == 0) {\n \t\t\t\tpacket_write(1, \"NAK\\n\");\n+\t\t\t\tlast_sent_was_nak = 1;\n+\t\t\t}\n \t\t\tcontinue;\n \t\t}\n \t\tlen = strip(line, len);\n \t\tif (!strncmp(line, \"have \", 5)) {\n \t\t\tif (got_sha1(line+5, sha1) &&\n-\t\t\t\t\t(multi_ack || nr_has == 1))\n+\t\t\t\t\t(multi_ack || nr_has == 1)) {\n \t\t\t\tpacket_write(1, \"ACK %s%s\\n\",\n \t\t\t\t\tsha1_to_hex(sha1),\n \t\t\t\t\tmulti_ack && nr_has < MAX_HAS ?\n \t\t\t\t\t\" continue\" : \"\");\n+\t\t\t\tlast_sent_was_nak = 0;\n+\t\t\t}\n \t\t\tcontinue;\n \t\t}\n \t\tif (!strcmp(line, \"done\")) {\n-\t\t\tif (nr_has > 0)\n+\t\t\tif (nr_has > 0) {\n+\t\t\t\tif (multi_ack && !last_sent_was_nak)\n+\t\t\t\t\tpacket_write(1, \"NAK\\n\");\n \t\t\t\treturn 0;\n+\t\t\t}\n \t\t\tpacket_write(1, \"NAK\\n\");\n \t\t\treturn -1;\n \t\t}\n---\n0.99.8.GIT"},{"id":"10594","messageId":"7vll0hfqdb.fsf@assigned-by-dhcp.cox.net","threadId":"2221","inReplyTo":"Pine.LNX.4.63.0510251730200.12176@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] fetch/upload: Fix corner case with few revs","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-10-25T17:39:12Z","receivedAt":"2005-10-25T17:39:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> When git-fetch-pack did not have enough revs to send, it did not realize \n> that the server actually speaks multi_ack. The server would now continue \n> sending ack', but the client would try to unpack objects. Oops.\n\nI've already pushed your initial set out to \"master\", but I\nsuspect we may be better of if I recall them and let it simmer a\nbit longer in the proposed updates branch, and defer them post\n0.99.9.  What do you think?\n"},{"id":"10608","messageId":"Pine.LNX.4.63.0510252259001.15756@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2221","inReplyTo":"7vll0hfqdb.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] fetch/upload: Fix corner case with few revs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-10-25T20:59:53Z","receivedAt":"2005-10-25T20:59:53Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 25 Oct 2005, Junio C Hamano wrote:\n\n> I've already pushed your initial set out to \"master\", but I\n> suspect we may be better of if I recall them and let it simmer a\n> bit longer in the proposed updates branch, and defer them post\n> 0.99.9.  What do you think?\n\nYes, please. Sorry for the problems.\n\nCiao,\nDscho\n"},{"id":"10677","messageId":"20051026183412.GB8030@steel.home","threadId":"2221","inReplyTo":"Pine.LNX.4.63.0510251730200.12176@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH 4/4] git-fetch-pack: Implement client part of the multi_ack extension","fromName":"Alex Riesen","fromEmail":"fork0@users.sourceforge.net","sentAt":"2005-10-26T18:34:12Z","receivedAt":"2005-10-26T18:34:12Z","isPatch":true,"sender":{"key":"fork0@users.sourceforge.net","avatar":null},"body":"Johannes Schindelin, Wed, Oct 26, 2005 10:41:47 +0200:\n> > > Could you please try the patch I sent with the subject \"[PATCH]\n> > > fetch/upload: Fix corner case with few revs\"? Your output looks exactly\n> > > like what I fixed with that patch.\n> > I couldn't at the moment. Do you still need a test?\n> If you have time and can test it, yes, please.\n\nJohannes Schindelin, Tue, Oct 25, 2005 17:34:07 +0200:\n> When git-fetch-pack did not have enough revs to send, it did not realize \n> that the server actually speaks multi_ack. The server would now continue \n> sending ack´s, but the client would try to unpack objects. Oops.\n\nThis patch fixed it.\n"}]}