From patchwork Tue Apr 28 00:01:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Tan X-Patchwork-Id: 11513455 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20E5614DD for ; Tue, 28 Apr 2020 00:01:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 059332087E for ; Tue, 28 Apr 2020 00:01:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SW8W5VCN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726271AbgD1ABR (ORCPT ); Mon, 27 Apr 2020 20:01:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726251AbgD1ABQ (ORCPT ); Mon, 27 Apr 2020 20:01:16 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77369C03C1A8 for ; Mon, 27 Apr 2020 17:01:16 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id g23so22541427qto.0 for ; Mon, 27 Apr 2020 17:01:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=7dlEWniC5YOAGNYfTrSAXaBcS+CRwesoGXRuEnRBLvU=; b=SW8W5VCNuV79KDxwloPmfT1vWgaviQWzTWyco8dY5/Q+1s2r1DLEZSOjH8Iu28L0lR ++aL5NiwUr9h7wMg3vczYeAz4d9X/rNurUjneiUpGyrTesClB+JUkpq5UobMjMaFfhUZ fBg2ukBRzFveDYPEd8GKNhVgwW7acEdC90sFMs0mVhXgOr39L49BQO1qvccaQblsSmxM MD1pmAV/hG4wHXavPmoyvB6ljr+5sxCxOfRucDuoa3HoyBhkzq+V1O9LSztsOAfb5GLj Vy5Y/lmprBmQpuNQLHI0H6i1vF/zJ1m/snNQO7LKHS4Qx8OWJgjlUZaSru7wOCKdIF+J Me4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=7dlEWniC5YOAGNYfTrSAXaBcS+CRwesoGXRuEnRBLvU=; b=kzrVEH0+LzT39XWkPPjWlDKyiDfXBIfMmR4Fz+ewE/4+OwqtVpPsabpAP5SH61s4ns 32a0b+qwiPgGehDhl34PjU9boNhDmon0ip+/oaLco7V5xqwu72stqOBAOnsltIHH8zUp RoVWi77XqcQLcnCYsUrXMHJJM669ZRD8/SWVgLdbmoMB15n7p8XzJfVJZS4lRhI6fVtj 41ID1rgLEabDCWbOQUb4QcFoy1xLiPEjWJhBmehNK/XVdrBFYpEyElY4Gw6/Zs63DPYg +jgSGwaoPSl+Wzw4ErP0avAMj2PBY+Hc+1YIykNImDEb3sRk9K902+Tr6lYv4mQlAOK8 HMvw== X-Gm-Message-State: AGi0PublRy1hlKpZfbL5WxlGo+4oKXaDusSyXMSZ9XU1JruTUoP0OEmd nz03RZYJBR4AQaud4SP4A7LNVYiSFVj154GxAUDLGndm6cqR6+PrJ8RcBXmug93+F7vidqae5qr xJULerOKD0iQhd1GM505hdxXIamAcCFrIDVVCSDHv+yO1cjv/e0v07TfFV4VwoKPnlj7GwIyeaB ew X-Google-Smtp-Source: APiQypLZ4VoXkDd9Y+BrCDIOKKxFZxbPAhcgMFDI8lm2R2bMH1W9/lUMJ4EmxL/Cls7XOSYF3Enytg1rKUpVo17OFHc+ X-Received: by 2002:a0c:9e6d:: with SMTP id z45mr25254102qve.206.1588032075437; Mon, 27 Apr 2020 17:01:15 -0700 (PDT) Date: Mon, 27 Apr 2020 17:01:08 -0700 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.26.2.303.gf8c07b1a785-goog Subject: [PATCH v2 1/3] fetch-pack: return enum from process_acks() From: Jonathan Tan To: git@vger.kernel.org Cc: Jonathan Tan , gitster@pobox.com, jrnieder@gmail.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org process_acks() returns 0, 1, or 2, depending on whether "ready" was received and if not, whether at least one commit was found to be common. Replace these magic numbers with a documented enum. Signed-off-by: Jonathan Tan Reviewed-by: Jonathan Nieder --- fetch-pack.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/fetch-pack.c b/fetch-pack.c index 0b07b3ee73..45547a621e 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -1268,9 +1268,29 @@ static int process_section_header(struct packet_reader *reader, return ret; } -static int process_acks(struct fetch_negotiator *negotiator, - struct packet_reader *reader, - struct oidset *common) +enum common_found { + /* + * No commit was found to be possessed by both the client and the + * server, and "ready" was not received. + */ + NO_COMMON_FOUND, + + /* + * At least one commit was found to be possessed by both the client and + * the server, and "ready" was not received. + */ + COMMON_FOUND, + + /* + * "ready" was received, indicating that the server is ready to send + * the packfile without any further negotiation. + */ + READY +}; + +static enum common_found process_acks(struct fetch_negotiator *negotiator, + struct packet_reader *reader, + struct oidset *common) { /* received */ int received_ready = 0; @@ -1320,7 +1340,8 @@ static int process_acks(struct fetch_negotiator *negotiator, die(_("expected no other sections to be sent after no 'ready'")); /* return 0 if no common, 1 if there are common, or 2 if ready */ - return received_ready ? 2 : (received_ack ? 1 : 0); + return received_ready ? READY : + (received_ack ? COMMON_FOUND : NO_COMMON_FOUND); } static void receive_shallow_info(struct fetch_pack_args *args, @@ -1508,13 +1529,13 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, case FETCH_PROCESS_ACKS: /* Process ACKs/NAKs */ switch (process_acks(negotiator, &reader, &common)) { - case 2: + case READY: state = FETCH_GET_PACK; break; - case 1: + case COMMON_FOUND: in_vain = 0; /* fallthrough */ - default: + case NO_COMMON_FOUND: state = FETCH_SEND_REQUEST; break; } From patchwork Tue Apr 28 00:01:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Tan X-Patchwork-Id: 11513457 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9BF2F81 for ; Tue, 28 Apr 2020 00:01:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80D942087E for ; Tue, 28 Apr 2020 00:01:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="HiV0wEN+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726343AbgD1ABT (ORCPT ); Mon, 27 Apr 2020 20:01:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726307AbgD1ABS (ORCPT ); Mon, 27 Apr 2020 20:01:18 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3A8BC03C1A8 for ; Mon, 27 Apr 2020 17:01:17 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id q43so22453373qtj.11 for ; Mon, 27 Apr 2020 17:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=3u3DweNqVT51+76ePUwJFgPxr2rK4EQok0gtAqBJ13Y=; b=HiV0wEN+QVqwJO3/e24BSBSvIin4AsiUrn4fYkZAOyeSe7HD1Fzr14PpgukM67vraa jy78JWqNgXzTY3+B2Li8+nnBvTKQjaNTs3dAWANVYc5GkzDA614AmCx6sXgtp/qOfzT9 ba1+JEuWYNKXbM1oijU/Km7Fvl6OhCqvPvq/iZkTvWg/qPZiPbnC1Tn1b/BiKwZTX089 iTrt3UZvkeL44MrejAosw2kjxzqi/wsZ6H6EQuooVo3Vklf/55/U0AeiPgEaeY1IS13Z 999vtqi1If6sJYC3XMhpsf8kGahuE3og5s6yP6yIKA4EnHLdO0kM3dOKQFBLvD+YIr15 sB+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=3u3DweNqVT51+76ePUwJFgPxr2rK4EQok0gtAqBJ13Y=; b=W9mNG3cS7qOv/tq40vFRp0fXFFO805zvawUFqFLgjwSoTNcysXveLfBo+xWr3W7R9z aVaxr4ch7z0BlybM/a8S5jfyx+pQjVhaUrsKLRzYkopuUA+OD2yOxQ0W/CuXv3YUwlPY RZsdo3FUEJJ2cU4dOPjsAYacIE+hP2FkrtZBIa1JJKMNKybcLey1xmWQsBnZ7Jlwsst8 TGFsAj2xM2k4AIQPtPYWooPU0DYnQ4nbb6wBqa1gr99kyzE8ZbHGuUvP41jHtYmYYaCi xY4QZTm3iixrwfFpj9pXkAR7lVXuLN4gPG2wOSa0Vva7m8bMMKRfHA7PoW/hVyuFOGP+ //OA== X-Gm-Message-State: AGi0PuZl7OmCO1a5SV3fq9NVXbJhfK4pDNcoOCdu9u4HtJwQuVLKzhrO lC3ozh4VcOnPV0HZmV6/x/Tvq6pfR9j0XuZonMdGIn+3LSGL4JKIr4piRL1TQbwVFe12AcMqbSd oQIKUUi6gDLhahWfnIUshL7kR+V3s0SBVH/eLiCc7K1MrlAGH8IjKVdSV/bXNZWNnDvfFQ3L56T vd X-Google-Smtp-Source: APiQypL/ZsxAt90DYBUFoTSsu+Qf9lIq9KvyoTpbiVmOU2vqV2BExDEqEQqjWRDRejcR+0C4UAUTboLlB/L6Lh3MGSZi X-Received: by 2002:a0c:b286:: with SMTP id r6mr5234992qve.244.1588032076923; Mon, 27 Apr 2020 17:01:16 -0700 (PDT) Date: Mon, 27 Apr 2020 17:01:09 -0700 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.26.2.303.gf8c07b1a785-goog Subject: [PATCH v2 2/3] fetch-pack: in protocol v2, in_vain only after ACK From: Jonathan Tan To: git@vger.kernel.org Cc: Jonathan Tan , gitster@pobox.com, jrnieder@gmail.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When fetching, Git stops negotiation when it has sent at least MAX_IN_VAIN (which is 256) "have" lines without having any of them ACK-ed. But this is supposed to trigger only after the first ACK, as pack-protocol.txt says: However, the 256 limit *only* turns on in the canonical client implementation if we have received at least one "ACK %s continue" during a prior round. This helps to ensure that at least one common ancestor is found before we give up entirely. The code path for protocol v0 observes this, but not protocol v2, resulting in shorter negotiation rounds but significantly larger packfiles. Teach the code path for protocol v2 to check this criterion only after at least one ACK was received. Signed-off-by: Jonathan Tan Reviewed-by: Jonathan Nieder --- fetch-pack.c | 13 +++++++++---- t/t5500-fetch-pack.sh | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/fetch-pack.c b/fetch-pack.c index 45547a621e..76691dc6c0 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -1143,6 +1143,7 @@ static void add_common(struct strbuf *req_buf, struct oidset *common) } static int add_haves(struct fetch_negotiator *negotiator, + int seen_ack, struct strbuf *req_buf, int *haves_to_send, int *in_vain) { @@ -1157,7 +1158,7 @@ static int add_haves(struct fetch_negotiator *negotiator, } *in_vain += haves_added; - if (!haves_added || *in_vain >= MAX_IN_VAIN) { + if (!haves_added || (seen_ack && *in_vain >= MAX_IN_VAIN)) { /* Send Done */ packet_buf_write(req_buf, "done\n"); ret = 1; @@ -1173,7 +1174,7 @@ static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out, struct fetch_pack_args *args, const struct ref *wants, struct oidset *common, int *haves_to_send, int *in_vain, - int sideband_all) + int sideband_all, int seen_ack) { int ret = 0; struct strbuf req_buf = STRBUF_INIT; @@ -1230,7 +1231,8 @@ static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out, add_common(&req_buf, common); /* Add initial haves */ - ret = add_haves(negotiator, &req_buf, haves_to_send, in_vain); + ret = add_haves(negotiator, seen_ack, &req_buf, + haves_to_send, in_vain); } /* Send request */ @@ -1465,6 +1467,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, int haves_to_send = INITIAL_FLUSH; struct fetch_negotiator negotiator_alloc; struct fetch_negotiator *negotiator; + int seen_ack = 0; if (args->no_dependents) { negotiator = NULL; @@ -1521,7 +1524,8 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, if (send_fetch_request(negotiator, fd[1], args, ref, &common, &haves_to_send, &in_vain, - reader.use_sideband)) + reader.use_sideband, + seen_ack)) state = FETCH_GET_PACK; else state = FETCH_PROCESS_ACKS; @@ -1534,6 +1538,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, break; case COMMON_FOUND: in_vain = 0; + seen_ack = 1; /* fallthrough */ case NO_COMMON_FOUND: state = FETCH_SEND_REQUEST; diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index baa1a99f45..961cd6beec 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -385,6 +385,24 @@ test_expect_success 'clone shallow with packed refs' ' test_cmp count8.expected count8.actual ' +test_expect_success 'in_vain not triggered before first ACK' ' + rm -rf myserver myclient trace && + git init myserver && + test_commit -C myserver foo && + git clone "file://$(pwd)/myserver" myclient && + + # MAX_IN_VAIN is 256. Because of batching, the client will send 496 + # (16+32+64+128+256) commits, not 256, before giving up. So create 496 + # irrelevant commits. + test_commit_bulk -C myclient 496 && + + # The new commit that the client wants to fetch. + test_commit -C myserver bar && + + GIT_TRACE_PACKET="$(pwd)/trace" git -C myclient fetch --progress origin && + test_i18ngrep "Total 3 " trace +' + test_expect_success 'fetch in shallow repo unreachable shallow objects' ' ( git clone --bare --branch B --single-branch "file://$(pwd)/." no-reflog && From patchwork Tue Apr 28 00:01:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Tan X-Patchwork-Id: 11513459 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7EDA15AB for ; Tue, 28 Apr 2020 00:01:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C046A208FE for ; Tue, 28 Apr 2020 00:01:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="upCwcmTg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726338AbgD1ABU (ORCPT ); Mon, 27 Apr 2020 20:01:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726307AbgD1ABT (ORCPT ); Mon, 27 Apr 2020 20:01:19 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82C66C0610D5 for ; Mon, 27 Apr 2020 17:01:19 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id w9so20659745qvs.22 for ; Mon, 27 Apr 2020 17:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=jhi7YYxgd+qjn/dE9OhwjUHW2psV52DHLTswLoRyL1Y=; b=upCwcmTgLf3joaCNw5W3Gx2eIK9zy/n+sH8EDZYU2bT3gkaLwJ9F1Ol13li6dZf7ON FpKAvYiOzzM1ix5AjkjB0udYysDC0cfCXbOYWR7K9jxbpJadqgrwCpM9UAVMNay4uPNU V1Bvs/D0jY6o94EMFYUcCeSvZ7nGjGLzJqqSYI9Vx7JtKkl+sEnh0LZaHLzB0Fa/+nxR IaT6TEEBgajGTJIS2axUsMXOXSwpxDBhs8vNMCDnmEfG+S2aoRXUBolI/SLUoX8KSLIh eQdlEpyqH8SpIlQJewN3vROT/AGEtruw2nUl1QH/qxUncg/FPBNp+ScZHBIwa/J8loM0 LL+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=jhi7YYxgd+qjn/dE9OhwjUHW2psV52DHLTswLoRyL1Y=; b=GjxnAptwm2EOwXcQ1cKsIieZoPgfbqOj1vC2hu6h9AiG6R1VBwW0qmXUiiMV6g3bST ylXti3zdhWLhgYe0h48OAIYf++yOiwlFuDkCuMOz12n/xZwmKwD/JglCF5/xO8c9jMw3 e2cBAbIyqmlFcUDePkLBXv0zq57rCqGEFZbqFU2rmpk5a7/2kYkWVdByCeXTbMs0O4zj TlO9cy+I968wJVEygQhNVuRhd+P1jKntLeE6wtueWevFzcXzYe61Sw+3b4RiafYTsxDc GTDmNFHZOGFbM9myklewCYA3dExOHxGU5BuN3jjrSjEFUV5jo2b8DZ/njm9gV7Ej0uLx SF7w== X-Gm-Message-State: AGi0PuZth4FbJsK0zl5LTxb7/uCetBN/rHTLZWF1Mi1mczDPLEblz00T V70CP0RsJyauGXT0q7Zl3MXOugwRXWqx0JkaV368AV+vBdKvcSRnenm0B0wF4DjmLdIH8em1AOy wtNm3yYiptxUC8dOQch9DPz1FM0mg0tNy09pSMPJQPkHJHoUxd9useGTBoa3h7Fb9ax4Xay3HXu Jw X-Google-Smtp-Source: APiQypJ0vKfK6hbNBzec7T7GDImazNmm+4Nwm+DhAXYUYOi1PKa4g9gvHRxPildBMfsTqqJYCPDg9tmPt2j3awtwl4zN X-Received: by 2002:a0c:aa85:: with SMTP id f5mr22436147qvb.51.1588032078580; Mon, 27 Apr 2020 17:01:18 -0700 (PDT) Date: Mon, 27 Apr 2020 17:01:10 -0700 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.26.2.303.gf8c07b1a785-goog Subject: [PATCH v2 3/3] fetch-pack: in protocol v2, reset in_vain upon ACK From: Jonathan Tan To: git@vger.kernel.org Cc: Jonathan Tan , gitster@pobox.com, jrnieder@gmail.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In the function process_acks() in fetch-pack.c, the variable received_ack is meant to track that an ACK was received, but it was never set. This results in negotiation terminating prematurely through the in_vain counter, when the counter should have been reset upon every ACK. Therefore, reset the in_vain counter upon every ACK. Helped-by: Jonathan Nieder Signed-off-by: Jonathan Tan Reviewed-by: Jonathan Nieder --- fetch-pack.c | 1 + t/t5500-fetch-pack.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/fetch-pack.c b/fetch-pack.c index 76691dc6c0..edbfc2af1c 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -1307,6 +1307,7 @@ static enum common_found process_acks(struct fetch_negotiator *negotiator, if (skip_prefix(reader->line, "ACK ", &arg)) { struct object_id oid; + received_ack = 1; if (!get_oid_hex(arg, &oid)) { struct commit *commit; oidset_insert(common, &oid); diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 961cd6beec..52dd1a688c 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -403,6 +403,36 @@ test_expect_success 'in_vain not triggered before first ACK' ' test_i18ngrep "Total 3 " trace ' +test_expect_success 'in_vain resetted upon ACK' ' + rm -rf myserver myclient trace && + git init myserver && + + # Linked list of commits on master. The first is common; the rest are + # not. + test_commit -C myserver first_master_commit && + git clone "file://$(pwd)/myserver" myclient && + test_commit_bulk -C myclient 255 && + + # Another linked list of commits on anotherbranch with no connection to + # master. The first is common; the rest are not. + git -C myserver checkout --orphan anotherbranch && + test_commit -C myserver first_anotherbranch_commit && + git -C myclient fetch origin anotherbranch:refs/heads/anotherbranch && + git -C myclient checkout anotherbranch && + test_commit_bulk -C myclient 255 && + + # The new commit that the client wants to fetch. + git -C myserver checkout master && + test_commit -C myserver to_fetch && + + # The client will send (as "have"s) all 256 commits in anotherbranch + # first. The 256th commit is common between the client and the server, + # and should reset in_vain. This allows negotiation to continue until + # the client reports that first_anotherbranch_commit is common. + GIT_TRACE_PACKET="$(pwd)/trace" git -C myclient fetch --progress origin master && + test_i18ngrep "Total 3 " trace +' + test_expect_success 'fetch in shallow repo unreachable shallow objects' ' ( git clone --bare --branch B --single-branch "file://$(pwd)/." no-reflog &&