From patchwork Thu Jun 4 17:54:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11588191 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 E4E99618 for ; Thu, 4 Jun 2020 17:55:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C800A20738 for ; Thu, 4 Jun 2020 17:55:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="glo/4SQl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730283AbgFDRzL (ORCPT ); Thu, 4 Jun 2020 13:55:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730124AbgFDRzK (ORCPT ); Thu, 4 Jun 2020 13:55:10 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23023C08C5C0 for ; Thu, 4 Jun 2020 10:55:10 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id l10so7083373wrr.10 for ; Thu, 04 Jun 2020 10:55: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=bkci+K7jA9f4jV84RMhgAxIpDQch1t3DWTwGW4wAQ8s=; b=glo/4SQla2ZimQ1p/H5tL+9HaWiiD8DGDZ6n369DFq49QIKo+a5IGSRztMRFP7v5II nsi1t2chBqIzzGHB6oE8K57rVTToTYycKZDtXUXb4c8qW38W+pLESrxHtiZrHjUFaNnV YKuXgm2JNMdOitaQKBld3ABmsQJjwxL2gQppBUnvtTx/DGkF3jvBDdgWQHwK2RMAtjoL E4DeXBSu+rbMeuLA87ftVaeM+VGzK4ahIDEY+jSLamTCT0b1s/7GCE7+02OfvsFiOmuD 99M0DAyFR4aoaivRETl6SjgYiJt/mbBgi0V0dkbMgRX1XaRYeoLTJTZvtCw2GzBRyYvr bPOQ== 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=bkci+K7jA9f4jV84RMhgAxIpDQch1t3DWTwGW4wAQ8s=; b=BjBqfRo1i/z+lU4+KcSP+BWU1xpPs61zr3ZScJOaz0R1j6IICPJCqhfQTAYH4/4tWp TyZ5wPsacHVRT0pXKsB52iSEGXuJmRGzB5R826OHo70nziZuXtUkcm3ddwmEURXoo/5n EAWMcy0xH0/MBJRg7qqk31U/k4UjAKboQAsAyWAz4RItHCSWaFi/aErcWD18SZ73vgOY nDDYhY9HHf6sXURYN0jjIS+3c8gaEb3ptjxfXYSPT5urU6cIXyf569HE70Kr8Fbf1TfV dIMD9pFf3VwCCkrsmhsk2qDt/hcMUurmYr8LdIzRihRyO6S0Buc7tONBv+353hehW/Zv 33Nw== X-Gm-Message-State: AOAM532Ti28OlpV6a/fMEzCErkQ2az1o5T8KBdC4EcF+0914R6CMXhCC yhjvEPRycle6evQ/yWO7br4vUsaDvyA= X-Google-Smtp-Source: ABdhPJyJSKXGblIPg9sdX04LOR7Q12O90huJlYiOhiSaz4IyfAMxdxcLqLyltoTxi15ach1mc8iMkQ== X-Received: by 2002:adf:9ccf:: with SMTP id h15mr5606610wre.275.1591293308314; Thu, 04 Jun 2020 10:55:08 -0700 (PDT) Received: from localhost.localdomain ([185.228.231.251]) by smtp.gmail.com with ESMTPSA id s7sm9173540wrr.60.2020.06.04.10.55.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 10:55:07 -0700 (PDT) From: Christian Couder X-Google-Original-From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Jeff King , Taylor Blau , Jonathan Tan , Jonathan Nieder , Christian Couder Subject: [PATCH v3 01/13] upload-pack: actually use some upload_pack_data bitfields Date: Thu, 4 Jun 2020 19:54:38 +0200 Message-Id: <20200604175450.17385-2-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc0.26.gf2851482f5 In-Reply-To: <20200604175450.17385-1-chriscool@tuxfamily.org> References: <20200602041657.7132-1-chriscool@tuxfamily.org> <20200604175450.17385-1-chriscool@tuxfamily.org> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff King As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's actually start using some bitfields of that struct. These bitfields were introduced in 3145ea957d ("upload-pack: introduce fetch server command", 2018-03-15), but were never used. We could instead have just removed the following bitfields from the struct: unsigned use_thin_pack : 1; unsigned use_ofs_delta : 1; unsigned no_progress : 1; unsigned use_include_tag : 1; but using them makes it possible to remove a number of static variables with the same name and purpose from 'upload-pack.c'. This is a behavior change, as we accidentally used to let values in those bitfields propagate from one v2 "fetch" command to another for ssh/git/file connections (but not for http). That's fixing a bug, but one nobody is likely to see, because it would imply the client sending different capabilities for each request. Helped-by: Jonathan Tan Signed-off-by: Jeff King Signed-off-by: Christian Couder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- upload-pack.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 401c9e6c4b..2fa645834a 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -46,8 +46,7 @@ static timestamp_t oldest_have; static int multi_ack; static int no_done; -static int use_thin_pack, use_ofs_delta, use_include_tag; -static int no_progress, daemon_mode; +static int daemon_mode; /* Allow specifying sha1 if it is a ref tip. */ #define ALLOW_TIP_SHA1 01 /* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */ @@ -186,17 +185,17 @@ static void create_pack_file(struct upload_pack_data *pack_data) } argv_array_push(&pack_objects.args, "pack-objects"); argv_array_push(&pack_objects.args, "--revs"); - if (use_thin_pack) + if (pack_data->use_thin_pack) argv_array_push(&pack_objects.args, "--thin"); argv_array_push(&pack_objects.args, "--stdout"); if (shallow_nr) argv_array_push(&pack_objects.args, "--shallow"); - if (!no_progress) + if (!pack_data->no_progress) argv_array_push(&pack_objects.args, "--progress"); - if (use_ofs_delta) + if (pack_data->use_ofs_delta) argv_array_push(&pack_objects.args, "--delta-base-offset"); - if (use_include_tag) + if (pack_data->use_include_tag) argv_array_push(&pack_objects.args, "--include-tag"); if (pack_data->filter_options.choice) { const char *spec = @@ -955,17 +954,17 @@ static void receive_needs(struct upload_pack_data *data, if (parse_feature_request(features, "no-done")) no_done = 1; if (parse_feature_request(features, "thin-pack")) - use_thin_pack = 1; + data->use_thin_pack = 1; if (parse_feature_request(features, "ofs-delta")) - use_ofs_delta = 1; + data->use_ofs_delta = 1; if (parse_feature_request(features, "side-band-64k")) use_sideband = LARGE_PACKET_MAX; else if (parse_feature_request(features, "side-band")) use_sideband = DEFAULT_PACKET_MAX; if (parse_feature_request(features, "no-progress")) - no_progress = 1; + data->no_progress = 1; if (parse_feature_request(features, "include-tag")) - use_include_tag = 1; + data->use_include_tag = 1; if (allow_filter && parse_feature_request(features, "filter")) filter_capability_requested = 1; @@ -997,7 +996,7 @@ static void receive_needs(struct upload_pack_data *data, check_non_tip(data); if (!use_sideband && daemon_mode) - no_progress = 1; + data->no_progress = 1; if (data->depth == 0 && !data->deepen_rev_list && data->shallows.nr == 0) return; @@ -1279,19 +1278,19 @@ static void process_args(struct packet_reader *request, /* process args like thin-pack */ if (!strcmp(arg, "thin-pack")) { - use_thin_pack = 1; + data->use_thin_pack = 1; continue; } if (!strcmp(arg, "ofs-delta")) { - use_ofs_delta = 1; + data->use_ofs_delta = 1; continue; } if (!strcmp(arg, "no-progress")) { - no_progress = 1; + data->no_progress = 1; continue; } if (!strcmp(arg, "include-tag")) { - use_include_tag = 1; + data->use_include_tag = 1; continue; } if (!strcmp(arg, "done")) { From patchwork Thu Jun 4 17:54:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11588193 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 6DA65618 for ; Thu, 4 Jun 2020 17:55:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4FCED20738 for ; Thu, 4 Jun 2020 17:55:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VG1j5ayn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730300AbgFDRzM (ORCPT ); Thu, 4 Jun 2020 13:55:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730266AbgFDRzL (ORCPT ); Thu, 4 Jun 2020 13:55:11 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32717C08C5C0 for ; Thu, 4 Jun 2020 10:55:11 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id r7so7126906wro.1 for ; Thu, 04 Jun 2020 10:55: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=kycjsm7wcEbpE1FvhW/RgUzGigDdtwWb6EJqkf+GbGg=; b=VG1j5aynsn9/Tms1zget6cXlAParc1HdBRs22iriywa75v615hILWTWnp5p5FgkN1R zaIYhIQAbtxiZlA9+mQHCr89wSWG9R3tCeSdVQ2Mk/ws1Vyu2VqH5Xcb3gBuBw/udYrv BbASB27A2aXS3t+t0Ge9bhMmbSmjnkoHJJo4WYLFKEVWgegBYKdEdUU/ckoqW2v8nqfu WaE7c8VsPC2I95Gku5kTkzobT75DBEwBZz2cuwPbnMOV/isJVKK2QzjRAAITUH+AhzKE q/XV0ApF+vk/NGmIPH/BFX/wfgU4mmhEhts1DLGzr2yCPrZFUlVkEc3eAGDatWI47YOn 2qXQ== 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=kycjsm7wcEbpE1FvhW/RgUzGigDdtwWb6EJqkf+GbGg=; b=Nx3f5d+w2IAaJr9dryyxiugjojjzTr4QA303hnGTLyuMaLVT2KJslsGwUTK/y2N/hD byowdDEjlAAxRBIXF9fTMYvgSEu9SvMOk27hsrUhSzy0ey9M774879gYLD0T/sUciwhq KiwcEB4xs3JeFNglPF9zLA1S556XpqhzNMwdnw33L4Xj/cwTUqCzXDN/rc4UDt9nbDWN lijAeElZadQ9ETpSVR0SBREYk3hc+NXuEG5J+KTMF4ApyZ7zba83r9s1pcQN4/5IZTtu rAoVpzNw71XaouB0rVYusDrrdskhPZp7hyRqs7fYU0kYR+jpnOxSrKmoZ4PrmhK7G8qh J5Xg== X-Gm-Message-State: AOAM53333+Ft3uatb+0p3eQM62jkN7q3DfOparK+evBuuZ5n9c3IF8sl OdsKEoLWipQ+Gbdf9x90QFLEEVdGZvU= X-Google-Smtp-Source: ABdhPJyxE8WZEtwxFdC44JbWw40rRGvFa7RFCl+6UAH8YCszQeWlcTXXdcqIM/N/tvHr7VAkvluntA== X-Received: by 2002:adf:f6ce:: with SMTP id y14mr5821885wrp.90.1591293309633; Thu, 04 Jun 2020 10:55:09 -0700 (PDT) Received: from localhost.localdomain ([185.228.231.251]) by smtp.gmail.com with ESMTPSA id s7sm9173540wrr.60.2020.06.04.10.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 10:55:08 -0700 (PDT) From: Christian Couder X-Google-Original-From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Jeff King , Taylor Blau , Jonathan Tan , Jonathan Nieder , Christian Couder , Christian Couder Subject: [PATCH v3 02/13] upload-pack: annotate upload_pack_data fields Date: Thu, 4 Jun 2020 19:54:39 +0200 Message-Id: <20200604175450.17385-3-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc0.26.gf2851482f5 In-Reply-To: <20200604175450.17385-1-chriscool@tuxfamily.org> References: <20200602041657.7132-1-chriscool@tuxfamily.org> <20200604175450.17385-1-chriscool@tuxfamily.org> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Christian Couder As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's annotate fields from this struct to let people know which ones are used only for protocol v0 and which ones only for protocol v2. Signed-off-by: Christian Couder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- upload-pack.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 2fa645834a..3963a3805e 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -70,12 +70,16 @@ static int allow_ref_in_want; static int allow_sideband_all; +/* + * Please annotate, and if possible group together, fields used only + * for protocol v0 or only for protocol v2. + */ struct upload_pack_data { - struct string_list symref; - struct string_list wanted_refs; + struct string_list symref; /* v0 only */ struct object_array want_obj; struct object_array have_obj; - struct oid_array haves; + struct oid_array haves; /* v2 only */ + struct string_list wanted_refs; /* v2 only */ struct object_array shallows; struct string_list deepen_not; @@ -88,13 +92,14 @@ struct upload_pack_data { struct packet_writer writer; - unsigned stateless_rpc : 1; + unsigned stateless_rpc : 1; /* v0 only */ unsigned use_thin_pack : 1; unsigned use_ofs_delta : 1; unsigned no_progress : 1; unsigned use_include_tag : 1; - unsigned done : 1; + + unsigned done : 1; /* v2 only */ }; static void upload_pack_data_init(struct upload_pack_data *data) From patchwork Thu Jun 4 17:54:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11588197 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 8ED6A90 for ; Thu, 4 Jun 2020 17:55:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 74D9920738 for ; Thu, 4 Jun 2020 17:55:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rUoicTgI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730305AbgFDRzO (ORCPT ); Thu, 4 Jun 2020 13:55:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730266AbgFDRzN (ORCPT ); Thu, 4 Jun 2020 13:55:13 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 884FFC08C5C0 for ; Thu, 4 Jun 2020 10:55:12 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id d128so6593689wmc.1 for ; Thu, 04 Jun 2020 10:55: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=pAv3Jnk1H9O8wqaecmYqxuSvlHKGjw/8razwMYcSkEM=; b=rUoicTgIHBuG1O2Glp1E8FzG6lCry5XMJ2jptQehGc650Z20WFKxwpjCURSORpDv5Q jHRJalcVcC52MPqxNHgfqHAbztMCGkeNkbo5ddIBsIGg0MhZE4gSZMkblRF/oRL/YOqm z3np2SqDdfdF6T1Ohi7y03WSKZn+nH4IV3TWPkaE6Y5f3CKm86vjGcRwr83m4cAgd5Tb yBcQ3CP/EK4kQy67m89GHSG3qwiVhQKDaT4LWXQ5CpuO8Pkef5TO9xZMGTQrA1/T8kV9 2QdqzxegClfsswkDJj2vYGu1OIP7TIEwf1DXLWs6ZhiHS/QK7XwY3rZScrMOxMGhE+3d o2xQ== 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=pAv3Jnk1H9O8wqaecmYqxuSvlHKGjw/8razwMYcSkEM=; b=IV6SDme+Jaujm/FZVIm9pNwsS62vvxxx0BNXrVe5P18XkJnElUxggs8Uybroa+MFhL oPY6dv+rgTv2pk9sdu2xa0eJYf8STkJpHBs1sc0I4OGvZLihqi6Rk8OulBJ/QCjBC3tZ WHAvqEOF1UdlAQvzT2IxRRLPgpi2y3Paa85VkE1KoSq4HFFrCDccOlHDnls07gQjx82F 2JFNiBKD29dxacDmaaZ7xakuyZcwTBEy427m/RSD7TlxcowSuC7n79NPp9y4CA5e+Tfw fVjY4ksf7fwDxjc5F81Pb+tuuvJOLh624sNPkmE/FRrv9gTDV+mYTmJhs8rJzpHATKZ4 19jQ== X-Gm-Message-State: AOAM532qTATmm6zBt9DPZy6OKbTaRNjH6hSq10bLm2fkhJ6db4LPd0ik AcHvMspFKf8DoAbZpI4Acwa/HlN0FP0= X-Google-Smtp-Source: ABdhPJwIWjHjscpI32aEZRk4aZhrZmo0OJIHhXgxECpqxc3veqdecdugO18TscvHVwAVC4rBJpWpUQ== X-Received: by 2002:a1c:59c7:: with SMTP id n190mr4852556wmb.61.1591293310896; Thu, 04 Jun 2020 10:55:10 -0700 (PDT) Received: from localhost.localdomain ([185.228.231.251]) by smtp.gmail.com with ESMTPSA id s7sm9173540wrr.60.2020.06.04.10.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 10:55:10 -0700 (PDT) From: Christian Couder X-Google-Original-From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Jeff King , Taylor Blau , Jonathan Tan , Jonathan Nieder , Christian Couder , Christian Couder Subject: [PATCH v3 03/13] upload-pack: move static vars to upload_pack_data Date: Thu, 4 Jun 2020 19:54:40 +0200 Message-Id: <20200604175450.17385-4-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc0.26.gf2851482f5 In-Reply-To: <20200604175450.17385-1-chriscool@tuxfamily.org> References: <20200602041657.7132-1-chriscool@tuxfamily.org> <20200604175450.17385-1-chriscool@tuxfamily.org> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Christian Couder As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's move the 'no_done', 'daemon_mode' and 'timeout' variables into this struct. They are only used by protocol v0 code since protocol v2 assumes certain baseline capabilities, but rolling them into upload_pack_data and just letting v2 code ignore them as it does now is more coherent and cleaner. Signed-off-by: Christian Couder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- upload-pack.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 3963a3805e..21a27b2d2c 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -45,8 +45,6 @@ static timestamp_t oldest_have; static int multi_ack; -static int no_done; -static int daemon_mode; /* Allow specifying sha1 if it is a ref tip. */ #define ALLOW_TIP_SHA1 01 /* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */ @@ -56,7 +54,6 @@ static int daemon_mode; static unsigned int allow_unadvertised_object_request; static int shallow_nr; static struct object_array extra_edge_obj; -static unsigned int timeout; static int keepalive = 5; /* 0 for no sideband, * otherwise maximum packet size (up to 65520 bytes). @@ -88,11 +85,15 @@ struct upload_pack_data { int deepen_rev_list; int deepen_relative; + unsigned int timeout; /* v0 only */ + struct list_objects_filter_options filter_options; struct packet_writer writer; unsigned stateless_rpc : 1; /* v0 only */ + unsigned no_done : 1; /* v0 only */ + unsigned daemon_mode : 1; /* v0 only */ unsigned use_thin_pack : 1; unsigned use_ofs_delta : 1; @@ -135,7 +136,7 @@ static void upload_pack_data_clear(struct upload_pack_data *data) list_objects_filter_release(&data->filter_options); } -static void reset_timeout(void) +static void reset_timeout(unsigned int timeout) { alarm(timeout); } @@ -251,7 +252,7 @@ static void create_pack_file(struct upload_pack_data *pack_data) int pe, pu, pollsize; int ret; - reset_timeout(); + reset_timeout(pack_data->timeout); pollsize = 0; pe = pu = -1; @@ -433,7 +434,7 @@ static int get_common_commits(struct upload_pack_data *data, for (;;) { const char *arg; - reset_timeout(); + reset_timeout(data->timeout); if (packet_reader_read(reader) != PACKET_READ_NORMAL) { if (multi_ack == 2 @@ -446,7 +447,7 @@ static int get_common_commits(struct upload_pack_data *data, if (data->have_obj.nr == 0 || multi_ack) packet_write_fmt(1, "NAK\n"); - if (no_done && sent_ready) { + if (data->no_done && sent_ready) { packet_write_fmt(1, "ACK %s\n", last_hex); return 0; } @@ -924,7 +925,7 @@ static void receive_needs(struct upload_pack_data *data, struct object_id oid_buf; const char *arg; - reset_timeout(); + reset_timeout(data->timeout); if (packet_reader_read(reader) != PACKET_READ_NORMAL) break; @@ -957,7 +958,7 @@ static void receive_needs(struct upload_pack_data *data, else if (parse_feature_request(features, "multi_ack")) multi_ack = 1; if (parse_feature_request(features, "no-done")) - no_done = 1; + data->no_done = 1; if (parse_feature_request(features, "thin-pack")) data->use_thin_pack = 1; if (parse_feature_request(features, "ofs-delta")) @@ -1000,7 +1001,7 @@ static void receive_needs(struct upload_pack_data *data, if (has_non_tip) check_non_tip(data); - if (!use_sideband && daemon_mode) + if (!use_sideband && data->daemon_mode) data->no_progress = 1; if (data->depth == 0 && !data->deepen_rev_list && data->shallows.nr == 0) @@ -1149,19 +1150,18 @@ void upload_pack(struct upload_pack_options *options) struct packet_reader reader; struct upload_pack_data data; - timeout = options->timeout; - daemon_mode = options->daemon_mode; - git_config(upload_pack_config, NULL); upload_pack_data_init(&data); data.stateless_rpc = options->stateless_rpc; + data.daemon_mode = options->daemon_mode; + data.timeout = options->timeout; head_ref_namespaced(find_symref, &data.symref); if (options->advertise_refs || !data.stateless_rpc) { - reset_timeout(); + reset_timeout(data.timeout); head_ref_namespaced(send_ref, &data); for_each_namespaced_ref(send_ref, &data); advertise_shallow_grafts(1); From patchwork Thu Jun 4 17:54:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11588199 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 D852590 for ; Thu, 4 Jun 2020 17:55:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C0B6F20772 for ; Thu, 4 Jun 2020 17:55:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HmUNM+14" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730312AbgFDRzQ (ORCPT ); Thu, 4 Jun 2020 13:55:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730306AbgFDRzP (ORCPT ); Thu, 4 Jun 2020 13:55:15 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB303C08C5C0 for ; Thu, 4 Jun 2020 10:55:13 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id l26so6082697wme.3 for ; Thu, 04 Jun 2020 10:55:13 -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=jX0AK5luiXylzslMicIct5yR3Rg8SQteEy29aY+m6IQ=; b=HmUNM+14V9T2JyHyiCPffmbNsEDbDDVkhuv9PRZfQFrea4F8uHaMhNlbS4B8iArN8r 7wDqBJz5QCmYP7wTLzTNEreulkbXyO+PnboZqI47UqQBgV+cFPgOsW7nIuEihAcj7ZOu tWJw/vuXP1DX7IynJenAz91u1BITcEN7qeUoFALzROQz891AkJQLetFs8aQxXgvxBIzK wKPLm1mwmGuDplOcj6CljLQICWHK039bd+X5Dnoos11ZXCBt3w0HpsImaOWgWbRY4AVG CWeLovX+RjpzKzhYK4InoVTDFXb1iEhSRNZHFElUlJ5RxErZe7QXVCKHS9O9urVIhYnG NG2g== 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=jX0AK5luiXylzslMicIct5yR3Rg8SQteEy29aY+m6IQ=; b=G7KrzRx2afDhvNm6WuWWk9OQqhXpesU2uuE0MgBKIik8QnVTlGCQFhgUiVyGMMs+Uw EsI9rHQYM4nerObiW0mGHd0q+RlXXOtJp9cVk6CicjWssQLbJdOUvukbwhYxLstuC0gw qdGuqPyjOJjjBhe6KISElWiEotNy6Mx7Ge6f8x5aAXTvc6eI1yjusshlKo7kgE4Jd1ey 9dqlTZljw/QmvB1raEuFUDuJQ9yij4IO3R5vuxX6YiJLanc6TK6SzKvQClyx2qePiUe2 ZzuufZrU9fJR/93yO3Vu+NQRdrsA1cy/e/rg4LYjR/0Jvk6PX5JjtLwhmvNXTk7vjVXg dPLg== X-Gm-Message-State: AOAM531rWE9pyiP49js9QAqAKRkoKAyWJVmL6v41zNyrliatOr6R6mHp Qe2iSTNDCyCa7+1slwtVNUxGs6/yu0w= X-Google-Smtp-Source: ABdhPJxYHaJxPm/5cGEfDjpigCJSDgJ4gU6jhARAxhAjbTgOYjrOke7T14mt8KmpYISsbn26k6vxlQ== X-Received: by 2002:a1c:d7:: with SMTP id 206mr5068347wma.15.1591293312180; Thu, 04 Jun 2020 10:55:12 -0700 (PDT) Received: from localhost.localdomain ([185.228.231.251]) by smtp.gmail.com with ESMTPSA id s7sm9173540wrr.60.2020.06.04.10.55.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 10:55:11 -0700 (PDT) From: Christian Couder X-Google-Original-From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Jeff King , Taylor Blau , Jonathan Tan , Jonathan Nieder , Christian Couder , Christian Couder Subject: [PATCH v3 04/13] upload-pack: move use_sideband to upload_pack_data Date: Thu, 4 Jun 2020 19:54:41 +0200 Message-Id: <20200604175450.17385-5-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc0.26.gf2851482f5 In-Reply-To: <20200604175450.17385-1-chriscool@tuxfamily.org> References: <20200602041657.7132-1-chriscool@tuxfamily.org> <20200604175450.17385-1-chriscool@tuxfamily.org> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Christian Couder As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's move the 'use_sideband' static variable into this struct. This variable is used by both v0 and v2 protocols. While at it, let's update the comment near the variable definition. Signed-off-by: Christian Couder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- upload-pack.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 21a27b2d2c..07798fdc75 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -55,10 +55,6 @@ static unsigned int allow_unadvertised_object_request; static int shallow_nr; static struct object_array extra_edge_obj; static int keepalive = 5; -/* 0 for no sideband, - * otherwise maximum packet size (up to 65520 bytes). - */ -static int use_sideband; static const char *pack_objects_hook; static int filter_capability_requested; @@ -87,6 +83,9 @@ struct upload_pack_data { unsigned int timeout; /* v0 only */ + /* 0 for no sideband, otherwise DEFAULT_PACKET_MAX or LARGE_PACKET_MAX */ + int use_sideband; + struct list_objects_filter_options filter_options; struct packet_writer writer; @@ -141,7 +140,8 @@ static void reset_timeout(unsigned int timeout) alarm(timeout); } -static void send_client_data(int fd, const char *data, ssize_t sz) +static void send_client_data(int fd, const char *data, ssize_t sz, + int use_sideband) { if (use_sideband) { send_sideband(1, fd, data, sz, use_sideband); @@ -290,7 +290,8 @@ static void create_pack_file(struct upload_pack_data *pack_data) sz = xread(pack_objects.err, progress, sizeof(progress)); if (0 < sz) - send_client_data(2, progress, sz); + send_client_data(2, progress, sz, + pack_data->use_sideband); else if (sz == 0) { close(pack_objects.err); pack_objects.err = -1; @@ -333,7 +334,8 @@ static void create_pack_file(struct upload_pack_data *pack_data) } else buffered = -1; - send_client_data(1, data, sz); + send_client_data(1, data, sz, + pack_data->use_sideband); } /* @@ -346,7 +348,7 @@ static void create_pack_file(struct upload_pack_data *pack_data) * protocol to say anything, so those clients are just out of * luck. */ - if (!ret && use_sideband) { + if (!ret && pack_data->use_sideband) { static const char buf[] = "0005\1"; write_or_die(1, buf, 5); } @@ -360,15 +362,17 @@ static void create_pack_file(struct upload_pack_data *pack_data) /* flush the data */ if (0 <= buffered) { data[0] = buffered; - send_client_data(1, data, 1); + send_client_data(1, data, 1, + pack_data->use_sideband); fprintf(stderr, "flushed.\n"); } - if (use_sideband) + if (pack_data->use_sideband) packet_flush(1); return; fail: - send_client_data(3, abort_msg, sizeof(abort_msg)); + send_client_data(3, abort_msg, sizeof(abort_msg), + pack_data->use_sideband); die("git upload-pack: %s", abort_msg); } @@ -964,9 +968,9 @@ static void receive_needs(struct upload_pack_data *data, if (parse_feature_request(features, "ofs-delta")) data->use_ofs_delta = 1; if (parse_feature_request(features, "side-band-64k")) - use_sideband = LARGE_PACKET_MAX; + data->use_sideband = LARGE_PACKET_MAX; else if (parse_feature_request(features, "side-band")) - use_sideband = DEFAULT_PACKET_MAX; + data->use_sideband = DEFAULT_PACKET_MAX; if (parse_feature_request(features, "no-progress")) data->no_progress = 1; if (parse_feature_request(features, "include-tag")) @@ -1001,7 +1005,7 @@ static void receive_needs(struct upload_pack_data *data, if (has_non_tip) check_non_tip(data); - if (!use_sideband && data->daemon_mode) + if (!data->use_sideband && data->daemon_mode) data->no_progress = 1; if (data->depth == 0 && !data->deepen_rev_list && data->shallows.nr == 0) @@ -1486,7 +1490,7 @@ int upload_pack_v2(struct repository *r, struct argv_array *keys, git_config(upload_pack_config, NULL); upload_pack_data_init(&data); - use_sideband = LARGE_PACKET_MAX; + data.use_sideband = LARGE_PACKET_MAX; while (state != FETCH_DONE) { switch (state) { From patchwork Thu Jun 4 17:54:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11588215 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 899C5618 for ; Thu, 4 Jun 2020 17:55:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F38620772 for ; Thu, 4 Jun 2020 17:55:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U86LV9mU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730327AbgFDRzV (ORCPT ); Thu, 4 Jun 2020 13:55:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730266AbgFDRzP (ORCPT ); Thu, 4 Jun 2020 13:55:15 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 399AAC08C5C1 for ; Thu, 4 Jun 2020 10:55:15 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id c3so7073451wru.12 for ; Thu, 04 Jun 2020 10:55: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=Q8+pO6b+C6ueibgsRq/EOVwpJwefWlMdNVGnh7lNH9U=; b=U86LV9mUqYrrZzYP1IxlolgqTb8eibJnHf6gwxG6DscarmPJUgIcQhiZ1i86frYhLR oR1jVk1FWwlIa0kagD+e2+gcF9ylNgJE0in8WxVAnxjZNQglvomDePFDcgL4Rug31Y3c Y6v9MO/8WfBMxJVzbnQYEwCGrO9BZIxsFJnvyrRHUt1UVEhh3GYSJbpeJSkw+nZEHZTQ s+MWN6L+9k7Gk71vir+r5P53snQzn3W9L25WdPKF9zovAf7KB61E4ksjmejNimF9eBMe PJk3RdixJsX9a2KNFx9M9edtlIwtBD6WJIoaIebSvBDALNDLYz7/kRKvUQbBiz8jnUlL 9IzQ== 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=Q8+pO6b+C6ueibgsRq/EOVwpJwefWlMdNVGnh7lNH9U=; b=BKC6Nx7+ekQn+I9nI59vb7Z0cfPTtOhKf/evoy3JDyKcxcvowGYJoXmNRpYhyypR3d Y26BUyEVSLJekAboA2Gu2Og6F/rZMEeTFHwOhbCVMBu8N7APOHairdXiWdYN449GkHcm I4gjUfAoCJZbj1UZQIfF5S8v9c5DnmDwMxu59KjsVAroqxRJqoxiZ0ofZ4eLPn5WYBfZ x+FXTa2nU4GhQcS3G5VJwIsSKfxc+/Tof2mbJjfHQlHp3Gv42HICkTs6KvanD0JPEoH9 X+PCkglfgweeBTO44UYaOx6Vy0HKKohjFf58TlBOUatUirZWSfRrXD+xvseBzbFoLWnj 2PMw== X-Gm-Message-State: AOAM53272MIe/ISuMJsdiHtLbkJYsZaMMIHMTC+wpWwuypI06kUYiTFQ B7PChmIbSSPibWE1qNey7Exsu3z4Mr4= X-Google-Smtp-Source: ABdhPJzppMAzsNmy5W8QC5z6b1YSo/xmVcswOZBUU0VlF/KRemS6TMQuX4p+D4GlQ26Vap2VRBeWzg== X-Received: by 2002:adf:9c12:: with SMTP id f18mr5977741wrc.105.1591293313632; Thu, 04 Jun 2020 10:55:13 -0700 (PDT) Received: from localhost.localdomain ([185.228.231.251]) by smtp.gmail.com with ESMTPSA id s7sm9173540wrr.60.2020.06.04.10.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 10:55:13 -0700 (PDT) From: Christian Couder X-Google-Original-From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Jeff King , Taylor Blau , Jonathan Tan , Jonathan Nieder , Christian Couder , Christian Couder Subject: [PATCH v3 05/13] upload-pack: move filter_capability_requested to upload_pack_data Date: Thu, 4 Jun 2020 19:54:42 +0200 Message-Id: <20200604175450.17385-6-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc0.26.gf2851482f5 In-Reply-To: <20200604175450.17385-1-chriscool@tuxfamily.org> References: <20200602041657.7132-1-chriscool@tuxfamily.org> <20200604175450.17385-1-chriscool@tuxfamily.org> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Christian Couder As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's move the filter_capability_requested static variable into this struct. It is only used by protocol v0 code since protocol v2 assumes certain baseline capabilities, but rolling it into upload_pack_data and just letting v2 code ignore it as it does now is more coherent and cleaner. Signed-off-by: Christian Couder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- upload-pack.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 07798fdc75..6226387a84 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -57,7 +57,6 @@ static struct object_array extra_edge_obj; static int keepalive = 5; static const char *pack_objects_hook; -static int filter_capability_requested; static int allow_filter; static int allow_ref_in_want; @@ -93,6 +92,7 @@ struct upload_pack_data { unsigned stateless_rpc : 1; /* v0 only */ unsigned no_done : 1; /* v0 only */ unsigned daemon_mode : 1; /* v0 only */ + unsigned filter_capability_requested : 1; /* v0 only */ unsigned use_thin_pack : 1; unsigned use_ofs_delta : 1; @@ -943,7 +943,7 @@ static void receive_needs(struct upload_pack_data *data, continue; if (skip_prefix(reader->line, "filter ", &arg)) { - if (!filter_capability_requested) + if (!data->filter_capability_requested) die("git upload-pack: filtering capability not negotiated"); list_objects_filter_die_if_populated(&data->filter_options); parse_list_objects_filter(&data->filter_options, arg); @@ -976,7 +976,7 @@ static void receive_needs(struct upload_pack_data *data, if (parse_feature_request(features, "include-tag")) data->use_include_tag = 1; if (allow_filter && parse_feature_request(features, "filter")) - filter_capability_requested = 1; + data->filter_capability_requested = 1; o = parse_object(the_repository, &oid_buf); if (!o) { From patchwork Thu Jun 4 17:54:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11588217 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 8E94E90 for ; Thu, 4 Jun 2020 17:55:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7523520772 for ; Thu, 4 Jun 2020 17:55:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fKad3Ald" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730324AbgFDRzU (ORCPT ); Thu, 4 Jun 2020 13:55:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730306AbgFDRzR (ORCPT ); Thu, 4 Jun 2020 13:55:17 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79206C08C5C0 for ; Thu, 4 Jun 2020 10:55:16 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id x14so7115395wrp.2 for ; Thu, 04 Jun 2020 10:55: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=HdYZXtFZbQmoNqpb+TJRxmLNyZGIvx2H2KUYd4nidoY=; b=fKad3Ald/9wkjVD0Ee4jrKxmjmrZiAhys4615x7OhKOBXcU9sBWJsrnNtnQEUloFTU kaJa7pwUaR97s9YTrb1wF8ZEUNiba3Z6HCsWF7aK/kDF3RkaxFGFFFnyWk25ZiPQjDR+ sU+Q+ZSyA9nBX6DQJLgp8ZGkmcu96/G96k3uPajqpFHAgBSfTCDGAaW83psGLj6RiptM +Zs7Y/Wo11XIJjfAAWrGEoyeHhOQT+pvyJWxl2Ie+ijh6d5tdJ7Hxsf2yXFl17ehJyt0 j2USy7nvUgdCVEYKjyyV3Z/OlZEXd/9bcZLqGV86GOxpCTIF4B1uxA3bRh5HTMQfOW5d qNWA== 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=HdYZXtFZbQmoNqpb+TJRxmLNyZGIvx2H2KUYd4nidoY=; b=jYBL23KxHaxmY9bpO9ieN2wsRHwQizqNS795entfBn/9XOVkcGM0Sf/1CCV8OTi3KR 0zknEc2h9SJk/zmazqCsCNegqyyQb12uOIkymBgVoShpnSTMtEnBAJJaKw2zMS06DsFA t99pYlhlyRzIKksX6FuJpe7UtHSFtkHqWeF35544z0s+eKiW55bqstLtXNTVYocNr0+9 E4BoQzXHmQQMnNfhNqSZpKWtckuGD1UmJoT0pIYrepVYXODICmGWdZbUKawfEfi8Xa79 XV9lglUY6+CRy1sGi7mJC3aUPf2XJZxFQqTDFf06lSHWAfdlE/HbZYjFSmW+CH77OXJq rhWw== X-Gm-Message-State: AOAM5316qavaeeG+dzZvsFkBRohW0r4rYtOYdpkMH0/DONcsB3nfqGaH Klw9wTb0vXUYxBh8HEEPZEgPzu8pavo= X-Google-Smtp-Source: ABdhPJw2ncBWPBj+ywAZgIk4sWm25quT2Uxs3E8Z3sckAnA6lv271oNLH/yqHt2jxTyTk7eDwYcQnw== X-Received: by 2002:adf:f8c8:: with SMTP id f8mr5537016wrq.151.1591293314888; Thu, 04 Jun 2020 10:55:14 -0700 (PDT) Received: from localhost.localdomain ([185.228.231.251]) by smtp.gmail.com with ESMTPSA id s7sm9173540wrr.60.2020.06.04.10.55.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 10:55:14 -0700 (PDT) From: Christian Couder X-Google-Original-From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Jeff King , Taylor Blau , Jonathan Tan , Jonathan Nieder , Christian Couder , Christian Couder Subject: [PATCH v3 06/13] upload-pack: move multi_ack to upload_pack_data Date: Thu, 4 Jun 2020 19:54:43 +0200 Message-Id: <20200604175450.17385-7-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc0.26.gf2851482f5 In-Reply-To: <20200604175450.17385-1-chriscool@tuxfamily.org> References: <20200602041657.7132-1-chriscool@tuxfamily.org> <20200604175450.17385-1-chriscool@tuxfamily.org> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Christian Couder As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's move the multi_ack static variable into this struct. It is only used by protocol v0 code since protocol v2 assumes certain baseline capabilities, but rolling it into upload_pack_data and just letting v2 code ignore it as it does now is more coherent and cleaner. Signed-off-by: Christian Couder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- upload-pack.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 6226387a84..f8611a5d53 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -44,7 +44,6 @@ static timestamp_t oldest_have; -static int multi_ack; /* Allow specifying sha1 if it is a ref tip. */ #define ALLOW_TIP_SHA1 01 /* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */ @@ -81,6 +80,7 @@ struct upload_pack_data { int deepen_relative; unsigned int timeout; /* v0 only */ + int multi_ack; /* v0 only */ /* 0 for no sideband, otherwise DEFAULT_PACKET_MAX or LARGE_PACKET_MAX */ int use_sideband; @@ -441,14 +441,14 @@ static int get_common_commits(struct upload_pack_data *data, reset_timeout(data->timeout); if (packet_reader_read(reader) != PACKET_READ_NORMAL) { - if (multi_ack == 2 + if (data->multi_ack == 2 && got_common && !got_other && ok_to_give_up(&data->have_obj, &data->want_obj)) { sent_ready = 1; packet_write_fmt(1, "ACK %s ready\n", last_hex); } - if (data->have_obj.nr == 0 || multi_ack) + if (data->have_obj.nr == 0 || data->multi_ack) packet_write_fmt(1, "NAK\n"); if (data->no_done && sent_ready) { @@ -465,10 +465,10 @@ static int get_common_commits(struct upload_pack_data *data, switch (got_oid(arg, &oid, &data->have_obj)) { case -1: /* they have what we do not */ got_other = 1; - if (multi_ack + if (data->multi_ack && ok_to_give_up(&data->have_obj, &data->want_obj)) { const char *hex = oid_to_hex(&oid); - if (multi_ack == 2) { + if (data->multi_ack == 2) { sent_ready = 1; packet_write_fmt(1, "ACK %s ready\n", hex); } else @@ -478,9 +478,9 @@ static int get_common_commits(struct upload_pack_data *data, default: got_common = 1; oid_to_hex_r(last_hex, &oid); - if (multi_ack == 2) + if (data->multi_ack == 2) packet_write_fmt(1, "ACK %s common\n", last_hex); - else if (multi_ack) + else if (data->multi_ack) packet_write_fmt(1, "ACK %s continue\n", last_hex); else if (data->have_obj.nr == 1) packet_write_fmt(1, "ACK %s\n", last_hex); @@ -490,7 +490,7 @@ static int get_common_commits(struct upload_pack_data *data, } if (!strcmp(reader->line, "done")) { if (data->have_obj.nr > 0) { - if (multi_ack) + if (data->multi_ack) packet_write_fmt(1, "ACK %s\n", last_hex); return 0; } @@ -958,9 +958,9 @@ static void receive_needs(struct upload_pack_data *data, if (parse_feature_request(features, "deepen-relative")) data->deepen_relative = 1; if (parse_feature_request(features, "multi_ack_detailed")) - multi_ack = 2; + data->multi_ack = 2; else if (parse_feature_request(features, "multi_ack")) - multi_ack = 1; + data->multi_ack = 1; if (parse_feature_request(features, "no-done")) data->no_done = 1; if (parse_feature_request(features, "thin-pack")) From patchwork Thu Jun 4 17:54:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11588203 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 8B8F990 for ; Thu, 4 Jun 2020 17:55:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71EC120772 for ; Thu, 4 Jun 2020 17:55:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JRgusKMU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730330AbgFDRzV (ORCPT ); Thu, 4 Jun 2020 13:55:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730313AbgFDRzR (ORCPT ); Thu, 4 Jun 2020 13:55:17 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A94CDC08C5C2 for ; Thu, 4 Jun 2020 10:55:17 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id h5so7098622wrc.7 for ; Thu, 04 Jun 2020 10:55:17 -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=MxsWEJoxBfnhgL9c26xEUqJhJiGybJlPZyEbbubJj10=; b=JRgusKMUWqpaCia0nwLvHILRsJFl+aHMcaj4bh5WZ/h0tKfPC3AAJMMsC47wHN7JHN eZY7WImuLSIbSnIqWDQq/C+A7pFEym7kkbLj5SM8zrBVEMWPIU+W2d8qzyp3sx5nd8IG StHfhr3gDCUyMSmoDTW5k+I/KOYBoEsjU+aXyMglm/PVorVOxrOAU8hbcEiWxF/pY01N itrJKo6Edisz9V4EOKaXegDsiVj/8+YqVKhX/HJvqoaFwsYWpx0J0jur4PAivTT1oC3Y CeP2uT9pHm/0QCRqbj1tUzmV9VfJV8gXpZuEYYNzIRNIwEMdn64gOqezob2AzGPTOKkX nlFw== 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=MxsWEJoxBfnhgL9c26xEUqJhJiGybJlPZyEbbubJj10=; b=FvZYAlXZDxQnVGgC05ajlGVBTRpHqwuYOAneE/cZlvT2U1zd+Y2C51p3fG9ofoWRyL xp1TFfbA3kRVrCZFEVaMKNFPLyoVvO+m0uTb2xLeaVcq/rr0GGQHDNRACz31a/nWqp38 NOhBrDXRDgH/XxfGEIlj8JGsUkI8jMURPjS/3aKCHlotrHkMe54Ud/abWJhqdd0iimSf +bul/8xpCmqmqNy9N90EVqEyPg7nPBm9T3NPignKWs2FG6r0PeW+pVdBkiqLP8s+fMXc 9nWVFNKh+lEWYVWOPSKc9h2bAbRnbtEIgHgtFo34i+JMyRYe2VK0XT0HqRKjx7P+l4FQ Z5xA== X-Gm-Message-State: AOAM530SAJ6xfrs4Vk2nS0XqqB3YFABqQjpOSgYTmV9kUM+tqpPglJAo X/4dNAGvMVVWtZxpKu5gUKT5O5NMivU= X-Google-Smtp-Source: ABdhPJzuwsrqnGe98oS/6Tg2g7JD5c0OsVgeXMSsIlEMLPQIWU4DCaXDx9jsbBOVNd8dRzdX5YPRMw== X-Received: by 2002:adf:ecc2:: with SMTP id s2mr6149656wro.60.1591293316085; Thu, 04 Jun 2020 10:55:16 -0700 (PDT) Received: from localhost.localdomain ([185.228.231.251]) by smtp.gmail.com with ESMTPSA id s7sm9173540wrr.60.2020.06.04.10.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 10:55:15 -0700 (PDT) From: Christian Couder X-Google-Original-From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Jeff King , Taylor Blau , Jonathan Tan , Jonathan Nieder , Christian Couder , Christian Couder Subject: [PATCH v3 07/13] upload-pack: change multi_ack to an enum Date: Thu, 4 Jun 2020 19:54:44 +0200 Message-Id: <20200604175450.17385-8-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc0.26.gf2851482f5 In-Reply-To: <20200604175450.17385-1-chriscool@tuxfamily.org> References: <20200602041657.7132-1-chriscool@tuxfamily.org> <20200604175450.17385-1-chriscool@tuxfamily.org> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Christian Couder As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's take this opportunity to change the 'multi_ack' variable, which is now part of 'upload_pack_data', to an enum. This will make it clear which values this variable can take. Helped-by: Jonathan Tan Signed-off-by: Christian Couder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- upload-pack.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index f8611a5d53..e7b8140e55 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -80,7 +80,11 @@ struct upload_pack_data { int deepen_relative; unsigned int timeout; /* v0 only */ - int multi_ack; /* v0 only */ + enum { + NO_MULTI_ACK = 0, + MULTI_ACK = 1, + MULTI_ACK_DETAILED = 2 + } multi_ack; /* v0 only */ /* 0 for no sideband, otherwise DEFAULT_PACKET_MAX or LARGE_PACKET_MAX */ int use_sideband; @@ -441,7 +445,7 @@ static int get_common_commits(struct upload_pack_data *data, reset_timeout(data->timeout); if (packet_reader_read(reader) != PACKET_READ_NORMAL) { - if (data->multi_ack == 2 + if (data->multi_ack == MULTI_ACK_DETAILED && got_common && !got_other && ok_to_give_up(&data->have_obj, &data->want_obj)) { @@ -468,7 +472,7 @@ static int get_common_commits(struct upload_pack_data *data, if (data->multi_ack && ok_to_give_up(&data->have_obj, &data->want_obj)) { const char *hex = oid_to_hex(&oid); - if (data->multi_ack == 2) { + if (data->multi_ack == MULTI_ACK_DETAILED) { sent_ready = 1; packet_write_fmt(1, "ACK %s ready\n", hex); } else @@ -478,7 +482,7 @@ static int get_common_commits(struct upload_pack_data *data, default: got_common = 1; oid_to_hex_r(last_hex, &oid); - if (data->multi_ack == 2) + if (data->multi_ack == MULTI_ACK_DETAILED) packet_write_fmt(1, "ACK %s common\n", last_hex); else if (data->multi_ack) packet_write_fmt(1, "ACK %s continue\n", last_hex); @@ -958,9 +962,9 @@ static void receive_needs(struct upload_pack_data *data, if (parse_feature_request(features, "deepen-relative")) data->deepen_relative = 1; if (parse_feature_request(features, "multi_ack_detailed")) - data->multi_ack = 2; + data->multi_ack = MULTI_ACK_DETAILED; else if (parse_feature_request(features, "multi_ack")) - data->multi_ack = 1; + data->multi_ack = MULTI_ACK; if (parse_feature_request(features, "no-done")) data->no_done = 1; if (parse_feature_request(features, "thin-pack")) From patchwork Thu Jun 4 17:54:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11588201 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 95C381391 for ; Thu, 4 Jun 2020 17:55:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AEB420738 for ; Thu, 4 Jun 2020 17:55:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lUvpsvzk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730335AbgFDRzW (ORCPT ); Thu, 4 Jun 2020 13:55:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730315AbgFDRzT (ORCPT ); Thu, 4 Jun 2020 13:55:19 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA3DAC08C5C3 for ; Thu, 4 Jun 2020 10:55:18 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id x6so7053785wrm.13 for ; Thu, 04 Jun 2020 10:55: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=fqsr4g6A1cagzaI+GdVD3EDUOvQWnlnDKkH3jzVKflk=; b=lUvpsvzkBczUZ3FRANv2cUMTKAGGrYUhaeHj3H2By0DjBryq2rDYopU/bCLsEsQQvq jbuscqUwbjD10yZ0RCp7kIWhFunbFZsXQ3MXzq9DC3O+88A1RggKvqkR5aejxodHY0PA idxzYRz+j/d6R5fY6r/terhmH3Uiqovby3ZB7YZCnestHmngvmY/YNoQfxLTVJ6VI1oS VsaEXxR+NrCCREDFnElSHDb41AncN/WVRCkAjXA4h9qP541MuBprAQJzd28reCViVQ2U Ih4Ji1YR1NiBsfOty6b5jhFoV4rzUIwLw6PpmHwQxSbd6uNuj0L1dPBQ7h2JyW1EASRs GA8w== 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=fqsr4g6A1cagzaI+GdVD3EDUOvQWnlnDKkH3jzVKflk=; b=ttjKk76cS2KJ1wp/P2NIb9fqpSneEn4UMRCPj413/PO/19Su/h25Oj9StTZJ67/Tdn a8z78HOc3Orva9rSF3QsMktLIVj0j2wWN6ll4laHGC6oDRHtqLP0Q25Hn0oqidnJEVRq vUPJefMFQfcjkTXzRvOFF+TzXQMe+kbmOEk6+HX+OY0zhsz4K1sgODGqgj3UpHmt8g5Y jpbWKYz0EYHt0b6LqLZHJnuonchQJ93SwvTHMbXAF5WFz0UMwsNi5y+XF1+uTkKV1p4Y Xm8dNJdzG7ivTH+1jjDfjvd4ukKhNS0gJMMClol9XLseOUe0k5vq+cRvF2rXlvBEAySk h5Jg== X-Gm-Message-State: AOAM533SJb25bYnEuNrHrr1MEoLisk+JCKVct9iRotVs9WUc45KUep+9 cZ/qQjzOYXuGBd961xPkLjMp1Hycgs8= X-Google-Smtp-Source: ABdhPJx7+3Y7lskEymK0IyOXot1egxAIh267Hr2J55bJHttmHloGKP6K/GkhH/LMpMrVwWFkzmM/cQ== X-Received: by 2002:a5d:6944:: with SMTP id r4mr5412568wrw.169.1591293317276; Thu, 04 Jun 2020 10:55:17 -0700 (PDT) Received: from localhost.localdomain ([185.228.231.251]) by smtp.gmail.com with ESMTPSA id s7sm9173540wrr.60.2020.06.04.10.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 10:55:16 -0700 (PDT) From: Christian Couder X-Google-Original-From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Jeff King , Taylor Blau , Jonathan Tan , Jonathan Nieder , Christian Couder , Christian Couder Subject: [PATCH v3 08/13] upload-pack: pass upload_pack_data to upload_pack_config() Date: Thu, 4 Jun 2020 19:54:45 +0200 Message-Id: <20200604175450.17385-9-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc0.26.gf2851482f5 In-Reply-To: <20200604175450.17385-1-chriscool@tuxfamily.org> References: <20200602041657.7132-1-chriscool@tuxfamily.org> <20200604175450.17385-1-chriscool@tuxfamily.org> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Christian Couder As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's pass that struct to upload_pack_config(), so that this function can use all the fields of the struct. This will be used in followup commits to move static variables that are set in upload_pack_config() into 'upload_pack_data'. Signed-off-by: Christian Couder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- upload-pack.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index e7b8140e55..b846aa4728 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1113,7 +1113,7 @@ static int find_symref(const char *refname, const struct object_id *oid, return 0; } -static int upload_pack_config(const char *var, const char *value, void *unused) +static int upload_pack_config(const char *var, const char *value, void *cb_data) { if (!strcmp("uploadpack.allowtipsha1inwant", var)) { if (git_config_bool(var, value)) @@ -1158,10 +1158,10 @@ void upload_pack(struct upload_pack_options *options) struct packet_reader reader; struct upload_pack_data data; - git_config(upload_pack_config, NULL); - upload_pack_data_init(&data); + git_config(upload_pack_config, &data); + data.stateless_rpc = options->stateless_rpc; data.daemon_mode = options->daemon_mode; data.timeout = options->timeout; @@ -1491,11 +1491,11 @@ int upload_pack_v2(struct repository *r, struct argv_array *keys, clear_object_flags(ALL_FLAGS); - git_config(upload_pack_config, NULL); - upload_pack_data_init(&data); data.use_sideband = LARGE_PACKET_MAX; + git_config(upload_pack_config, &data); + while (state != FETCH_DONE) { switch (state) { case FETCH_PROCESS_ARGS: From patchwork Thu Jun 4 17:54:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11588205 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 1CAC31391 for ; Thu, 4 Jun 2020 17:55:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03B1820772 for ; Thu, 4 Jun 2020 17:55:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="csxsXnV1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730338AbgFDRzX (ORCPT ); Thu, 4 Jun 2020 13:55:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730322AbgFDRzU (ORCPT ); Thu, 4 Jun 2020 13:55:20 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E35EC08C5C0 for ; Thu, 4 Jun 2020 10:55:20 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id h5so7098733wrc.7 for ; Thu, 04 Jun 2020 10:55:20 -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=NsnmZbntEmSHnE0k9YV//POIaRzxQCkfQqAxlzppKoo=; b=csxsXnV1jN1uGMmJf+RMzJ0AQJzQS5NswdpzCL6iOfCkpIoQdkYs1S3GYmF9zD7fQJ l2KUTeivVItGSdYLhwPz4pPc8g4r57HsxSO2DjfVbeOr9U3pW0SPP10TcS+01OPL5yqf VtC67Wqt7AsfX0KY7A02JpyBBpUc2J4ciwiCOWZx6t1jme6W/aw318oCAf5UUXROFLkG ffAGQnQrxAn0JK/xd9ucyiFC9NuEJ+Q6dV/dSP5wlesehl4CP/QDN3gwVL7SouV+piG0 HLvmb5/drO3Y00noTDSOPJoocS66AtPVITuvTPua3lK9p4C7YKifMB2y5f3XObtJa2mx i6rw== 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=NsnmZbntEmSHnE0k9YV//POIaRzxQCkfQqAxlzppKoo=; b=kpoDVN14DYA3Z1bp3OZYGzu2mfcK3BEhiVaclIHilLPU6j0KbyU9xm5mSjhlvTHlXF VlM0BWQvdWBDLChNZWbh5z86q2PGgj6Sch2FJERLzvzIuilPL8PLSbRzZXTzyoVKTojz kHQ7+mTGxuUCWgo2RKu7s8dNhSAl2U4l7TCzbbnVRVnNLFOO3SlTbnC1/iVBoJq/TtWt OQM2LdeDaBfFSxbE3FeDmbGIl6DX1MKuXpRz1Zm/GRR3511Zp/+jRFNsB6OL/H+MGOSc SfYRhT0iE9LJXJjOY+tSHAgFr40JeowQr7pesO7xNWKKLpH5APvhG+QRr4wblYe4wVZr 4gNQ== X-Gm-Message-State: AOAM531K5ycJ0o6MZRMiJaJcBI3TQoIUg/C2sxEgsqwYbeR5fRXJPgdj /JE9U7TD35vIqcrBSNepj6/wdLUP1tA= X-Google-Smtp-Source: ABdhPJyqJqjMjGSn2v1GB46ee6emc91wmAItn9GVsHppm7j7HHb/8A1d9mGfPCpwlnsFb0+jLtGVfw== X-Received: by 2002:a05:6000:12c4:: with SMTP id l4mr5938910wrx.128.1591293318595; Thu, 04 Jun 2020 10:55:18 -0700 (PDT) Received: from localhost.localdomain ([185.228.231.251]) by smtp.gmail.com with ESMTPSA id s7sm9173540wrr.60.2020.06.04.10.55.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 10:55:18 -0700 (PDT) From: Christian Couder X-Google-Original-From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Jeff King , Taylor Blau , Jonathan Tan , Jonathan Nieder , Christian Couder , Christian Couder Subject: [PATCH v3 09/13] upload-pack: move keepalive to upload_pack_data Date: Thu, 4 Jun 2020 19:54:46 +0200 Message-Id: <20200604175450.17385-10-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc0.26.gf2851482f5 In-Reply-To: <20200604175450.17385-1-chriscool@tuxfamily.org> References: <20200602041657.7132-1-chriscool@tuxfamily.org> <20200604175450.17385-1-chriscool@tuxfamily.org> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Christian Couder As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's move the 'keepalive' static variable into this struct. It is used by code common to protocol v0 and protocol v2. Signed-off-by: Christian Couder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- upload-pack.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index b846aa4728..0eb4c32552 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -53,7 +53,6 @@ static timestamp_t oldest_have; static unsigned int allow_unadvertised_object_request; static int shallow_nr; static struct object_array extra_edge_obj; -static int keepalive = 5; static const char *pack_objects_hook; static int allow_filter; @@ -78,6 +77,7 @@ struct upload_pack_data { timestamp_t deepen_since; int deepen_rev_list; int deepen_relative; + int keepalive; unsigned int timeout; /* v0 only */ enum { @@ -125,6 +125,8 @@ static void upload_pack_data_init(struct upload_pack_data *data) data->shallows = shallows; data->deepen_not = deepen_not; packet_writer_init(&data->writer, 1); + + data->keepalive = 5; } static void upload_pack_data_clear(struct upload_pack_data *data) @@ -253,7 +255,7 @@ static void create_pack_file(struct upload_pack_data *pack_data) while (1) { struct pollfd pfd[2]; - int pe, pu, pollsize; + int pe, pu, pollsize, polltimeout; int ret; reset_timeout(pack_data->timeout); @@ -277,8 +279,11 @@ static void create_pack_file(struct upload_pack_data *pack_data) if (!pollsize) break; - ret = poll(pfd, pollsize, - keepalive < 0 ? -1 : 1000 * keepalive); + polltimeout = pack_data->keepalive < 0 + ? -1 + : 1000 * pack_data->keepalive; + + ret = poll(pfd, pollsize, polltimeout); if (ret < 0) { if (errno != EINTR) { @@ -1115,6 +1120,8 @@ static int find_symref(const char *refname, const struct object_id *oid, static int upload_pack_config(const char *var, const char *value, void *cb_data) { + struct upload_pack_data *data = cb_data; + if (!strcmp("uploadpack.allowtipsha1inwant", var)) { if (git_config_bool(var, value)) allow_unadvertised_object_request |= ALLOW_TIP_SHA1; @@ -1131,9 +1138,9 @@ static int upload_pack_config(const char *var, const char *value, void *cb_data) else allow_unadvertised_object_request &= ~ALLOW_ANY_SHA1; } else if (!strcmp("uploadpack.keepalive", var)) { - keepalive = git_config_int(var, value); - if (!keepalive) - keepalive = -1; + data->keepalive = git_config_int(var, value); + if (!data->keepalive) + data->keepalive = -1; } else if (!strcmp("uploadpack.allowfilter", var)) { allow_filter = git_config_bool(var, value); } else if (!strcmp("uploadpack.allowrefinwant", var)) { From patchwork Thu Jun 4 17:54:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11588207 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 664C0618 for ; Thu, 4 Jun 2020 17:55:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E51F20738 for ; Thu, 4 Jun 2020 17:55:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HHqu4py/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730174AbgFDRzY (ORCPT ); Thu, 4 Jun 2020 13:55:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730313AbgFDRzW (ORCPT ); Thu, 4 Jun 2020 13:55:22 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A55E1C08C5C0 for ; Thu, 4 Jun 2020 10:55:21 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id l11so7132422wru.0 for ; Thu, 04 Jun 2020 10:55:21 -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=jVVA927F6Ddsg0YqaC/pFt9jm0ZdWRv1/vx5O8QK2cw=; b=HHqu4py/ZKDHaMsgIljPvPB4A0JNvfZYHzRIab796bLVfk0wyqMa5an7VG2Fh5NwVm aWapIrDoQLgdLYtWaQ1eZeE/GyxduDZMPYJCmUzYOe7BTPEq45W3hLNtvmD0Gmv5HZYC H8qaGBfTisa83kUoRCTMyF47BAgIZJwGXatjDIUX/msnePL3vqXfUFnQcG0AbExQEdFY NQUXVDlr2/bzf+K2Bbf4a38Ktu3FZpOiuG8vBuEOnwSlEwYFK0VjQwoOkoSRMAUOS0h7 r7ETBS1Z0IZEDAYjEFNi5oWpL+UIi0LxssiXNM7v0msaKP8rOsBIijPzz/KdTcKaxJMh O92A== 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=jVVA927F6Ddsg0YqaC/pFt9jm0ZdWRv1/vx5O8QK2cw=; b=k8vj8Ax5I9j/0rPxCSaPalwT6ifhDV10+UqdGH0yKK59dZqI4HomLl5xVdd1e0evjE Ba0GQRTNln7ITHRcs9dheZK84pQRUA9LHmGMKgR9HcMtvDezA08xBeCnRclY9eFnKkgJ kDylO6WNMh24HpFfzfuHUZOt4ff105Xi4J3U9avzdrPY81bzdggbvYvPwotRDJ4sfBSK Q8hFHlKYOHnMnzCuI3Ntzyh3+3b4fx7Vz2/Rojz/+NLhJlbfvTToFNx3zxSbAiyEMmHb rLGEe497Qz5J/sBx5TPCKWp5p5bKrHGEZA4tsVTp9GaxLb8yl3hunFopQ9aIKtvEdhJl SiDg== X-Gm-Message-State: AOAM5316k4AngLjoLAUZ/H9uhktpOg1X3kDvisdkcQHdOc3beCWYJAUb fQEhzbusIT1jbnWQYT3BKoxUz04HOh4= X-Google-Smtp-Source: ABdhPJxH4a7wBwiagTZUcvEaKJqN50rSNtrUhIe8E8lsbZHtR/6MXYLavQDwNLxfQ4XNz3T329pnhQ== X-Received: by 2002:adf:bbc5:: with SMTP id z5mr5614097wrg.269.1591293320060; Thu, 04 Jun 2020 10:55:20 -0700 (PDT) Received: from localhost.localdomain ([185.228.231.251]) by smtp.gmail.com with ESMTPSA id s7sm9173540wrr.60.2020.06.04.10.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 10:55:19 -0700 (PDT) From: Christian Couder X-Google-Original-From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Jeff King , Taylor Blau , Jonathan Tan , Jonathan Nieder , Christian Couder , Christian Couder Subject: [PATCH v3 10/13] upload-pack: move allow_filter to upload_pack_data Date: Thu, 4 Jun 2020 19:54:47 +0200 Message-Id: <20200604175450.17385-11-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc0.26.gf2851482f5 In-Reply-To: <20200604175450.17385-1-chriscool@tuxfamily.org> References: <20200602041657.7132-1-chriscool@tuxfamily.org> <20200604175450.17385-1-chriscool@tuxfamily.org> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Christian Couder As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's move the 'allow_filter' static variable into this struct. It is used by both protocol v0 and protocol v2 code. Signed-off-by: Christian Couder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- upload-pack.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 0eb4c32552..19b342d4b0 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -55,7 +55,6 @@ static int shallow_nr; static struct object_array extra_edge_obj; static const char *pack_objects_hook; -static int allow_filter; static int allow_ref_in_want; static int allow_sideband_all; @@ -102,6 +101,7 @@ struct upload_pack_data { unsigned use_ofs_delta : 1; unsigned no_progress : 1; unsigned use_include_tag : 1; + unsigned allow_filter : 1; unsigned done : 1; /* v2 only */ }; @@ -984,7 +984,8 @@ static void receive_needs(struct upload_pack_data *data, data->no_progress = 1; if (parse_feature_request(features, "include-tag")) data->use_include_tag = 1; - if (allow_filter && parse_feature_request(features, "filter")) + if (data->allow_filter && + parse_feature_request(features, "filter")) data->filter_capability_requested = 1; o = parse_object(the_repository, &oid_buf); @@ -1090,7 +1091,7 @@ static int send_ref(const char *refname, const struct object_id *oid, " allow-reachable-sha1-in-want" : "", data->stateless_rpc ? " no-done" : "", symref_info.buf, - allow_filter ? " filter" : "", + data->allow_filter ? " filter" : "", git_user_agent_sanitized()); strbuf_release(&symref_info); } else { @@ -1142,7 +1143,7 @@ static int upload_pack_config(const char *var, const char *value, void *cb_data) if (!data->keepalive) data->keepalive = -1; } else if (!strcmp("uploadpack.allowfilter", var)) { - allow_filter = git_config_bool(var, value); + data->allow_filter = git_config_bool(var, value); } else if (!strcmp("uploadpack.allowrefinwant", var)) { allow_ref_in_want = git_config_bool(var, value); } else if (!strcmp("uploadpack.allowsidebandall", var)) { @@ -1334,7 +1335,7 @@ static void process_args(struct packet_reader *request, continue; } - if (allow_filter && skip_prefix(arg, "filter ", &p)) { + if (data->allow_filter && skip_prefix(arg, "filter ", &p)) { list_objects_filter_die_if_populated(&data->filter_options); parse_list_objects_filter(&data->filter_options, p); continue; From patchwork Thu Jun 4 17:54:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11588209 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 94B2090 for ; Thu, 4 Jun 2020 17:55:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7915920738 for ; Thu, 4 Jun 2020 17:55:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="StL6nQR1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730344AbgFDRz0 (ORCPT ); Thu, 4 Jun 2020 13:55:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730336AbgFDRzX (ORCPT ); Thu, 4 Jun 2020 13:55:23 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0C4CC08C5C0 for ; Thu, 4 Jun 2020 10:55:22 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id c3so7073804wru.12 for ; Thu, 04 Jun 2020 10:55:22 -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=3UbWBbqthOteAeFgEeN1OMziwAp2xGWU0IRuQXIy9Io=; b=StL6nQR1pd/tkHq/IM6sFg5WbC44j/uTrnmRRGDR5HOjyDTPllbmtTHTXHUeafK/8a Fat9hoFxTnm1UYrfeFC+ZhSAdzlDqKScxPcO8pMsthABd+xfvoKGYRNwYhV+uZK1VVfK Wd4HsqNQ9ATO9G9X//4a4lW4bkCLbdEIgY/fhIupSlVbyw7lAWo/bzyVJcsrWy0yYflU mHOShxJIMe/IiclIEjGBt6IO1Lr1J40hYhLVhNT2duyYilYaG2IB5pre/RltLsQ0dHEQ uBhAkVwi6YahbuH6/AZFb5pqcocO7Kq46KSuBxCY7vYPlGcXA+G+LUHPaEd2bRsnP5Yk Vawg== 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=3UbWBbqthOteAeFgEeN1OMziwAp2xGWU0IRuQXIy9Io=; b=R/FZpsySpxTvn2cdYNOrdPvFUoUwmJcbs3itzeBbgJeIH5KNOt/RBwgn2mrvxWG6mn kLJ1pUTpYNtlfwbHObwh5wfdaBwyStnYt7s1u1b+Fy4GGQZp1pdCDIVBDXMbRAYvFmjP rQXoWnoVejUnzfVMbNAgopqdnMRl9bGrjnZlJPw1oweNS3SDPFhcQRMbyoTVj58ztHBQ 3WP9vr8goRTcLkF8bGN63xkgtyI+Tywwrp9dQcgCMjEXvLvFxKbU3NG6LqHSoX0BmRCD /cgxIQes21vb4Ec018sk7M6D2PiLnFQNKS0/DiZicddEfNRZQqhFtkArb71y7xWogN37 waIg== X-Gm-Message-State: AOAM531FtTp2IgM8kmiAKDJzPYHd7JypjWwiIHFCV4fjf7iDKrQfBzWR KQOIhvr2v5lIDuVh1rLN1NHPs2bu1Qw= X-Google-Smtp-Source: ABdhPJxZp4fOIdPaGiahKPZZ34LQqDNXzf+Sn74VRq3UfXvlyvwkAJhyv+A/qmgrh+N7slSpv7yjBQ== X-Received: by 2002:a5d:60c3:: with SMTP id x3mr5336289wrt.48.1591293321307; Thu, 04 Jun 2020 10:55:21 -0700 (PDT) Received: from localhost.localdomain ([185.228.231.251]) by smtp.gmail.com with ESMTPSA id s7sm9173540wrr.60.2020.06.04.10.55.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 10:55:20 -0700 (PDT) From: Christian Couder X-Google-Original-From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Jeff King , Taylor Blau , Jonathan Tan , Jonathan Nieder , Christian Couder , Christian Couder Subject: [PATCH v3 11/13] upload-pack: move allow_ref_in_want to upload_pack_data Date: Thu, 4 Jun 2020 19:54:48 +0200 Message-Id: <20200604175450.17385-12-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc0.26.gf2851482f5 In-Reply-To: <20200604175450.17385-1-chriscool@tuxfamily.org> References: <20200602041657.7132-1-chriscool@tuxfamily.org> <20200604175450.17385-1-chriscool@tuxfamily.org> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Christian Couder As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's move the 'allow_ref_in_want' static variable into this struct. It is used only by protocol v2 code. Signed-off-by: Christian Couder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- upload-pack.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 19b342d4b0..0d75745d8d 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -55,8 +55,6 @@ static int shallow_nr; static struct object_array extra_edge_obj; static const char *pack_objects_hook; -static int allow_ref_in_want; - static int allow_sideband_all; /* @@ -104,6 +102,7 @@ struct upload_pack_data { unsigned allow_filter : 1; unsigned done : 1; /* v2 only */ + unsigned allow_ref_in_want : 1; /* v2 only */ }; static void upload_pack_data_init(struct upload_pack_data *data) @@ -1145,7 +1144,7 @@ static int upload_pack_config(const char *var, const char *value, void *cb_data) } else if (!strcmp("uploadpack.allowfilter", var)) { data->allow_filter = git_config_bool(var, value); } else if (!strcmp("uploadpack.allowrefinwant", var)) { - allow_ref_in_want = git_config_bool(var, value); + data->allow_ref_in_want = git_config_bool(var, value); } else if (!strcmp("uploadpack.allowsidebandall", var)) { allow_sideband_all = git_config_bool(var, value); } else if (!strcmp("core.precomposeunicode", var)) { @@ -1289,7 +1288,7 @@ static void process_args(struct packet_reader *request, /* process want */ if (parse_want(&data->writer, arg, &data->want_obj)) continue; - if (allow_ref_in_want && + if (data->allow_ref_in_want && parse_want_ref(&data->writer, arg, &data->wanted_refs, &data->want_obj)) continue; From patchwork Thu Jun 4 17:54:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11588211 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 250AF90 for ; Thu, 4 Jun 2020 17:55:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C118207D8 for ; Thu, 4 Jun 2020 17:55:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pYDggUJ/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730360AbgFDRza (ORCPT ); Thu, 4 Jun 2020 13:55:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730339AbgFDRzY (ORCPT ); Thu, 4 Jun 2020 13:55:24 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10721C08C5C0 for ; Thu, 4 Jun 2020 10:55:24 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id r9so6094090wmh.2 for ; Thu, 04 Jun 2020 10:55:23 -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=Rp+KI8HHhRsLIJaPWde4PVHjOxys+D0eD5bN7m2VPPg=; b=pYDggUJ/CMcjkSqCFb4TbLeV4fl4ovippJMgfVE9/lCUvwkuGFXtj8BLAMdM/qKsaX xk3aHT90WYYraNwmTM64E/IbXMMRkj1s3bomhrMJRgS5YPsVQ1LWmbFnokQMcwelSR6i 70sixyiLANzn+ZjD4cMP3hGjH1AdTShLwntoJUqh6zU2AnpMbfVZVE6gJ7gDS/VDQNx0 EmJ9jxmq7VrRPX2PdcP480ojlkwE+C6z+iUVuK6kWuKPrer8YvqkWrkcsqo2WQNDdJuu zgzcPi5Mhh6Z+lSupZUGjpHPktMYGVBsLdgCkReJH6g9b3ycGtYa82hQq/J3tsDAol95 z80w== 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=Rp+KI8HHhRsLIJaPWde4PVHjOxys+D0eD5bN7m2VPPg=; b=hfd98ekdTeu56eEpaKt/OEdNOTngU9w4dRTKwKJBDLGj/RmpJuR2r+tMEYVYBqyRw6 tx+r9SptBU+EZw4HLH5Os3kpAtr66vsTtRg3I1zxYSIbwqi2IMVAEFCvOpG1yxYogtbJ NU+iQfadvEEwIfV2CfwGg3/abi0g/h2L5vU8u7Ynw2gnPH9IkVxVkyq4yEzaCdeWFlkc pTe/eO+hrRG9z4iul4BS6XOAIbSoZDGVVOjPBSF6shwc/Geg3k3lHOwgQxI3t1jHwPHR dhgpqGGUpRnQAj/nBfywQLTnBRoijFjjq1CmZtJLK49+ivpa23jzUsYzX2cmctgvW/KJ ekqg== X-Gm-Message-State: AOAM5328hpPGULXuJWMfEYT7xuCGgvY/wJpCUdaGc3/46Vg8Vt7tERgc GlikJkwc2muTbczAqM9+27cG67pcPrg= X-Google-Smtp-Source: ABdhPJy1uyBYWXq3xCOzcJal+mo+XUebQZ59KnVJuh36umjVnTuQwnJOcu/jFtT4vudun7txNlwDMQ== X-Received: by 2002:a1c:4b0f:: with SMTP id y15mr5431132wma.83.1591293322482; Thu, 04 Jun 2020 10:55:22 -0700 (PDT) Received: from localhost.localdomain ([185.228.231.251]) by smtp.gmail.com with ESMTPSA id s7sm9173540wrr.60.2020.06.04.10.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 10:55:21 -0700 (PDT) From: Christian Couder X-Google-Original-From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Jeff King , Taylor Blau , Jonathan Tan , Jonathan Nieder , Christian Couder , Christian Couder Subject: [PATCH v3 12/13] upload-pack: move allow_sideband_all to upload_pack_data Date: Thu, 4 Jun 2020 19:54:49 +0200 Message-Id: <20200604175450.17385-13-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc0.26.gf2851482f5 In-Reply-To: <20200604175450.17385-1-chriscool@tuxfamily.org> References: <20200602041657.7132-1-chriscool@tuxfamily.org> <20200604175450.17385-1-chriscool@tuxfamily.org> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Christian Couder As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's move the 'allow_sideband_all' static variable into this struct. It is used only by protocol v2 code. Signed-off-by: Christian Couder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- upload-pack.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 0d75745d8d..78b10a89ea 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -55,8 +55,6 @@ static int shallow_nr; static struct object_array extra_edge_obj; static const char *pack_objects_hook; -static int allow_sideband_all; - /* * Please annotate, and if possible group together, fields used only * for protocol v0 or only for protocol v2. @@ -103,6 +101,7 @@ struct upload_pack_data { unsigned done : 1; /* v2 only */ unsigned allow_ref_in_want : 1; /* v2 only */ + unsigned allow_sideband_all : 1; /* v2 only */ }; static void upload_pack_data_init(struct upload_pack_data *data) @@ -1146,7 +1145,7 @@ static int upload_pack_config(const char *var, const char *value, void *cb_data) } else if (!strcmp("uploadpack.allowrefinwant", var)) { data->allow_ref_in_want = git_config_bool(var, value); } else if (!strcmp("uploadpack.allowsidebandall", var)) { - allow_sideband_all = git_config_bool(var, value); + data->allow_sideband_all = git_config_bool(var, value); } else if (!strcmp("core.precomposeunicode", var)) { precomposed_unicode = git_config_bool(var, value); } @@ -1341,7 +1340,7 @@ static void process_args(struct packet_reader *request, } if ((git_env_bool("GIT_TEST_SIDEBAND_ALL", 0) || - allow_sideband_all) && + data->allow_sideband_all) && !strcmp(arg, "sideband-all")) { data->writer.use_sideband = 1; continue; From patchwork Thu Jun 4 17:54:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11588213 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 B9035618 for ; Thu, 4 Jun 2020 17:55:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F92E20738 for ; Thu, 4 Jun 2020 17:55:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nl9QFimL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730354AbgFDRz3 (ORCPT ); Thu, 4 Jun 2020 13:55:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730341AbgFDRzZ (ORCPT ); Thu, 4 Jun 2020 13:55:25 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3227EC08C5C1 for ; Thu, 4 Jun 2020 10:55:25 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id x14so7115834wrp.2 for ; Thu, 04 Jun 2020 10:55:25 -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=0AvgNasTiy1kg7vtZwkKc8f2U7l1xPYOkExDxuqhIco=; b=nl9QFimL0OafwjvQAM0qeilk6Rl8lWKjPAIBPO7pvgvTkim/KRYIj4CGiYloQa3i/g /KE6huh3WVUdU+3eYyqq3Ng2Sy3sFPHoiekSfL1g+viSxGDVbc96Qyf98LEFSPAANBHr DmxwK32ISoI9uH/MoL9XwwzJUJuBk1cbAPqjFwT8HuG3vZibrqo8X4W/jPy+NhETx/lX SOsrZdIAMLLwxmlhJXp3ReaowoK476SjVh7Xs2NvS0V9FFyhM3QR3JMO1W8Kznqhmy8d UMOmMpiBPaQbq1o6nCf+RZo522YI8JqTJOu8XwD48kb25mOyJ3xG4gnJCHnBpgJC0rtl ZFFg== 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=0AvgNasTiy1kg7vtZwkKc8f2U7l1xPYOkExDxuqhIco=; b=NK2RQobio1B3+ejliUsjCZL0xzRQAVoR4O0OnsUmLORmdILTHyZKlTKxO4znjSWUhg 3xyCz+MaChBXs268uSVUU1TxkO7Y4AkgUK47Q3BV8a8wyY6ataxpyc7eVXzTKA5iH878 GX4oX9AJCIiuj1FWVDBpKaHtvJNANgV0jz2yG00sC7BWfZl4gwIptIIJMRLayljaSLmO vaIXTYEEZsQP7dR9BpO8FF0B0dhejCwI9YwJpmxwQcdTJx/yqXqusgdPuMQb8VdBTxfC 0/5B1/q1IReaG6SJU2hMhYLyJJLpLhXOIuftEUqkuuw8+JuTCpb5CEo/8yjb9zcNNmFS KDkg== X-Gm-Message-State: AOAM530aR0quaTbUq5GWyjs8+Pt9mUuCR93fRsjdJmLvo/VUMgRffv6z 68fCsh1FWmUIXEf1hJJ3adjdUV/aoH4= X-Google-Smtp-Source: ABdhPJz66I16R/WIRYykpG95YoYdQzy1e5R4/mUO596hctTcLT5S8vQw/M1ezAXy63fxiIX07umtVA== X-Received: by 2002:adf:9481:: with SMTP id 1mr5510756wrr.396.1591293323599; Thu, 04 Jun 2020 10:55:23 -0700 (PDT) Received: from localhost.localdomain ([185.228.231.251]) by smtp.gmail.com with ESMTPSA id s7sm9173540wrr.60.2020.06.04.10.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 10:55:23 -0700 (PDT) From: Christian Couder X-Google-Original-From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Jeff King , Taylor Blau , Jonathan Tan , Jonathan Nieder , Christian Couder , Christian Couder Subject: [PATCH v3 13/13] upload-pack: move pack_objects_hook to upload_pack_data Date: Thu, 4 Jun 2020 19:54:50 +0200 Message-Id: <20200604175450.17385-14-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc0.26.gf2851482f5 In-Reply-To: <20200604175450.17385-1-chriscool@tuxfamily.org> References: <20200602041657.7132-1-chriscool@tuxfamily.org> <20200604175450.17385-1-chriscool@tuxfamily.org> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Christian Couder As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's move the 'pack_objects_hook' static variable into this struct. It is used by code common to protocol v0 and protocol v2. While at it let's also free() it in upload_pack_data_clear(). Signed-off-by: Christian Couder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- upload-pack.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 78b10a89ea..bc7e3ca19d 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -53,7 +53,6 @@ static timestamp_t oldest_have; static unsigned int allow_unadvertised_object_request; static int shallow_nr; static struct object_array extra_edge_obj; -static const char *pack_objects_hook; /* * Please annotate, and if possible group together, fields used only @@ -88,6 +87,8 @@ struct upload_pack_data { struct packet_writer writer; + const char *pack_objects_hook; + unsigned stateless_rpc : 1; /* v0 only */ unsigned no_done : 1; /* v0 only */ unsigned daemon_mode : 1; /* v0 only */ @@ -137,6 +138,8 @@ static void upload_pack_data_clear(struct upload_pack_data *data) object_array_clear(&data->shallows); string_list_clear(&data->deepen_not, 0); list_objects_filter_release(&data->filter_options); + + free((char *)data->pack_objects_hook); } static void reset_timeout(unsigned int timeout) @@ -181,10 +184,10 @@ static void create_pack_file(struct upload_pack_data *pack_data) int i; FILE *pipe_fd; - if (!pack_objects_hook) + if (!pack_data->pack_objects_hook) pack_objects.git_cmd = 1; else { - argv_array_push(&pack_objects.args, pack_objects_hook); + argv_array_push(&pack_objects.args, pack_data->pack_objects_hook); argv_array_push(&pack_objects.args, "git"); pack_objects.use_shell = 1; } @@ -1153,7 +1156,7 @@ static int upload_pack_config(const char *var, const char *value, void *cb_data) if (current_config_scope() != CONFIG_SCOPE_LOCAL && current_config_scope() != CONFIG_SCOPE_WORKTREE) { if (!strcmp("uploadpack.packobjectshook", var)) - return git_config_string(&pack_objects_hook, var, value); + return git_config_string(&data->pack_objects_hook, var, value); } return parse_hide_refs_config(var, value, "uploadpack");