From patchwork Wed May 13 18:04:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11546989 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 B5ABC697 for ; Wed, 13 May 2020 18:05:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C5BE2053B for ; Wed, 13 May 2020 18:05:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Opp6LsDK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389995AbgEMSFL (ORCPT ); Wed, 13 May 2020 14:05:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1732488AbgEMSFK (ORCPT ); Wed, 13 May 2020 14:05:10 -0400 Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1755C061A0C for ; Wed, 13 May 2020 11:05:10 -0700 (PDT) Received: by mail-qv1-xf44.google.com with SMTP id r3so191983qve.1 for ; Wed, 13 May 2020 11:05:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hxclQLbBSUal7Gbbwbp5s1iq2t0j8ZwEi3scAMADpQc=; b=Opp6LsDKogoIE6VS7kWNkdgaSYPAPfW3/1ahN5AzvTLlw7wVBL8P/80Vpt3tKXcL8d 0qMLLWGPinvPi7WRJEd2X9H3v4il6oGg3WHTTA5l82xyK2RKXWYaBUDbIrGRvTVaMl84 +tU0uxRwuCU4GkdamQaBSqDdoe/x0qFt0vqz019+gkadAxoVeKjG2KlsfutSOm4zMi5R MtGxV79Qe0Ec3hsHqeQupnAu6DCGtU3lYz/hJXTHopGD1pzRRXB6Lz7xRRACqDS56yjr LouGDt1pFhXnBEQ8PPV8fAK0XI6X5ZYlu8hhXV5i7z83EvIc6JMLfxHfsXnzt440foqP gyHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hxclQLbBSUal7Gbbwbp5s1iq2t0j8ZwEi3scAMADpQc=; b=OEX/Fxu4AviwODlwZBXtamXVlGe6nZWkGyfmzrLHHmL5RuGSTQVfA3QeF0H0VbDknM I2ckP9thNR5BI0g2KwwlqJ0nGyrtynaG6asLBTrCIpCjg9q4b2hxB7YuUf3qaev5eH5R e423BZHK1v4KsOMnShkWRlINtcXe/aRIwNYHa4BCXYW+lx/1HrJG98P8D8rTabP2cOKt yeAJoJNhFqOzW01kEU9xmhhM9a+bZ6VGK4BNFecDLRkwskPccAG2l2+9IhK9XWh+CvyN wjc9xzfuHLpgx2Dulb21wxn3IAl9It5uOo+iuF371sg3O/RLksVz4+NjET4cx0w6lhIO LEyw== X-Gm-Message-State: AOAM533og0t1fXlKEkFdcHoFgMdqgiZ0FnJLP2fzbc2wcjjI7GHCXrg/ WEZBN03oaZYPKEQQOVLq7tbmCMzk X-Google-Smtp-Source: ABdhPJziXB4wkosdy2ivaggRYYayAdQWN9Unws5j/TZU8Xk8Ej3Q47TffrD7iyi1yDxHoIAW4E/yeQ== X-Received: by 2002:a05:6214:4e4:: with SMTP id cl4mr891774qvb.216.1589393109599; Wed, 13 May 2020 11:05:09 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.65.113]) by smtp.gmail.com with ESMTPSA id z60sm301153qtc.30.2020.05.13.11.05.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 11:05:09 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Jeff King Subject: [PATCH 1/6] remote-curl: fix typo Date: Wed, 13 May 2020 14:04:53 -0400 Message-Id: X-Mailer: git-send-email 2.26.2.706.g87896c9627 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Denton Liu --- remote-curl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote-curl.c b/remote-curl.c index 1c9aa3d0ab..6844708f38 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -643,7 +643,7 @@ static size_t rpc_out(void *ptr, size_t eltsize, return 0; } /* - * If avail is non-zerp, the line length for the flush still + * If avail is non-zero, the line length for the flush still * hasn't been fully sent. Proceed with sending the line * length. */ From patchwork Wed May 13 18:04:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11546991 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 5DD0B697 for ; Wed, 13 May 2020 18:05:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 427482065C for ; Wed, 13 May 2020 18:05:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b7+qMHw6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390011AbgEMSFM (ORCPT ); Wed, 13 May 2020 14:05:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1732488AbgEMSFM (ORCPT ); Wed, 13 May 2020 14:05:12 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FEC5C061A0C for ; Wed, 13 May 2020 11:05:11 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id b6so132093qkh.11 for ; Wed, 13 May 2020 11:05:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RFan4SxK9IYM8JwqCj6zEhODFuYsjYeefwOc2HlU8gU=; b=b7+qMHw6lrUMKwaX8oOrCJ5tQzT4X1w1rkgWuv++lNPtiAqYF1tNg9AQgbtN5xApBI hgi8Qr6/F356Fki2cmdLwFB74VNlEIIkmlH/06YfFc709UZ/JfJzBVWSmQY2FeDqBME3 XR6uo1lIMm1u8+9HmbTqHYQ26o9dDQRe9rH9lPGGymCvUKS3+Arr3wwIAiYX87e1VLtq 30sMXIVccCfFf5sNR4fHikxwMCYmmz5VaiSnq+kjU2+6vHcy6EoIYkKgUWAgEUflK+mD 5IWXqma+MHVbw0TBewTYEFh/yh8S0TbcI29DdbpOH6K8ZAclaQSLGT76HAhoidW0tb+k BOMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RFan4SxK9IYM8JwqCj6zEhODFuYsjYeefwOc2HlU8gU=; b=E9wC3IUzzaQvC+bOd+WxoIEMDJFUlyYYMgUzduc9IvoQdCFC5GuWCJqPFrfbOziXUb BGsUijPRWyqYJ+5tFkg0ZT6ZswmctR3hBAVUhwKzRmM4nHKPzsG16DLhF2JbIv8BjPrt fdskME9HV/lOP+6F7SL73NgAHNUsnR5repUtxUSqMvvFstQOA1RtT8yVawKwlO49fNoM 9CKmHnTlsdeMAHM0oS0EDyUiUdp3vNAMEWO32/O8xdXCEAeCAH9SrH4qzUmqXn7AQ1XS vrvQfLmN6RoqD3s3FC1PeNBDgjJr4UhoMPrJQZI1d3ig3DYhCgcUP5UmpDSWUREWVtnj /jlw== X-Gm-Message-State: AOAM531i70rbKhyCXAyhKmwCJmHm0t44D4+bZO3jcaqmG70snn2khmTN TLvr7INSztW7UjLBUxNlh8N3tpuk X-Google-Smtp-Source: ABdhPJwD3DVdBCqW7aHWCj2lnCNoL46x0dk9S4VTkUybRbrdnHcmpfDKKMJrBUIF1g8+F1AqZMsJmA== X-Received: by 2002:a37:bd47:: with SMTP id n68mr911529qkf.379.1589393110522; Wed, 13 May 2020 11:05:10 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.65.113]) by smtp.gmail.com with ESMTPSA id z60sm301153qtc.30.2020.05.13.11.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 11:05:10 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Jeff King Subject: [PATCH 2/6] remote-curl: remove label indentation Date: Wed, 13 May 2020 14:04:54 -0400 Message-Id: X-Mailer: git-send-email 2.26.2.706.g87896c9627 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In the codebase, labels are aligned to the leftmost column. Remove the space-indentation from `free_specs:` to conform to this. Signed-off-by: Denton Liu --- remote-curl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote-curl.c b/remote-curl.c index 6844708f38..da3e07184a 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1276,7 +1276,7 @@ static void parse_push(struct strbuf *buf) if (ret) exit(128); /* error already reported */ - free_specs: +free_specs: argv_array_clear(&specs); } From patchwork Wed May 13 18:04:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11546993 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 9F3D6697 for ; Wed, 13 May 2020 18:05:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F7BD2065C for ; Wed, 13 May 2020 18:05:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="p7DdTy50" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390017AbgEMSFO (ORCPT ); Wed, 13 May 2020 14:05:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1732488AbgEMSFN (ORCPT ); Wed, 13 May 2020 14:05:13 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E559C061A0C for ; Wed, 13 May 2020 11:05:12 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id b6so132164qkh.11 for ; Wed, 13 May 2020 11:05:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y19IbOuhZIRTyyoU2VZixeM0uKga7ZpB7g+fevshc14=; b=p7DdTy50zBynwwGBtH9/zHVy1mQhf/mY8w2wF08Jb19lIClsmA3SJIaVkMjsrGn6pf bKQdClr1nYZwF6Zd9h03XaIEWV5JM1xrXGQU3a3VF9Mvw5HlVH/2OEl6fMpRwF18RqG1 QTUaxSi1d0RhGFBn1YMuiSVTtFxtJmnSFFdibaOuMA48r22dqFyphmNDK/LAYzmkdyMC e2gb5fXezLJ2X570CCCiACykm6Vg9+vetSvwA9TzO0nzAr1CHJbAWYAqxFvOHKWKXX7C cT8ZxCeRhIBoGPy84pDdWiN4rLJh8Fw2S4LtXnTNc6ZJi70FPQl7aRh8la0ow4OCNRyx 7cNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y19IbOuhZIRTyyoU2VZixeM0uKga7ZpB7g+fevshc14=; b=cUwdpziy48vq09pznFAmd1dnnHFNyJShyHvLcHIFZuDV5Sxws8Hr+VwbAmc9QZjN3H J7UKS0+t+Tajznwx8YsV2KiRizNyth84HewphT9Zdhgcpt51QKaOMstwqGDC1RY/qxLI hweSIw17HYulcVxkWcVnwA5hZtQhWvnnfiC6r8KPJ8uf/93wcylVab6ygomifGGDakrS yK/YIPosNobPuKsQSLl9rz01eUv9gXcpAatq3iLK8A/ecuYKpJ8NVC4JecWWfuXChkzF mqExLml1UTq5VYC7eXHNwjSjga7TZbsIXG+ajKku2umvg60JWbGLl/mwTaI2xU2ITGlS /mGg== X-Gm-Message-State: AOAM533jpdNumdN14PGQPYIpuqxwV4NrGLwV/tI2SGIHi/OQWHDAMv0u T7I6Osmc3nL4qlfgqhiduBYU/y86 X-Google-Smtp-Source: ABdhPJzmB16CpbAbhXVhditc23XSudV6/jt6d3EmypNpeJU2IceW61+XsYCrcXlDG+INcYM1CiVifA== X-Received: by 2002:a37:7dc4:: with SMTP id y187mr934271qkc.412.1589393111726; Wed, 13 May 2020 11:05:11 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.65.113]) by smtp.gmail.com with ESMTPSA id z60sm301153qtc.30.2020.05.13.11.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 11:05:11 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Jeff King Subject: [PATCH 3/6] transport: combine common cases with a fallthrough Date: Wed, 13 May 2020 14:04:55 -0400 Message-Id: X-Mailer: git-send-email 2.26.2.706.g87896c9627 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In the switch statement, the difference between the `protocol_v2` and `protocol_v{1,0}` arms is a prepatory call to die_if_server_options() in the latter. The fetch_pack() call is identical in both arms. However, since this fetch_pack() call has so many parameters, it is not immediately obvious that the call is identical in both cases. Rewrite the switch statement to fallthrough from the v{1,0} case to v2 so that they share a common fetch_pack() call. This reduces duplication and makes the logic more clear for future readers. Signed-off-by: Denton Liu --- transport.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/transport.c b/transport.c index 15f5ba4e8f..475f94564a 100644 --- a/transport.c +++ b/transport.c @@ -370,15 +370,11 @@ static int fetch_refs_via_pack(struct transport *transport, } switch (data->version) { - case protocol_v2: - refs = fetch_pack(&args, data->fd, - refs_tmp ? refs_tmp : transport->remote_refs, - to_fetch, nr_heads, &data->shallow, - &transport->pack_lockfile, data->version); - break; - case protocol_v1: case protocol_v0: + case protocol_v1: die_if_server_options(transport); + /* fallthrough */ + case protocol_v2: refs = fetch_pack(&args, data->fd, refs_tmp ? refs_tmp : transport->remote_refs, to_fetch, nr_heads, &data->shallow, From patchwork Wed May 13 18:04:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11546995 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 CA1C214BF for ; Wed, 13 May 2020 18:05:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B9A2320659 for ; Wed, 13 May 2020 18:05:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RAB8CjF1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390020AbgEMSFQ (ORCPT ); Wed, 13 May 2020 14:05:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1732488AbgEMSFP (ORCPT ); Wed, 13 May 2020 14:05:15 -0400 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32DE2C061A0C for ; Wed, 13 May 2020 11:05:15 -0700 (PDT) Received: by mail-qv1-xf42.google.com with SMTP id 59so324353qva.13 for ; Wed, 13 May 2020 11:05:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZYo/5DpGKwvgnCq4IIcE5/0TPlCiDxKXWx5hvmTizTA=; b=RAB8CjF1Yk62j/okyJGZhBxxEM5juQbMZwljp+zF49zfkDdkyO/m3hkrweksWSNxDp /k40gnnpoMARNpWL4FZffv08L+fv6FRbglPBxneDj1pgtM9NujzW0BUEzsA33PzUC/6e 4GAntqpDn6AEmRDuPERnatGd2B/vSSILTozM8B85tpoBHcbWzELRsAAldE80ejFbAi6v iqtBDApJPloOTl8+dhjUocZSRp4wsvobJY4ica32QqNZRx5vsuf3YCttTFc8+rE3CJnD AS+A4uhm4nylDiZsNwKG6HSsJ8aq6hoicpUBoKXHTzF+Y4ROrB8773Y02kT5ebzB5nKt og1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZYo/5DpGKwvgnCq4IIcE5/0TPlCiDxKXWx5hvmTizTA=; b=ueXeXqDqEP+uKSLZMvW8D9JsYRrtr4iVhTF/3yoFMuGnkTdyB5SDUqSFgGDg2tJ+r/ UZXBDp2kpee97TGtw5piTAs9rT3YWqtQmp7aTEondS57dAXEDoVGaPOvCp/3ItKVKDww 6T3ErQ9QwRKJC5vJEGQJC7DObxewsYPJ7TO46H4wvOmCwPgHpVLYso9wQ1fMuYFKLH1W RQpXZTG5REtUfIVgzz2otBA7J14XH4vlupuw/dO6zdK6nT2Q9bw5Xksg4ISwyCo/HPVL VjO0u9EfKxvcq+z6J7PHxuhumYZhqDFUKPP7nl9K1ecaXUVk+FbCvDYyXsuovLb/5Yh7 KiGg== X-Gm-Message-State: AOAM5324SHwSLGozEsKTmI59sZHG/5A+fR+GKHgogAMyGG9ufUGDau4Y WNwqHNU+jVl3MK6sEJiVSWU+4hHj X-Google-Smtp-Source: ABdhPJxY8vLmzlUFOU48u33cQgk3pnZRG+WhsB48zTaVW0GRJN8bcJNDWGtUwP7H04jYzMfgbqeCfw== X-Received: by 2002:a05:6214:cf:: with SMTP id f15mr834598qvs.59.1589393113409; Wed, 13 May 2020 11:05:13 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.65.113]) by smtp.gmail.com with ESMTPSA id z60sm301153qtc.30.2020.05.13.11.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 11:05:12 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Jeff King Subject: [PATCH 4/6] pkt-line: extern packet_length() Date: Wed, 13 May 2020 14:04:56 -0400 Message-Id: <891a39c853ce3669b6167dc9ad8a2328e4321a9e.1589393036.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.26.2.706.g87896c9627 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In a future commit, we will be manually processing packets and we will need to access the length header. In order to simplify this, extern packet_length() so that the logic can be reused. Signed-off-by: Denton Liu --- pkt-line.c | 2 +- pkt-line.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkt-line.c b/pkt-line.c index a0e87b1e81..6b60886770 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -306,7 +306,7 @@ static int get_packet_data(int fd, char **src_buf, size_t *src_size, return ret; } -static int packet_length(const char *linelen) +int packet_length(const char *linelen) { int val = hex2chr(linelen); return (val < 0) ? val : (val << 8) | hex2chr(linelen + 2); diff --git a/pkt-line.h b/pkt-line.h index fef3a0d792..f443185f8f 100644 --- a/pkt-line.h +++ b/pkt-line.h @@ -74,6 +74,11 @@ int write_packetized_from_buf(const char *src_in, size_t len, int fd_out); int packet_read(int fd, char **src_buffer, size_t *src_len, char *buffer, unsigned size, int options); +/* + * Reads a packetized line and returns the length header of the packet. + */ +int packet_length(const char *linelen); + /* * Read a packetized line into a buffer like the 'packet_read()' function but * returns an 'enum packet_read_status' which indicates the status of the read. From patchwork Wed May 13 18:04:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11546997 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 533EE697 for ; Wed, 13 May 2020 18:05:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4220620659 for ; Wed, 13 May 2020 18:05:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SkcUaKD1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390027AbgEMSFR (ORCPT ); Wed, 13 May 2020 14:05:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1732488AbgEMSFR (ORCPT ); Wed, 13 May 2020 14:05:17 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0435EC061A0C for ; Wed, 13 May 2020 11:05:17 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id a136so170733qkg.6 for ; Wed, 13 May 2020 11:05:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T3RQyxwzk5eD5Tov/2/bHuda9GtTYa6j6s5ayYwMMTI=; b=SkcUaKD1QpHw16kT9rxFaay2g4awwogg+smjQUl3TWry/JInOcK+lAvjAx/3rFtSab Y9lC4v4qhkMIActRtivJN4BOUMyD1ZutPuP5JNL3HLxzvzxI8LCUA4k1cmTFjfKgVh1X s/NmtXZR/hkOyEJIu4+MYiKddlYYZWtJcmJWzFPUTox/jnXPOS6RJZrhULd0U1hxSs7Y yxTWCC1NuG5a4ne0+VK0LmvULoVqFWt0/r2eIp2hAO8mCF1HF8Ts4a9qNorMMrImmmrL Q+t2EVbYKcc6z9MBDPDcjaAbCp5cr1qJgVuoaUvMYQ3PVRm8aS/2lt/D5qfCW+SQ2oQf sNFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T3RQyxwzk5eD5Tov/2/bHuda9GtTYa6j6s5ayYwMMTI=; b=SiMfPtxG8hz3E8Zcg/klhQaOilMCJLTcByuDDWJqG00OohYo+2oFV3XkGeS3C+Iqt9 UDmB/vwS2cwdyL37d/nnFwZBMwA3ALK1I9Raaidhal2RDvJ6hPwAPFDQGAH+eOzf6+hJ aDzZunC3tiXYr4FK74KWTtpkcqXS5YOvpOlUkgWQqHS7zIUGByopj4vLjXHvLYO4wNuu jdIJFhD+r0NO9sv5rccbi2TB8+5/enDxCtP5Dh9qirIH+zYG9GPSB85d1kjSWD3er3o5 WpfDKH7+DDZmqgIGXW4vyzcVqiHKvZprgKrehSapjECj6dMSbvx19FfKZtaR00VQEQoM VAWA== X-Gm-Message-State: AOAM533EUN+RA8sHGVdvOzTMkGYMv4uL8vrA0l4JRnNigWxwemDku/J7 ru/5aRDdfGa1n5mm8z6xWG/u1L4p X-Google-Smtp-Source: ABdhPJx0yZnuMps8QyGu0igDaqGLGlIXUw8Rkh+4128HbImWZUqu0AZMZJX+VXECti0ROqYvGZMsKA== X-Received: by 2002:a37:6e42:: with SMTP id j63mr868458qkc.495.1589393115892; Wed, 13 May 2020 11:05:15 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.65.113]) by smtp.gmail.com with ESMTPSA id z60sm301153qtc.30.2020.05.13.11.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 11:05:14 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Jeff King Subject: [PATCH 5/6] remote-curl: error on incomplete packet Date: Wed, 13 May 2020 14:04:57 -0400 Message-Id: <3ed7cf87aaa40ee66b20aa929d89d28fefcec312.1589393036.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.26.2.706.g87896c9627 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Currently, remote-curl acts as a proxy and blindly forwards packets between an HTTP server and fetch-pack. In the case of a stateless RPC connection where the connection is terminated with a partially written packet, remote-curl will blindly send the partially written packet before waiting on more input from fetch-pack. Meanwhile, fetch-pack will read the partial packet and continue reading, expecting more input. This results in a deadlock between the two processes. Instead of blindly forwarding packets, inspect each packet to ensure that it is a full packet, erroring out if a partial packet is sent. Helped-by: Jeff King Signed-off-by: Denton Liu --- Notes: Unfortunately, I'm not really sure how to test this. remote-curl.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/remote-curl.c b/remote-curl.c index da3e07184a..8b740354e5 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -682,6 +682,8 @@ static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp) struct rpc_in_data { struct rpc_state *rpc; struct active_request_slot *slot; + struct strbuf len_buf; + int remaining; }; /* @@ -692,6 +694,7 @@ static size_t rpc_in(char *ptr, size_t eltsize, size_t nmemb, void *buffer_) { size_t size = eltsize * nmemb; + size_t unwritten = size; struct rpc_in_data *data = buffer_; long response_code; @@ -702,7 +705,42 @@ static size_t rpc_in(char *ptr, size_t eltsize, return size; if (size) data->rpc->any_written = 1; - write_or_die(data->rpc->in, ptr, size); + + while (unwritten) { + if (!data->remaining) { + int digits_remaining = 4 - data->len_buf.len; + if (digits_remaining > unwritten) + digits_remaining = unwritten; + strbuf_add(&data->len_buf, ptr, digits_remaining); + ptr += digits_remaining; + unwritten -= digits_remaining; + + if (data->len_buf.len == 4) { + data->remaining = packet_length(data->len_buf.buf); + if (data->remaining < 0) { + die(_("remote-curl: bad line length character: %.4s"), data->len_buf.buf); + } else if (data->remaining <= 1) { + data->remaining = 0; + } else if (data->remaining < 4) { + die(_("remote-curl: bad line length %d"), data->remaining); + } else { + data->remaining -= 4; + } + write_or_die(data->rpc->in, data->len_buf.buf, 4); + strbuf_reset(&data->len_buf); + } + } + + if (data->remaining) { + int remaining = data->remaining; + if (remaining > unwritten) + remaining = unwritten; + write_or_die(data->rpc->in, ptr, remaining); + ptr += remaining; + unwritten -= remaining; + data->remaining -= remaining; + } + } return size; } @@ -920,6 +958,8 @@ static int post_rpc(struct rpc_state *rpc, int flush_received) curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, rpc_in); rpc_in_data.rpc = rpc; rpc_in_data.slot = slot; + strbuf_init(&rpc_in_data.len_buf, 4); + rpc_in_data.remaining = 0; curl_easy_setopt(slot->curl, CURLOPT_FILE, &rpc_in_data); curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0); @@ -936,6 +976,9 @@ static int post_rpc(struct rpc_state *rpc, int flush_received) if (!rpc->any_written) err = -1; + if (rpc_in_data.remaining) + err = error(_("%d bytes are still expected"), rpc_in_data.remaining); + curl_slist_free_all(headers); free(gzip_body); return err; From patchwork Wed May 13 18:04:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11546999 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 1DFC6697 for ; Wed, 13 May 2020 18:05:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EBED2065C for ; Wed, 13 May 2020 18:05:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b/BRjWOy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390037AbgEMSFT (ORCPT ); Wed, 13 May 2020 14:05:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1732488AbgEMSFS (ORCPT ); Wed, 13 May 2020 14:05:18 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EB00C061A0C for ; Wed, 13 May 2020 11:05:18 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id a136so170836qkg.6 for ; Wed, 13 May 2020 11:05:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Sv+JB8nSV1OKpS92HJl6Z+1itiAJ4oONZNBTcd1fzXk=; b=b/BRjWOyFXccIHcd2Az1JKCUHPjB7rZ0BmZYLfuIO5XULNgRD8kGyKwmWV1lDrTTh/ 52aQbWvyFNxwGufB6ym9tWa8uIWRXSUXc7PykiA/Y8TJptjG6HDdafvyv6LwY8atnhoo R1qUh0aIa5m3Bz0/IInib/kh6+/wnzvaGzF5W4UomLO9tC76ojckZDGNsN07Ikh2ibys xkNPRTpXzoi0kPRjThj+VSbKIpT8mH+3o4mjD7PHVqxD1zgO57xYTDYWbftsIPWzF7fe SvBlgDv+9T43vvxP7ZW4rCseP4Q0rMoq/Yh7p1Wh68REPHmYy3+rt3Y1nZCgmH8CZKyA bEjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Sv+JB8nSV1OKpS92HJl6Z+1itiAJ4oONZNBTcd1fzXk=; b=ArBGtB2HNMdpOStWvka+AqIx7XZLwhUzousgCnQ02rEICv8HbBUcd5GG7+vIFI11xl gjIqXn2OT8snDO6BCasiqLqrZoI/iNQxgqyW7c12I5Akh+vX6vp0rKe456O+inCOVA57 D8DGamPNmcysJbuBerfHXVpjeDWuHak3szNI9UC3BQqMvCNcwM4fGrWfLv7asz06gTaI PSJDbQA591PWn96eFBB+GylwQZZ+BYnUHTqcXlp+hM0UgfxheBU9R6auWFU59g3dQpJi Y3n79yFIzRA2ZPSolhNfqeNmleI2Gtad6qneDzkZqMvUhw48Qr1uMgo6jsr4J5hx1qYw HyvQ== X-Gm-Message-State: AOAM531TYDEr1cINz+x4XJ0EMm0kf54xAxL9iqMWbUlseOZY9hByMG1v yBN4/nTgGuZhEMLBIB9V8zrHZx3X X-Google-Smtp-Source: ABdhPJxD4b1Yu9sCyrRSckEIqL/Y/TK/K5m8Ij4YE1HPwS4bX8DFH2Ll+UTzrvXRMT7sWZ8G4rDHBA== X-Received: by 2002:a37:bc7:: with SMTP id 190mr948104qkl.286.1589393117596; Wed, 13 May 2020 11:05:17 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.65.113]) by smtp.gmail.com with ESMTPSA id z60sm301153qtc.30.2020.05.13.11.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 11:05:17 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Jeff King , Force Charlie Subject: [PATCH 6/6] remote-curl: ensure last packet is a flush Date: Wed, 13 May 2020 14:04:58 -0400 Message-Id: <7a689da2bb820f70d9e668d656b088af2297d456.1589393036.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.26.2.706.g87896c9627 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Currently, remote-curl acts as a proxy and blindly forwards packets between an HTTP server and fetch-pack. In the case of a stateless RPC connection where the connection is terminated before the transaction is complete, remote-curl will blindly forward the packets before waiting on more input from fetch-pack. Meanwhile, fetch-pack will read the transaction and continue reading, expecting more input to continue the transaction. This results in a deadlock between the two processes. This can be seen in the following command which does not terminate: $ git -c protocol.version=2 clone https://github.com/git/git.git --shallow-since=20151012 Cloning into 'git'... whereas the v1 version does terminate as expected: $ git -c protocol.version=1 clone https://github.com/git/git.git --shallow-since=20151012 Cloning into 'git'... fatal: the remote end hung up unexpectedly Instead of blindly forwarding packets, raise a flag when a flush packet is encountered. Ensure that the last packet sent is a flush packet otherwise error out, breaking the deadlock. This is not a complete solution to the problem, however. It is possible that a flush packet could be sent in the middle of a message and the connection could die immediately after. Then, remote-curl would not error out and fetch-pack would still be in the middle of a transaction and they would enter deadlock. A complete solution would involve reframing the stateless-connect protocol, possibly by introducing another control packet ("0002"?) as a stateless request separator packet which is always sent at the end of post_rpc(). Although this is not a complete solution, it is better than nothing and it resolves the reported issue for now. Reported-by: Force Charlie Helped-by: Jeff King Signed-off-by: Denton Liu --- Notes: I wish there were some way to insert a timeout on the test case so that we don't block forever in case we regress. remote-curl.c | 9 +++++++++ t/t5702-protocol-v2.sh | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/remote-curl.c b/remote-curl.c index 8b740354e5..aab17851be 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -684,6 +684,7 @@ struct rpc_in_data { struct active_request_slot *slot; struct strbuf len_buf; int remaining; + int last_flush; }; /* @@ -707,6 +708,8 @@ static size_t rpc_in(char *ptr, size_t eltsize, data->rpc->any_written = 1; while (unwritten) { + data->last_flush = 0; + if (!data->remaining) { int digits_remaining = 4 - data->len_buf.len; if (digits_remaining > unwritten) @@ -720,6 +723,8 @@ static size_t rpc_in(char *ptr, size_t eltsize, if (data->remaining < 0) { die(_("remote-curl: bad line length character: %.4s"), data->len_buf.buf); } else if (data->remaining <= 1) { + if (!data->remaining) + data->last_flush = 1; data->remaining = 0; } else if (data->remaining < 4) { die(_("remote-curl: bad line length %d"), data->remaining); @@ -960,6 +965,7 @@ static int post_rpc(struct rpc_state *rpc, int flush_received) rpc_in_data.slot = slot; strbuf_init(&rpc_in_data.len_buf, 4); rpc_in_data.remaining = 0; + rpc_in_data.last_flush = 0; curl_easy_setopt(slot->curl, CURLOPT_FILE, &rpc_in_data); curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0); @@ -979,6 +985,9 @@ static int post_rpc(struct rpc_state *rpc, int flush_received) if (rpc_in_data.remaining) err = error(_("%d bytes are still expected"), rpc_in_data.remaining); + if (!rpc_in_data.last_flush) + err = error(_("last packet was not a flush")); + curl_slist_free_all(headers); free(gzip_body); return err; diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index 5039e66dc4..4570d0746c 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -586,6 +586,23 @@ test_expect_success 'clone with http:// using protocol v2' ' ! grep "Send header: Transfer-Encoding: chunked" log ' +test_expect_success 'clone with http:// using protocol v2 and invalid parameters' ' + test_when_finished "rm -f log" && + + test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" \ + git -c protocol.version=2 \ + clone --shallow-since=20151012 "$HTTPD_URL/smart/http_parent" http_child_invalid 2>err && + + # Client requested to use protocol v2 + grep "Git-Protocol: version=2" log && + # Server responded using protocol v2 + grep "git< version 2" log && + # Verify that we errored out in the expected way + test_i18ngrep "last packet was not a flush" err && + # Verify that the chunked encoding sending codepath is NOT exercised + ! grep "Send header: Transfer-Encoding: chunked" log +' + test_expect_success 'clone big repository with http:// using protocol v2' ' test_when_finished "rm -f log" &&