From patchwork Wed May 27 16:47:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11573555 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 ABBC314B7 for ; Wed, 27 May 2020 16:48:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93F072088E for ; Wed, 27 May 2020 16:48:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GRukJy0d" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728771AbgE0QsD (ORCPT ); Wed, 27 May 2020 12:48:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728384AbgE0QsC (ORCPT ); Wed, 27 May 2020 12:48:02 -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 B5BA6C03E97D for ; Wed, 27 May 2020 09:48:01 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id r15so52315wmh.5 for ; Wed, 27 May 2020 09:48:01 -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=QyOLRxr5ler/AlEa/fNiQDUJMQ0V1X/3P0+IQemadzI=; b=GRukJy0dDzOwy3hSD3uPqT9lx4zT+usN0QnLeFkf/ED6gxWgPXGeUmSxSr5MucRKrv JbjezJZtuRnqay+jh1Q3Yn2+73NxKo3tC0bGzhvdCpQG+XQiIHsuZZHsSzyK8hbtOP5F Sv8kGd0jEc8mP5xNS10UVcDat16mvgbel8DA1j0TI0MDV76Z31QH+klv3DTf0SZXDybb qoQgXfGq2eJI9Inu3zReS+cG/ijIM1XAFVc+h/4B4vOOlxb6CXl3nPvN/OJakXN9rVN+ Q0fUUe7Nx8KDxXkWLtCLtWyktKxHhjgmMkJAx34EkBe5hXnfCfn/6E9L1A92uVC0/T78 GOiA== 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=QyOLRxr5ler/AlEa/fNiQDUJMQ0V1X/3P0+IQemadzI=; b=jQirnhTUzrymsXuRUoPTZFbydKEx3zqEl9iy3MJUjNzzmoTAYOzQ5oECVnnV+dcaK6 i6oECVdI52NCF2gbQMaJ6e7kZ5G2yMKM5UEJgBbuOJ0q88GacUiQa1IANLnR61hPGT3j SLLAtHqT44VgBmuZ0vGsV1AhLCHve4EgjzgL+//iZ2a7ipLJQx/OnLl1K5d5waAodpnC POaYbVRRQmuG7bxZw1/SWBOvQrR5juedzJ/bjVKcV+feSnKsc17V7s5RZgGVkCZOw9ou 4P8S9RAzdaDGN5zLf9W6ZEgIjSXDbBMOuHY+aQNXuZep7B8lft5Ay3AsKT70ZBY/n8OM 1WXg== X-Gm-Message-State: AOAM532VssFdVVYEp1h0JIZibE64dFJSS0cTC5FxsrAzYwk/5Q6jk+Pu hJZGPPFsZdrmS0Yrf7uzfw6ikTsWURc= X-Google-Smtp-Source: ABdhPJw9/XjJZ1FVCa48jrRia7RfxiOnez/KzDWvKaEFbahYAn/Z3iJTxaj041QiGmHfFF9stii/9A== X-Received: by 2002:a1c:f301:: with SMTP id q1mr5018848wmq.109.1590598078633; Wed, 27 May 2020 09:47:58 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.40]) by smtp.gmail.com with ESMTPSA id d17sm2432852wrg.75.2020.05.27.09.47.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 09:47:58 -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 01/12] upload-pack: actually use some upload_pack_data bitfields Date: Wed, 27 May 2020 18:47:31 +0200 Message-Id: <20200527164742.23067-2-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc2.38.gc6b4ed14d2.dirty In-Reply-To: <20200527164742.23067-1-chriscool@tuxfamily.org> References: <20200515100454.14486-1-chriscool@tuxfamily.org> <20200527164742.23067-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, which were previously unused. 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. Signed-off-by: Jeff King Signed-off-by: Christian Couder --- 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 Wed May 27 16:47:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11573551 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 B2DC814F6 for ; Wed, 27 May 2020 16:48:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A0D42088E for ; Wed, 27 May 2020 16:48:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mD+tBMj3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728728AbgE0QsC (ORCPT ); Wed, 27 May 2020 12:48:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726928AbgE0QsB (ORCPT ); Wed, 27 May 2020 12:48:01 -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 948D4C05BD1E for ; Wed, 27 May 2020 09:48:01 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id u13so86197wml.1 for ; Wed, 27 May 2020 09:48:01 -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=7UiFHnoDVmGy51pePUyz/BxKai79L3vtN4/6ZnTcCzc=; b=mD+tBMj3WwP16LOdU0djjNZm7+b8n2ZfJI5lwtRX4dvT3qeux+FnjH2bE6XfS3jWHc bNW3j14Fr1UfJO5DdXbjHUG2FNtTI+zcOBS1AqiYeLmAObWD9xytdEHzQwMrdOWnjY/z J+D2PavwXImaG6IXu4dqj9c3gVixmlrT603nPtfqIUoJAyoja83f+oSbkCY33sHykDVz JvVJWRFcoHzoZPvwvmUjW/P+oQ9UxYww6fIQxvt0umgD4+XYGcqbPSLtPfFd4TC+NDKf n4H9cfScKxPR0vwWP09VSc6MerdvIK1ZOrOnuiU65E20lqA1Q7gRsJ1HXbU0ga7yBl+L ZrkQ== 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=7UiFHnoDVmGy51pePUyz/BxKai79L3vtN4/6ZnTcCzc=; b=Y9S28UxLRc851Px5cr38OJxewtRuPetm9sPrvhDUt8wBUQBqzPEVa9joOM9trah7zU rwoEMqK1N/OCJ9OeDcdP3vGvmO7R0Z4HU6BqJQzIqqcA1L0vnS6BKTcs6e/xUznA407m 1Wvd4u78uB9lfNunTS0QcbaaLJ0LaYNUVnM1A8QGcuVdB5hsZJAW9ki5hAVMEP06l9dJ eZYx6bmajvjXR2XJ5OO0L/XVPgT+IyqtHEWzhxzEaJLQtxEg6lHs2oEAn/h4bVRqjIRB sH/vcvq1a4x/UVhWEfkEQNnUOa5o+0XMwX6vGpqfFr1/b4/Hdp98qhpmU+EdM+dInkV/ 7P6g== X-Gm-Message-State: AOAM530WjbBfBS5d+Ai8SFP+9Y40ADt+01gGh1yYBU2sAQ91LCLbHj34 +AVeJjrXC99gSGl7G3F2lm5R/KQJnog= X-Google-Smtp-Source: ABdhPJxlzMm5k1Ku0yCapsJ1WGDPa+EXkUyxXnHPTY/vd9cvc3uXCOOZKqmdxMTS3fQbEJLSLo6Krw== X-Received: by 2002:a7b:c149:: with SMTP id z9mr4933459wmi.57.1590598080012; Wed, 27 May 2020 09:48:00 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.40]) by smtp.gmail.com with ESMTPSA id d17sm2432852wrg.75.2020.05.27.09.47.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 09:47:59 -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 02/12] upload-pack: move static vars to upload_pack_data Date: Wed, 27 May 2020 18:47:32 +0200 Message-Id: <20200527164742.23067-3-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc2.38.gc6b4ed14d2.dirty In-Reply-To: <20200527164742.23067-1-chriscool@tuxfamily.org> References: <20200515100454.14486-1-chriscool@tuxfamily.org> <20200527164742.23067-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 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 --- upload-pack.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 2fa645834a..c83c5a619b 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). @@ -83,18 +80,21 @@ struct upload_pack_data { timestamp_t deepen_since; int deepen_rev_list; int deepen_relative; + int timeout; struct list_objects_filter_options filter_options; struct packet_writer writer; unsigned stateless_rpc : 1; + unsigned daemon_mode : 1; unsigned use_thin_pack : 1; unsigned use_ofs_delta : 1; unsigned no_progress : 1; unsigned use_include_tag : 1; unsigned done : 1; + unsigned no_done : 1; }; static void upload_pack_data_init(struct upload_pack_data *data) @@ -130,7 +130,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(int timeout) { alarm(timeout); } @@ -246,7 +246,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; @@ -428,7 +428,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 @@ -441,7 +441,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; } @@ -919,7 +919,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; @@ -952,7 +952,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")) @@ -995,7 +995,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) @@ -1144,19 +1144,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 Wed May 27 16:47:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11573557 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 1327814B7 for ; Wed, 27 May 2020 16:48:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBBE820873 for ; Wed, 27 May 2020 16:48:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ldQOWXQF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729836AbgE0QsH (ORCPT ); Wed, 27 May 2020 12:48:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728384AbgE0QsD (ORCPT ); Wed, 27 May 2020 12:48:03 -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 D97B1C05BD1E for ; Wed, 27 May 2020 09:48:02 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id j16so12266269wrb.7 for ; Wed, 27 May 2020 09:48:02 -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=Xx1Ri6O5ddwhCRuvySzBCDf1FEii2p3uCrzIYDEhXmk=; b=ldQOWXQFpNABRGX+WDrdgF80hyyXetrRgL++a27EqJWXC98QzRV97mtJARZF8jzhGM jzltmNvGNyCoOPriGC93STS0VB4YXEPnWSlm7u3uG1M+wBuwZ9pLndPE5IKzyR0YmeZa fLv0ZzG4V3/GF2Z5BBQvjqzxXCKxSy4NdHcMxxiBYk9urVk46UoLOPT8xYMLa44Go7Qp EcpPp2kF56DK34UTHF1KOsKUcCV0fpMgk2oY+pPLnX76Qa7p08Qq2WSCPhgxuWdlAXrl Dsf+SvHn+vZfQO5ckkzcSeQ/tHbwTO+4DVlUzqEUbGvFNxxeajhCoPGAYqorPxF853qN +u3A== 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=Xx1Ri6O5ddwhCRuvySzBCDf1FEii2p3uCrzIYDEhXmk=; b=joxYN2MsTXUu24F6BySqHnGbZpvjsNQWMk4KOA/gC12O0A8S7wzW3IUOKr0mT1Wegu e0gPG+8MHOi6EmCGOUfdlYIldn+0dF5CjbBs/7fDKKi99HYbB3adcJ+TIQLmxzMT4fVD zImdpMyvjtJG0QZpAqYHrfIALkwhidX9TfeGSqrHVioeJUmYclKOT46ckm5jCcRMidR+ TqV08VimTwCukD59lSbZJzRTt7GqzV81T7T/5AJSOHqaLUoZ/ukETEfESfI1FTAkErMB GrXZN19I55NgCcyi22/MIev82J3da1OPFDiDzeQLE+ntTL8w1aDFBb//4LVjAmjdCTIp 2exQ== X-Gm-Message-State: AOAM531toRFBQrPsQxsh8Pj04C7UwMSA01lOpEFKyzlJsyYnJ83T8XlH Nyv657M8a/+0z5f7QR3bruZK3f811W0= X-Google-Smtp-Source: ABdhPJyUeQuxUC/l1lfjSVGTjapWPFAf9tQe7MxfMVbvrRPvjIVJT/2ImXhVAJZ5VxCDm6giwV7Q1A== X-Received: by 2002:a5d:4f81:: with SMTP id d1mr14572414wru.95.1590598081258; Wed, 27 May 2020 09:48:01 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.40]) by smtp.gmail.com with ESMTPSA id d17sm2432852wrg.75.2020.05.27.09.48.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 09:48:00 -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 03/12] upload-pack: move use_sideband to upload_pack_data Date: Wed, 27 May 2020 18:47:33 +0200 Message-Id: <20200527164742.23067-4-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc2.38.gc6b4ed14d2.dirty In-Reply-To: <20200527164742.23067-1-chriscool@tuxfamily.org> References: <20200515100454.14486-1-chriscool@tuxfamily.org> <20200527164742.23067-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 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 --- upload-pack.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index c83c5a619b..a5a9750890 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; @@ -82,6 +78,9 @@ struct upload_pack_data { int deepen_relative; int timeout; + /* 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; @@ -135,7 +134,8 @@ static void reset_timeout(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); @@ -284,7 +284,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; @@ -327,7 +328,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); } /* @@ -340,7 +342,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); } @@ -354,15 +356,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); } @@ -958,9 +962,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")) @@ -995,7 +999,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) @@ -1480,7 +1484,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 Wed May 27 16:47:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11573559 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 54EB160D for ; Wed, 27 May 2020 16:48:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3CB192071A for ; Wed, 27 May 2020 16:48:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="STGX5SsV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729999AbgE0QsI (ORCPT ); Wed, 27 May 2020 12:48:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728944AbgE0QsE (ORCPT ); Wed, 27 May 2020 12:48:04 -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 24549C03E97D for ; Wed, 27 May 2020 09:48:04 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id s8so24656036wrt.9 for ; Wed, 27 May 2020 09:48:04 -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=ZTBtRVojsFooRQ8A/hfME/j5z9yFbNPFFADrvRLzKdc=; b=STGX5SsVkKbg7UbOGp7WW+m9yfnumY1dhMg+GZfXIyrm/O7kjJcI4Qe2PF4vizRaPh 2fypruU6YcMEZJ9zijyPbU5A4+zdYQ0W9+0/r6qQ/LH48Soy1s7Tn35Ug7KuBICWuPAs hYP+Ux9ZzJsEeEMCTHt7EhviEDTx7KUFn+8dC/474zO4hYSDoQ1zeY2QoDw8FeSJbzkz zHIbBTCHudldSUbQDl2oEQu7dAbGBRIO/zOnwFrXp0RQmKjIEmWUehorSuwx6ApOoszy 1778iAnl0LKgwupERnl3Yb1fQLozrWdD0jZ6IbVE6hGWgB+3xC+g4sy3k3xvbtOgdRoa sjiw== 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=ZTBtRVojsFooRQ8A/hfME/j5z9yFbNPFFADrvRLzKdc=; b=bdoK90lxwQHCRBiAfAH8eND/JDTep6S/Xny/vEisAg/VYuabSfWD/LfleqiwTSlwDS d7IVbtEF4NTt/5rE51x4PWMfJCrt8pqoILZjXsL1W1J2osgPj4S9zzks/q3W5siy1i5O hwtd4EJjOExaT59XdzydMhG1gfBJyu/WNj0vjdnpJ8XbJAh3x3hSJ9BDyHzN1S+O97qS 0T+Awhua1w3YYDCl0N0IFg3PhkK3VaoieOux1g7NDqj0epP1HZZHF7KAP6ehtJR8AQKL H4nU4mujOz77xrCeeKOwnxX31yffNRUffRhhh/iSYLcQNDFhDEAxo9A9G8wOfdI6OuNN HD9w== X-Gm-Message-State: AOAM531qQdOLZqG+sl/OkMC1aiIyJc1urqpZY8offcf9/CEdqoUJeSyH FPCZ3lhhuNopZWQc8UIxmknnRdLptpM= X-Google-Smtp-Source: ABdhPJzi8dBey89Dfs6Ifha3Zj1mpK2DPf4r6Rfu08AhYk9h9HW4DWmkr0ylrDnb6KGPn6i6bmbtHg== X-Received: by 2002:adf:a15c:: with SMTP id r28mr24306279wrr.337.1590598082488; Wed, 27 May 2020 09:48:02 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.40]) by smtp.gmail.com with ESMTPSA id d17sm2432852wrg.75.2020.05.27.09.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 09:48:01 -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 04/12] upload-pack: move filter_capability_requested to upload_pack_data Date: Wed, 27 May 2020 18:47:34 +0200 Message-Id: <20200527164742.23067-5-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc2.38.gc6b4ed14d2.dirty In-Reply-To: <20200527164742.23067-1-chriscool@tuxfamily.org> References: <20200515100454.14486-1-chriscool@tuxfamily.org> <20200527164742.23067-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 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 --- upload-pack.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index a5a9750890..e81b326690 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; @@ -94,6 +93,7 @@ struct upload_pack_data { unsigned use_include_tag : 1; unsigned done : 1; unsigned no_done : 1; + unsigned filter_capability_requested : 1; }; static void upload_pack_data_init(struct upload_pack_data *data) @@ -937,7 +937,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); @@ -970,7 +970,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 Wed May 27 16:47:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11573561 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 C35BC14B7 for ; Wed, 27 May 2020 16:48:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ABEA62088E for ; Wed, 27 May 2020 16:48:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ASvcYUgO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387444AbgE0QsI (ORCPT ); Wed, 27 May 2020 12:48:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729510AbgE0QsF (ORCPT ); Wed, 27 May 2020 12:48:05 -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 46CF0C08C5C1 for ; Wed, 27 May 2020 09:48:05 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id y17so16314765wrn.11 for ; Wed, 27 May 2020 09:48:05 -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=TMV0M3Ku0XaMVshO6irApQtFuX2W9J3TgmH+Vvf0oQY=; b=ASvcYUgOEt7Xl/okq5GGBZc/61fHfGZyHBUj8aEwvxIS55Oj4nARqpmJr4bqpBP6kF MmC4Qwx7nQZqUYiG70NxOjq2WE8g0yg8Zmrm44Mux6Rm90HKwgAW5hJEh4xw4/KzUtRX rfQgJzaAtXj0d6Atc6Bg1XpahwBaaisOyAVoAfGI2g+4HsGxPizBkstDEGKIwRjk/lTK oLkngr9GFoAFtviinkZ9laJgcyGiCSoc5cRipGGtnMRbMJcvXnABQ5Q8Hf7VjiVYkwE/ TFCSMjKuAMTR/gy6HxAX96vlkZ2YMYMyonRCcVVxiRcBrWngm679SVOxNh69UaptnHH0 LQIQ== 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=TMV0M3Ku0XaMVshO6irApQtFuX2W9J3TgmH+Vvf0oQY=; b=Xo5EIvomxjnRt/xzfqIX0h4AlbhLFOH92SwMe/YS8bAFw+/dBxOfnWPNg3Uc+WcuHJ Y+K6fJekgLMFvXR5D5L/iGwaJNf9S+4KkXBfeh4HZVNFKKn3aGVefEv8GHnzF+7cYgdA q3Fq8+bDtE1GJxVOrFyDL39e3RbOpSIfgvnNkaM9GRvwOMfcPu9fBeYWAMEYALBKcOvM 2YB4cK+KF4RZ2cjfXBJQBuy8WZJRTbbgQJu5XVSSrfjBus4jG03vkDP0/0rPXfAik14I r9FLrNptvy/8NHASyQRHrrd/gCIg5Kk3olLWPLNswAih5z1Jx9ojbfYjm/3Vjh96roSp f3bg== X-Gm-Message-State: AOAM5307SFPc02SuE4RChbHdGWyRoh0Mt9zTMeAMpzw89JRO0ou7Lldz vDFyHTYsyEgHD91e5QsQRQYVVhMp+BU= X-Google-Smtp-Source: ABdhPJyR1CPe3skjAm1dIB/Qwg4ODtHdDlrNiJ7oFSIwTB5Gog0JobhYrmCVcrEOlD3b/PqKGxtCjA== X-Received: by 2002:a5d:4a8a:: with SMTP id o10mr18624878wrq.222.1590598083655; Wed, 27 May 2020 09:48:03 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.40]) by smtp.gmail.com with ESMTPSA id d17sm2432852wrg.75.2020.05.27.09.48.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 09:48:03 -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 05/12] upload-pack: move multi_ack to upload_pack_data Date: Wed, 27 May 2020 18:47:35 +0200 Message-Id: <20200527164742.23067-6-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc2.38.gc6b4ed14d2.dirty In-Reply-To: <20200527164742.23067-1-chriscool@tuxfamily.org> References: <20200515100454.14486-1-chriscool@tuxfamily.org> <20200527164742.23067-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 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 --- upload-pack.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index e81b326690..385b165bec 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). */ @@ -76,6 +75,7 @@ struct upload_pack_data { int deepen_rev_list; int deepen_relative; int timeout; + int multi_ack; /* 0 for no sideband, otherwise DEFAULT_PACKET_MAX or LARGE_PACKET_MAX */ int use_sideband; @@ -435,14 +435,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) { @@ -459,10 +459,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 @@ -472,9 +472,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); @@ -484,7 +484,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; } @@ -952,9 +952,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 Wed May 27 16:47:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11573563 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 51D5B60D for ; Wed, 27 May 2020 16:48:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A92D2088E for ; Wed, 27 May 2020 16:48:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MkictQ/t" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389184AbgE0QsJ (ORCPT ); Wed, 27 May 2020 12:48:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729900AbgE0QsH (ORCPT ); Wed, 27 May 2020 12:48:07 -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 062E6C05BD1E for ; Wed, 27 May 2020 09:48:07 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id l11so24762936wru.0 for ; Wed, 27 May 2020 09:48:06 -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=JzaK3oaiuoxJl0gGNDuBN5H1kuaIm1tDSaPtL88bkAw=; b=MkictQ/tSjkj6/foS/0dyvF5TkSdngDqFMxbL1PgGDnkIDJ88Tae1P/xcxBszlMmSt PQ4AglE6jZgeB4Wcvz2w8seesqY1qS2F4lz22BIW5nGR5OvEroBTeoBLsRxhR8x+Rc+I 7pH1kUbrKRnz4cFjxrlhoIa/50R0+N87IjAKuFWZZ/uBuggwda4fLw35+9C273XN5L1r SI6xKs6h3TNLWBoMJM87y3etDA+gx6n74NcApCPvx5okb5/uIdUqdHLEIwEAH6qH64GS 2yaM4IfqdFb6db/msLnF1H1zwf+Qgd28avD32kPbD06Bt8ctT9UcAmkEj6sjogjYIFBT ltAQ== 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=JzaK3oaiuoxJl0gGNDuBN5H1kuaIm1tDSaPtL88bkAw=; b=tVjWfo8Oif1jO4+l9Y84xeaz78YhL1yKjdBNFY030Y4jCgUgjbcaIjjwDG2pHaS2uE NyJUYSJ9HkHpIwcQVK+oKDjZAApE/bGyw8YyG2KNiK8qaURbaGe7M5Ae3Br953QNs/jl 5Vjj5LCbddM5fW2s1PJTat5eYpz4ISvm4eR1QAjb4TgKuScan39lQyOlTuKqDlreciLj H9mw6yOac9Eau8r/wox21aoR73rC1zGCKFj/aZk2E5SEZABB0y8/lF7ZJ5vchPxv2Y5p vGfAMHj0vs9hEPKgZiutYimn7kYBK7Vb+YNW0tVzU/pvzFHleOwE89ar3hQKlsLd5r3C +XFQ== X-Gm-Message-State: AOAM531EeSfxrotYARsEmzdipEsaLvV3R7QAZXeEhp0XQ7Tf7hSKEIK9 o3XgdybRERXPJO4BWBl90oC0LV36Blw= X-Google-Smtp-Source: ABdhPJwSbEf1Xz64CnGW7epFlALUjSZipw8YoRzWOhyhn2l8yYkfz/dkS65TA5SD1bHyo8vH0qcN0A== X-Received: by 2002:a5d:4a0b:: with SMTP id m11mr5988815wrq.385.1590598084966; Wed, 27 May 2020 09:48:04 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.40]) by smtp.gmail.com with ESMTPSA id d17sm2432852wrg.75.2020.05.27.09.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 09:48:04 -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 06/12] upload-pack: change multi_ack to an enum Date: Wed, 27 May 2020 18:47:36 +0200 Message-Id: <20200527164742.23067-7-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc2.38.gc6b4ed14d2.dirty In-Reply-To: <20200527164742.23067-1-chriscool@tuxfamily.org> References: <20200515100454.14486-1-chriscool@tuxfamily.org> <20200527164742.23067-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 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. Signed-off-by: Christian Couder --- upload-pack.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 385b165bec..d211bebc0e 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -75,7 +75,12 @@ struct upload_pack_data { int deepen_rev_list; int deepen_relative; int timeout; - int multi_ack; + + enum { + no_multi_ack = 0, + multi_ack = 1, + multi_ack_detailed = 2 + } multi_ack; /* 0 for no sideband, otherwise DEFAULT_PACKET_MAX or LARGE_PACKET_MAX */ int use_sideband; @@ -435,7 +440,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)) { @@ -462,7 +467,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 @@ -472,7 +477,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); @@ -952,9 +957,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 Wed May 27 16:47:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11573575 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 E5DBC60D for ; Wed, 27 May 2020 16:48:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CDFB520873 for ; Wed, 27 May 2020 16:48:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W+wSOgF2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730471AbgE0QsW (ORCPT ); Wed, 27 May 2020 12:48:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728384AbgE0QsH (ORCPT ); Wed, 27 May 2020 12:48:07 -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 735F0C03E97D for ; Wed, 27 May 2020 09:48:07 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id e1so24723740wrt.5 for ; Wed, 27 May 2020 09:48:07 -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=biXD0PSbZHQ5kb+Lge2gnrWpM40mlglFMgRt9Fibc7I=; b=W+wSOgF2hTbJEo2wDxI0BEMVN558SyGEniUkhp29HCNBcRkest17IOYm8vKGju93PG /4HNk/Ts/7PZOFLsrWxzigGshY2/f1ciS7sL+ow/gPd174th1344Mxv+AgNdMQzzvXYK Nn2FY6mwRfacuS8m0Kd+SVP1Tp8cZ9VWoYNLpizQn7POlPvvUjXT24rEWFIk9r2eaCWz xO4LRaPA2GYYWLreKQ3pHLzWMKF1IBzsaKz4EWswRZbFAqV9uneDIWnXqO/atr6E0Sfm xN6mm71CMEa9UUwNq+IaPkP0oF4J2X4WJBYetO6oKk9/9/fAFsHf3ACaWMU1m1znK38a zOJA== 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=biXD0PSbZHQ5kb+Lge2gnrWpM40mlglFMgRt9Fibc7I=; b=T68EWy2/5vx0EHFyf0MW91MFYpkJVSyRl45Ucg7KwJ+8FLSKyojxitc6D5Ju5qJY62 PEX3jqvahcASWzAyeN8/o+jdFUYTQ1u6WuElpXIA73OePLhN6llzBZAnV4Jm3yAZKjNn bYY4TiFsPiUuuSYP1iey989tn9WGop3Hi48BvyqzvhWG2oDrCjDB3BP+a2HFykEZ5u+T Ok6pAPXIA+HUjYub0Pb/iwK85em8KsKol3dXX1ZZReEUQBv9T/PZD9XdIb3jkAFmOFhg kAAoeqFtebUQ9wJRTNG8UxvUthSoQgzNwU676VBVlFsTZAlORi6BB6GSLztX4C7767vz cNIw== X-Gm-Message-State: AOAM530+auXAhFy9l8+BN1NFcT47GNBXxPiT4oBg/WQomeElbziE7PS3 RqQyxYenB5us5ksi8tyS+B0ZbIdUfD0= X-Google-Smtp-Source: ABdhPJydnRvLouxz5/0ok/xoEnluuKDL1GEWGT3ikz0u9iZ5GMYke03vetrDn27YjKEC2s4SBRNdtg== X-Received: by 2002:adf:b34e:: with SMTP id k14mr25913695wrd.109.1590598085956; Wed, 27 May 2020 09:48:05 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.40]) by smtp.gmail.com with ESMTPSA id d17sm2432852wrg.75.2020.05.27.09.48.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 09:48:05 -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 07/12] upload-pack: pass upload_pack_data to upload_pack_config() Date: Wed, 27 May 2020 18:47:37 +0200 Message-Id: <20200527164742.23067-8-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc2.38.gc6b4ed14d2.dirty In-Reply-To: <20200527164742.23067-1-chriscool@tuxfamily.org> References: <20200515100454.14486-1-chriscool@tuxfamily.org> <20200527164742.23067-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 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 --- upload-pack.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index d211bebc0e..101e28f478 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1108,7 +1108,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)) @@ -1153,10 +1153,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; @@ -1486,11 +1486,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 Wed May 27 16:47: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: 11573567 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 8152B14F6 for ; Wed, 27 May 2020 16:48:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 69CDC2088E for ; Wed, 27 May 2020 16:48:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QkU68WE1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730463AbgE0QsO (ORCPT ); Wed, 27 May 2020 12:48:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387583AbgE0QsI (ORCPT ); Wed, 27 May 2020 12:48:08 -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 9565CC05BD1E for ; Wed, 27 May 2020 09:48:08 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id l11so24763046wru.0 for ; Wed, 27 May 2020 09:48:08 -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=nkG9ASB0F2f1N5uJN9mnbqQ/vFK2xlrVKb1Ou+cdgLQ=; b=QkU68WE1zIz3C9Z8yNyt02O9TQKza4yjEuqvWuthYCdSVOtBQqK8YCh5BD3Uc6vIwq L9VJnVNy/9MAB062A4axREagcm3jGZSMYVywcoyE4BEhVMaCTkeuhrAyaLJPuY4eAPsv 2qyqmY5ohGp4I4hO7X64ORSLKoEQBbUOawzPmEfmCBxnCboHKo9XryaMjl3t9YIQCIf2 ERLjytzD1n8mPKfWgh0hfmk6JeHojJYGfJNDObGqHySiqyP496AJVvDU7HYB2pQg7Z+w gH9ksclhHKi9Jnj+mbtVAj3fv6KJZf5ONf21G7qJ88GfRFHqOTlyJVkYVl6cJVAPchku p//A== 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=nkG9ASB0F2f1N5uJN9mnbqQ/vFK2xlrVKb1Ou+cdgLQ=; b=gpdNYABRhLeXV5QxQr5s1eJ0vkGwebZFlYTTXMbjDQmW9taDlX5/Sf/hHmE8iv0GCq 3GxGVcw08w0MfUaSaCE4KhYsxyw4w2wlBsNAYbIfPKEOET5CFFNAs8b6advkHmQ86QGH fpr4r/QVd4XX7Ou+CqghWw9yAXcMa+tcZ8fenr2Tq/KeNEeDoncX+sjnbZkABf36JU53 AukUznYtSebfTUAVhsYgOmZ3VsLkBesTWw1fnA0mfqtl7AKaWd557BkrkW/2KXMI6ZRp VW/ehDzDIk0jYolSmsDq7oX52YDx5UJiaQjTRxwoHjFPhY0yNMtJl/yuBe/QvgIU+hUM 6n6A== X-Gm-Message-State: AOAM532IQQiZqoRbS0WndHXNH8L+YxWZS1JMUeWCeeBJ10zn7RiQ7vPA wAtH4waIt5fiUWF4nK8dF2A7+JBr3dw= X-Google-Smtp-Source: ABdhPJxeW92Hw4B9H6aYCk1lsVzbSKReenG727MLV3kDpjAK9guUZDV6Igusw7SKU1ShPC/lVA4D+g== X-Received: by 2002:a05:6000:10cf:: with SMTP id b15mr24985312wrx.214.1590598087053; Wed, 27 May 2020 09:48:07 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.40]) by smtp.gmail.com with ESMTPSA id d17sm2432852wrg.75.2020.05.27.09.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 09:48:06 -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 08/12] upload-pack: move keepalive to upload_pack_data Date: Wed, 27 May 2020 18:47:38 +0200 Message-Id: <20200527164742.23067-9-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc2.38.gc6b4ed14d2.dirty In-Reply-To: <20200527164742.23067-1-chriscool@tuxfamily.org> References: <20200515100454.14486-1-chriscool@tuxfamily.org> <20200527164742.23067-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 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 --- upload-pack.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 101e28f478..e00631a703 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; @@ -75,6 +74,7 @@ struct upload_pack_data { int deepen_rev_list; int deepen_relative; int timeout; + int keepalive; enum { no_multi_ack = 0, @@ -120,6 +120,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) @@ -248,7 +250,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); @@ -272,8 +274,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) { @@ -1110,6 +1115,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; @@ -1126,9 +1133,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 Wed May 27 16:47: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: 11573565 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 DCD7960D for ; Wed, 27 May 2020 16:48:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4013212CC for ; Wed, 27 May 2020 16:48:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mUsbKXG9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730439AbgE0QsN (ORCPT ); Wed, 27 May 2020 12:48:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725385AbgE0QsK (ORCPT ); Wed, 27 May 2020 12:48:10 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5580C05BD1E for ; Wed, 27 May 2020 09:48:09 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id u188so85638wmu.1 for ; Wed, 27 May 2020 09:48:09 -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=SCB04ebAsF3S6UDwsj3Vrt/qC1FbhUf2CC5VOfbFsrY=; b=mUsbKXG9h2tGwm9y+6C1K4/sQENwtJ9nJx2Oa7oyKCNUm1sm3BjYyB9gJv38lkSRLa lVKd00xkVrDgJalv60szWKMbGXjegpoCqqx46duoMKVrYpQNbn5Oa6J93nDfWnnSol3f vnynv4Qs/wGWSTLN/rkKMHjnvaQGK29dNDs0fFs5zJwAXw2o9LNqw+VaY1zQ6FGV5LdJ ZaTQ2rlTCPXyAHSqaxoYAQIjghtWbvQ+k6uhG/xXoXzCPlzXd4sHzfOrAYzhBRiQb2p9 f/H4I3im8sNlUGpOu9bpclO65cgqzEJgrJa8LnNhZ25elIBTvBUAAsuvEjJGVg3+xcG3 yyrQ== 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=SCB04ebAsF3S6UDwsj3Vrt/qC1FbhUf2CC5VOfbFsrY=; b=XU8JzDD32kQCeW0DChq0YkNRv8MgVu0gtZygLBrjToib2Ptc8n/QHsJKYClGSo3sUO xPkbYOX3pWQ7PLs+N5BZBO61x5OnZwIInPhZyTfRf6O74+DZFQcQtKbZdVbzdWTgBHi0 HUT+FrkpMrt1nHC1j2SlYpC9gqW+vvQsJfL2cG2ebkFRo7dlGwbaA1/g6jAuxATQI0sc phq/F0FPisHzsOFmsGiJLpeqib8GQmtHPntfxo8jU+DqbEWIvtbm5HrA3rIcmKygp7Kd BcKpknaVp2YGCSEUnP4xSDF/iMVg1EnctCGoKCq0wEvlpgkA7yoyMDBwesepTaiR1aBA 7ejw== X-Gm-Message-State: AOAM532baXpVc9CiSonW7qlFEFjvKSUr0WZ+Ii7+eigzMI9f5qJyEbvl 4P2MdgaIqwiFCrxR9fQIFQHDnBHSh7c= X-Google-Smtp-Source: ABdhPJx/59MPfhj0WR+Cggo1RhR5JaUnHqQ9QmkBF4fYHL/Hf/bjdtjbc1kdK1o8oLR3gg7fSSznIQ== X-Received: by 2002:a1c:9c85:: with SMTP id f127mr5243513wme.79.1590598088267; Wed, 27 May 2020 09:48:08 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.40]) by smtp.gmail.com with ESMTPSA id d17sm2432852wrg.75.2020.05.27.09.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 09:48: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 09/12] upload-pack: move allow_filter to upload_pack_data Date: Wed, 27 May 2020 18:47:39 +0200 Message-Id: <20200527164742.23067-10-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc2.38.gc6b4ed14d2.dirty In-Reply-To: <20200527164742.23067-1-chriscool@tuxfamily.org> References: <20200515100454.14486-1-chriscool@tuxfamily.org> <20200527164742.23067-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 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 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 --- upload-pack.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index e00631a703..10bafeb8b6 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; @@ -99,6 +98,8 @@ struct upload_pack_data { unsigned done : 1; unsigned no_done : 1; unsigned filter_capability_requested : 1; + + unsigned allow_filter : 1; }; static void upload_pack_data_init(struct upload_pack_data *data) @@ -979,7 +980,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); @@ -1085,7 +1087,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 { @@ -1137,7 +1139,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)) { @@ -1329,7 +1331,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 Wed May 27 16:47: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: 11573573 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 CCE4260D for ; Wed, 27 May 2020 16:48:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B549A2088E for ; Wed, 27 May 2020 16:48:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UiguL2pw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727073AbgE0QsV (ORCPT ); Wed, 27 May 2020 12:48:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726927AbgE0QsL (ORCPT ); Wed, 27 May 2020 12:48:11 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F365C05BD1E for ; Wed, 27 May 2020 09:48:11 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id k26so60906wmi.4 for ; Wed, 27 May 2020 09:48: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=Np3x3lXNMsgPvQ0nMmzplFldIsfuVyoocsuMGjjF55I=; b=UiguL2pwLlxGwxskf1UnFIy/q8L07kfJKYSKWixs2wO/xP8dWDcuZP76VGfdK3KreY mb44wIFnzrX11aRiUaLRPSR8ohaD67JvOC2DGKuitSf6vgwsU/OiskO1/QouCUZv1lPy zDrRRarx9GWQEsPQIXFBnXfBojLpFjGJrGMp+4NR6TZIoOhI4knf5QA8Y+E+6Vxd69wy Mx1t3mbjC/FlqLagQ5+7lassm9w35znQ3OAaXiEr/Bc9uWoWG/erUfV57m62vst/cb20 RECBjrotwUBKK6BkhKprzECNL6N0Z750Eknt7Z+Pdu/PZXtaIHvRsj1/Vmx5dVOUwMMK B/2g== 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=Np3x3lXNMsgPvQ0nMmzplFldIsfuVyoocsuMGjjF55I=; b=Pvm9Rg/nhcid0hBlCr3Jd19K/SH5cO8B7FMXhYmEPp6C3p+50uwxsDcn8jUwyBKqFx GnFb7q1Lw02RwHuCfxpztCqxQyLhQe1R7TFVMmBCXPldtbtX7pRVZjW1Heb9zhYhk+U5 eFqEpAlYPQyvREH4MpQuieQHTNodP0pYXSFvO+m9zF4EoMqMpKEerHW1TZXk3PNQy8aE z7Wsel1On21ZzK+256OvspVUqHeLFiAmZNRMwMrRJnfRvpfUTj77ManO+e3xdKli0CdI 5VabvUxMw7r3Rxs4NGDv9jcLb5DVViRZs6koW3iqE/P5MeowzX9TDU2TcNzefkJ423ct 2Z/g== X-Gm-Message-State: AOAM530hPAocbaNUIponot+SR5k8KmfhrnZWNNNv+5O0sdislvYASzQ7 6HgBpZ+SXyyh8ng1xUNY5zzM6oma/mo= X-Google-Smtp-Source: ABdhPJyoSaE6rputAc7wETKHaScrXJLUopDhmLlz3r9irqxYDd0wrYjxMY8aCZPCtBBtx+sQlYMBng== X-Received: by 2002:a7b:c399:: with SMTP id s25mr5420619wmj.185.1590598089571; Wed, 27 May 2020 09:48:09 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.40]) by smtp.gmail.com with ESMTPSA id d17sm2432852wrg.75.2020.05.27.09.48.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 09:48: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 Subject: [PATCH 10/12] upload-pack: move allow_ref_in_want to upload_pack_data Date: Wed, 27 May 2020 18:47:40 +0200 Message-Id: <20200527164742.23067-11-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc2.38.gc6b4ed14d2.dirty In-Reply-To: <20200527164742.23067-1-chriscool@tuxfamily.org> References: <20200515100454.14486-1-chriscool@tuxfamily.org> <20200527164742.23067-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 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 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 --- upload-pack.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 10bafeb8b6..b5647eb47c 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; struct upload_pack_data { @@ -100,6 +98,7 @@ struct upload_pack_data { unsigned filter_capability_requested : 1; unsigned allow_filter : 1; + unsigned allow_ref_in_want : 1; }; static void upload_pack_data_init(struct upload_pack_data *data) @@ -1141,7 +1140,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)) { @@ -1285,7 +1284,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 Wed May 27 16:47: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: 11573571 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 2025260D for ; Wed, 27 May 2020 16:48:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 086D32088E for ; Wed, 27 May 2020 16:48:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uL822v8x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727806AbgE0QsU (ORCPT ); Wed, 27 May 2020 12:48:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729900AbgE0QsM (ORCPT ); Wed, 27 May 2020 12:48:12 -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 3413BC03E97D for ; Wed, 27 May 2020 09:48:12 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id c71so53900wmd.5 for ; Wed, 27 May 2020 09:48: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=X4h3dhzIalKM779J1TMHqw2IMtT+aQ6BFTV4HKHQb8M=; b=uL822v8xKIXvTBSGPhyFetFpn/kcC5tx6nz+PmZflPAMVv26sxZ9CEti+Q9/urX/6u uWt1zDVP8nqEj1/j2zXZpCYrOeZqtEhg95mp1XTZNiEDEF/wnueV3xMtsK8XDeTy0VjM 3vVKEbQkkhow4RTzSCHyOULC68kL4slPDj8ITYhhiQzUdDlifDHxyep4c8ifLx4lnh9u JbrbJ8KJhVEINH0VE1UhjvvgrZnP9OIjQUOg96JSaJmXA4FKJfTlbiFx/HtRy6+wmkAq wuvY1DJuuIvuxb5mgbO7FJy1VfI4byL72wFTiSqtKxQL8u3AYs6p4eRxuuPUpGGTyH5a 8rEw== 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=X4h3dhzIalKM779J1TMHqw2IMtT+aQ6BFTV4HKHQb8M=; b=oW2f5yRHArLBhx+ibsVXEjIofMfekdrttsuYwm72xCafzEgm1rGgnzSVqPzHRkFLyL U8A7OnsBhGGlxKYrXmyglai8mKU1IjkxiULKP7SywG7QeCD1nVHZMMht/SzZ8zOHszrp T4sIamBd9E9ubYJVKsOH653KCPZMye7tjsW3fsNaZ2mP0InLfyyTfLTx5RFBdYwKluo1 aN/uPYiPp0rFfExmyiR5qQKC14xN0u2AtI9JGTvOBOczI9M01jYs5mV/1fFJUoZvk3TG sFAJbT0rt/Ue7uBFRbmrtQ+mUwe3LC8gRynY38tqnKmO/NoQ6n76oEgkYT7MtwjByvo9 qIuw== X-Gm-Message-State: AOAM532wsTnJcY0EJESpJ68UjfDRzvsxVJPtkZmaY190GP24b680GTkf oixg7hC/mXtWXnMZF9H52+95tfi544Y= X-Google-Smtp-Source: ABdhPJwaHv/Qz2QnRjIRxjtYbi+hgG6gdxZNRwYTIAQTFSFwnxEzOphWkvYxRCx7iuJ8rSbaY6nfLA== X-Received: by 2002:a1c:f712:: with SMTP id v18mr5041897wmh.27.1590598090670; Wed, 27 May 2020 09:48:10 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.40]) by smtp.gmail.com with ESMTPSA id d17sm2432852wrg.75.2020.05.27.09.48.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 09:48: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 Subject: [PATCH 11/12] upload-pack: move allow_sideband_all to upload_pack_data Date: Wed, 27 May 2020 18:47:41 +0200 Message-Id: <20200527164742.23067-12-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc2.38.gc6b4ed14d2.dirty In-Reply-To: <20200527164742.23067-1-chriscool@tuxfamily.org> References: <20200515100454.14486-1-chriscool@tuxfamily.org> <20200527164742.23067-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 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 --- upload-pack.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index b5647eb47c..becefd5bdc 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; - struct upload_pack_data { struct string_list symref; struct string_list wanted_refs; @@ -99,6 +97,7 @@ struct upload_pack_data { unsigned allow_filter : 1; unsigned allow_ref_in_want : 1; + unsigned allow_sideband_all : 1; }; static void upload_pack_data_init(struct upload_pack_data *data) @@ -1142,7 +1141,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); } @@ -1337,7 +1336,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 Wed May 27 16:47: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: 11573569 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 608A114B7 for ; Wed, 27 May 2020 16:48:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4770C2071A for ; Wed, 27 May 2020 16:48:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RZGMkokw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387913AbgE0QsQ (ORCPT ); Wed, 27 May 2020 12:48:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730454AbgE0QsO (ORCPT ); Wed, 27 May 2020 12:48:14 -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 B113AC08C5C1 for ; Wed, 27 May 2020 09:48:13 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id j10so9112779wrw.8 for ; Wed, 27 May 2020 09:48: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=SRsCxpsZBYpWwlFd7P2jlA08CC1Cq0Wbcebjv+yKgFE=; b=RZGMkokwbbeN8rTIWCmSIZDk7LxFIWFRwYG2zjmOc94r3CVds796HNVq/4S57VTLDg ebUpEPLoGNwyNH/bkaEbhWRIJSRspiuGZWC3X/yfmtZRhvouMYLfVDEluv7V884IrYr9 AfVRh4ccdALKFJjsALcys4OYgJY4NOls1CwGwqYoRcG2IfkkVGvCJhxt/EK6te9w+ha0 NCDEFUQJ84F5EgceNtm5phkINVIKjo57dSv5Jzb5jFYQ0ntfreSeVYsH0jVf6lwIlpIu u+JobKnGZLaz91m9OHBJM59d6LeScu5NXsiKEdk0GLWIOHUnvk6Q5uEq35c7vFwee2Yc yStA== 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=SRsCxpsZBYpWwlFd7P2jlA08CC1Cq0Wbcebjv+yKgFE=; b=f3/9xC0i+wZi38ATUJXqwpI9gxKPbB0o8XFeGWlhsBolmn6QHYMJbwwvTvnUvDXpHp qtLmAZfUlPjaTre1aFwoqwgYyqJV3r1Mb+7l4eOArZhpS6raumrwPFVaolrXLriSV2HN tfeBEBvrsRLXySoLlg1ZgVPLcUKwBpqR3QTxPm/K2UQ5HdXOXBQnLHm1h1chpAJ/BFZq 25sOw968FFiXKlhSX91HPYYKH9eQIk1FfnxAsknk8x50/Q0nUqvhHB6hNCLsrg+OaNhg iMtXB3o+k1fQRl7hLE1bIQ9dWoBZX2aiXZHEC0F0iIVj9GiNW7UMwquFHLrg9K/EIGjh HmWw== X-Gm-Message-State: AOAM5339CE/wbv9112G9JoishPQNwOG/tIJbxtNxigJ4V6IjI9GQjorq kPjdJVCbwM+7GFveLssmwFoXtZWUOhc= X-Google-Smtp-Source: ABdhPJxURN3gNWrS90GzZ2cYUdT3IwUcxTqCqQBBtfRDrunE6FIlT3PPE/vvdbIyUcYUzWHlKXVXBw== X-Received: by 2002:a5d:6541:: with SMTP id z1mr25529975wrv.264.1590598092206; Wed, 27 May 2020 09:48:12 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.40]) by smtp.gmail.com with ESMTPSA id d17sm2432852wrg.75.2020.05.27.09.48.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 09:48: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 Subject: [PATCH 12/12] upload-pack: move pack_objects_hook to upload_pack_data Date: Wed, 27 May 2020 18:47:42 +0200 Message-Id: <20200527164742.23067-13-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.27.0.rc2.38.gc6b4ed14d2.dirty In-Reply-To: <20200527164742.23067-1-chriscool@tuxfamily.org> References: <20200515100454.14486-1-chriscool@tuxfamily.org> <20200527164742.23067-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 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 --- upload-pack.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index becefd5bdc..3e9ae53e6c 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; struct upload_pack_data { struct string_list symref; @@ -84,6 +83,8 @@ struct upload_pack_data { struct packet_writer writer; + const char *pack_objects_hook; + unsigned stateless_rpc : 1; unsigned daemon_mode : 1; @@ -133,6 +134,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(int timeout) @@ -177,10 +180,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; } @@ -1149,7 +1152,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");