From patchwork Fri May 15 10:04: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: 11550981 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 0265014C0 for ; Fri, 15 May 2020 10:05:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE9DE2074D for ; Fri, 15 May 2020 10:05:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d6Y/ourw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728126AbgEOKFM (ORCPT ); Fri, 15 May 2020 06:05:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728005AbgEOKFM (ORCPT ); Fri, 15 May 2020 06:05:12 -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 BA0ADC061A0C for ; Fri, 15 May 2020 03:05:11 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id d207so13489739wmd.0 for ; Fri, 15 May 2020 03:05:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b5ppLKRU0970ye5zTxC0e3Zk2GUGRNb3smRgNRmBA0E=; b=d6Y/ourwsCi32thP6dJx0oVygDgzklkH9Q6roSfFsKPBevxBunI7AlM4oAclEwz1zL Q0LMeb8n8MF3kaGwan6s/GRpzM+9532A2t+Y9OxCQWy4QPV3pXsaoydevzPOo5fZF9v4 MlPzE6cWun9g45LVBaEjs8anrDZ5kyF0TqpYRn1VrWrR7ymQQnu5JD2kTSQiUu/UZYdI Pvjy47OIDD5MyKk3EkPdjpz0+L4jY4KzTgYZd0b3i0iDVlvm/rd63Sx2UoTXR2wWwm1z jnO8aF9Uo8VLIY9Po/F8JhPSE09eOBeEM9AuzRmqKcGSX1FjROuNeFaW8lBoKfE9BUr5 kPxQ== 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=b5ppLKRU0970ye5zTxC0e3Zk2GUGRNb3smRgNRmBA0E=; b=QHDjpRnJ5aR6pg0JeU8RmkVIJC9o06cLI6qJtjv8jpYqnPdaA/QXJSXrGel+Jlsmp2 4pGVE5C9pLCm8wJ8v00XBNERml2Fml7NdBvwrRzKiGrYjaJOWQNnHfSVQvmCmkqICnoV CM8+FP90VxPbBvD+pOXgecz6rd1wcbeXdT51E+3L9822/dlZRDoYuRW7skqPohKRv9vN iPAIXScmo0VwqNtBYKDHP0DV/M3v/3GCPeiEOY1yuxaBiRnPOWU4MOvnWKpdkakDkfZg kSsOmtCbfWKiJpWJcpQodnv4BaFdHHco59qJAP6MuetDE8EOhXeKV+UgT7VVO2UsBAVN OsoA== X-Gm-Message-State: AOAM533LhA7zk1MVJkVqbfXmWr3hhZRQCdR+5Ckx+bua/ju9HN1rhTvi wTIIIFeGe2l1xnh8k0QUyA4b0QU2aT8= X-Google-Smtp-Source: ABdhPJxN+lEKl156Z+melVdpzGrXi1Zdonpkcpvgip0QzeOj/D+1uH1vH1mUgPrab7pTKavPXE5azA== X-Received: by 2002:a05:600c:2299:: with SMTP id 25mr3225572wmf.138.1589537110028; Fri, 15 May 2020 03:05:10 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.171]) by smtp.gmail.com with ESMTPSA id m3sm2792326wrn.96.2020.05.15.03.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 03:05:09 -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/13] upload-pack: remove unused 'wants' from upload_pack_data Date: Fri, 15 May 2020 12:04:42 +0200 Message-Id: <20200515100454.14486-2-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.26.2.639.gb7dde20fdf In-Reply-To: <20200515100454.14486-1-chriscool@tuxfamily.org> References: <20200515100454.14486-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 remove 'struct object_array wants' from 'struct upload_pack_data', as it appears to be unused. Signed-off-by: Christian Couder --- upload-pack.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 0478bff3e7..9aaf886828 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1131,7 +1131,6 @@ void upload_pack(struct upload_pack_options *options) } struct upload_pack_data { - struct object_array wants; struct string_list wanted_refs; struct oid_array haves; @@ -1157,14 +1156,12 @@ struct upload_pack_data { static void upload_pack_data_init(struct upload_pack_data *data) { - struct object_array wants = OBJECT_ARRAY_INIT; struct string_list wanted_refs = STRING_LIST_INIT_DUP; struct oid_array haves = OID_ARRAY_INIT; struct object_array shallows = OBJECT_ARRAY_INIT; struct string_list deepen_not = STRING_LIST_INIT_DUP; memset(data, 0, sizeof(*data)); - data->wants = wants; data->wanted_refs = wanted_refs; data->haves = haves; data->shallows = shallows; @@ -1174,7 +1171,6 @@ static void upload_pack_data_init(struct upload_pack_data *data) static void upload_pack_data_clear(struct upload_pack_data *data) { - object_array_clear(&data->wants); string_list_clear(&data->wanted_refs, 1); oid_array_clear(&data->haves); object_array_clear(&data->shallows); From patchwork Fri May 15 10:04: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: 11550987 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 9858D14F7 for ; Fri, 15 May 2020 10:05:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C9A220760 for ; Fri, 15 May 2020 10:05:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lVvyS9nD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728133AbgEOKFO (ORCPT ); Fri, 15 May 2020 06:05:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728127AbgEOKFN (ORCPT ); Fri, 15 May 2020 06:05:13 -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 14560C061A0C for ; Fri, 15 May 2020 03:05:13 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id f13so1689195wmc.5 for ; Fri, 15 May 2020 03:05: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=ubsdCUOVUBnqz6Tl9GCvT1w2qtiEbSyP7W0au0MvThk=; b=lVvyS9nDsDmAyJZCeJKt9PhU0pwQ4JvVWoqzYYceolxrnMEoGn/ETLHFGasov6qpfe jSKmWlylf1icNustQ2FvAK140dTywlpgDV0rD5tPjQNh0lHsFs3gr8QbasqxZHEAT2by dQl3h15M/nr7yXMRLI0GD8Oo1lC5P5LTq1mbHCBf4SNEBs6hk7zaJj5rEP5TKa3xFd93 4h2yJJPrxJq/DxO7B0jhyswU7ekhqpLheYEc2yYl/NfSEXP5NI72HBO3Z/k7A71STFVH R2y7vdlurTbJRsEMN9/JN7u3ipSmXY+YwX3nidICvMJOcnhhqeOwEWMj0Y+17gquolKl 37Tw== 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=ubsdCUOVUBnqz6Tl9GCvT1w2qtiEbSyP7W0au0MvThk=; b=WPDC6O+v9umfqiZTLWI+9Dp7+27oE8XbaBBlGfELhwxqsNLunMCHIsGXaD/elfMQO4 DI+qFSH3sasjY7qW306wIIuy8OYPauCqeLQBVExldhh0XdN/tHghIRcRFC6b8nCy57Xr kveEZTKm7E0QJHMLhUsLw7mLzBDcpFn1rCB8e6PgqtTOOvlbRHzbzF/9JIM6W7Pj92Tt +zSHYpp3m5wp7ecGM3IjkIVKd/pm1IU0uMg8s9Y2wvxPFkHoT/R+KMxFXeNu3n5T7CLS rXPKFWZAag4SwEFT2VmnFG8ldPwQlNTpKXtOdQwIPZ+pnDbWH7c0ALzpF05Z5hc1PITL 62DA== X-Gm-Message-State: AOAM533BzZHTw+nLs+uQxfEzM0Du2d0CSNQkvASFZBxUc3EowDT1kVNx tmfgtz6ZygyiY5enSiuw02RnqDzbxX0= X-Google-Smtp-Source: ABdhPJzNfaWjSdslc6FZH+gVbfCbYZEn16r+iWatdoGm79zDT+OxNFzOsx8Vgfo3kvxLtcM+tI6DjA== X-Received: by 2002:a05:600c:297:: with SMTP id 23mr3373764wmk.12.1589537111305; Fri, 15 May 2020 03:05:11 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.171]) by smtp.gmail.com with ESMTPSA id m3sm2792326wrn.96.2020.05.15.03.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 03:05: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 02/13] upload-pack: move {want,have}_obj to upload_pack_data Date: Fri, 15 May 2020 12:04:43 +0200 Message-Id: <20200515100454.14486-3-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.26.2.639.gb7dde20fdf In-Reply-To: <20200515100454.14486-1-chriscool@tuxfamily.org> References: <20200515100454.14486-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 want_obj and have_obj object arrays into 'struct upload_pack_data'. These object arrays are used by both upload_pack() and upload_pack_v2(), for example when these functions call create_pack_file(). We are going to use 'struct upload_pack_data' in upload_pack() in a followup commit. Signed-off-by: Christian Couder --- upload-pack.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 9aaf886828..e1b10522f7 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1132,6 +1132,8 @@ void upload_pack(struct upload_pack_options *options) struct upload_pack_data { struct string_list wanted_refs; + struct object_array want_obj; + struct object_array have_obj; struct oid_array haves; struct object_array shallows; @@ -1157,12 +1159,16 @@ struct upload_pack_data { static void upload_pack_data_init(struct upload_pack_data *data) { struct string_list wanted_refs = STRING_LIST_INIT_DUP; + struct object_array want_obj = OBJECT_ARRAY_INIT; + struct object_array have_obj = OBJECT_ARRAY_INIT; struct oid_array haves = OID_ARRAY_INIT; struct object_array shallows = OBJECT_ARRAY_INIT; struct string_list deepen_not = STRING_LIST_INIT_DUP; memset(data, 0, sizeof(*data)); data->wanted_refs = wanted_refs; + data->want_obj = want_obj; + data->have_obj = have_obj; data->haves = haves; data->shallows = shallows; data->deepen_not = deepen_not; @@ -1172,6 +1178,8 @@ static void upload_pack_data_init(struct upload_pack_data *data) static void upload_pack_data_clear(struct upload_pack_data *data) { string_list_clear(&data->wanted_refs, 1); + object_array_clear(&data->want_obj); + object_array_clear(&data->have_obj); oid_array_clear(&data->haves); object_array_clear(&data->shallows); string_list_clear(&data->deepen_not, 0); @@ -1256,19 +1264,18 @@ static int parse_have(const char *line, struct oid_array *haves) } static void process_args(struct packet_reader *request, - struct upload_pack_data *data, - struct object_array *want_obj) + struct upload_pack_data *data) { while (packet_reader_read(request) == PACKET_READ_NORMAL) { const char *arg = request->line; const char *p; /* process want */ - if (parse_want(&data->writer, arg, want_obj)) + if (parse_want(&data->writer, arg, &data->want_obj)) continue; if (allow_ref_in_want && parse_want_ref(&data->writer, arg, &data->wanted_refs, - want_obj)) + &data->want_obj)) continue; /* process have line */ if (parse_have(arg, &data->haves)) @@ -1399,17 +1406,16 @@ static int send_acks(struct packet_writer *writer, struct oid_array *acks, return 0; } -static int process_haves_and_send_acks(struct upload_pack_data *data, - struct object_array *have_obj, - struct object_array *want_obj) +static int process_haves_and_send_acks(struct upload_pack_data *data) { struct oid_array common = OID_ARRAY_INIT; int ret = 0; - process_haves(&data->haves, &common, have_obj); + process_haves(&data->haves, &common, &data->have_obj); if (data->done) { ret = 1; - } else if (send_acks(&data->writer, &common, have_obj, want_obj)) { + } else if (send_acks(&data->writer, &common, + &data->have_obj, &data->want_obj)) { packet_writer_delim(&data->writer); ret = 1; } else { @@ -1441,8 +1447,7 @@ static void send_wanted_ref_info(struct upload_pack_data *data) packet_writer_delim(&data->writer); } -static void send_shallow_info(struct upload_pack_data *data, - struct object_array *want_obj) +static void send_shallow_info(struct upload_pack_data *data) { /* No shallow info needs to be sent */ if (!data->depth && !data->deepen_rev_list && !data->shallows.nr && @@ -1455,10 +1460,10 @@ static void send_shallow_info(struct upload_pack_data *data, data->deepen_rev_list, data->deepen_since, &data->deepen_not, data->deepen_relative, - &data->shallows, want_obj) && + &data->shallows, &data->want_obj) && is_repository_shallow(the_repository)) deepen(&data->writer, INFINITE_DEPTH, data->deepen_relative, - &data->shallows, want_obj); + &data->shallows, &data->want_obj); packet_delim(1); } @@ -1475,8 +1480,6 @@ int upload_pack_v2(struct repository *r, struct argv_array *keys, { enum fetch_state state = FETCH_PROCESS_ARGS; struct upload_pack_data data; - struct object_array have_obj = OBJECT_ARRAY_INIT; - struct object_array want_obj = OBJECT_ARRAY_INIT; clear_object_flags(ALL_FLAGS); @@ -1488,9 +1491,9 @@ int upload_pack_v2(struct repository *r, struct argv_array *keys, while (state != FETCH_DONE) { switch (state) { case FETCH_PROCESS_ARGS: - process_args(request, &data, &want_obj); + process_args(request, &data); - if (!want_obj.nr) { + if (!data.want_obj.nr) { /* * Request didn't contain any 'want' lines, * guess they didn't want anything. @@ -1510,18 +1513,19 @@ int upload_pack_v2(struct repository *r, struct argv_array *keys, } break; case FETCH_SEND_ACKS: - if (process_haves_and_send_acks(&data, &have_obj, - &want_obj)) + if (process_haves_and_send_acks(&data)) state = FETCH_SEND_PACK; else state = FETCH_DONE; break; case FETCH_SEND_PACK: send_wanted_ref_info(&data); - send_shallow_info(&data, &want_obj); + send_shallow_info(&data); packet_writer_write(&data.writer, "packfile\n"); - create_pack_file(&have_obj, &want_obj, &data.filter_options); + create_pack_file(&data.have_obj, + &data.want_obj, + &data.filter_options); state = FETCH_DONE; break; case FETCH_DONE: @@ -1530,8 +1534,6 @@ int upload_pack_v2(struct repository *r, struct argv_array *keys, } upload_pack_data_clear(&data); - object_array_clear(&have_obj); - object_array_clear(&want_obj); return 0; } From patchwork Fri May 15 10:04: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: 11550985 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 3293390 for ; Fri, 15 May 2020 10:05:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B2CC20760 for ; Fri, 15 May 2020 10:05:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uDhIXyka" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728144AbgEOKFQ (ORCPT ); Fri, 15 May 2020 06:05:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728128AbgEOKFO (ORCPT ); Fri, 15 May 2020 06:05:14 -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 96AD7C061A0C for ; Fri, 15 May 2020 03:05:14 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id w7so2776567wre.13 for ; Fri, 15 May 2020 03:05:14 -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=eJHTDBVJt/x8TZMShSjXBxMTx4a49GJvjpTL40XCLRU=; b=uDhIXykay+tIIo4kLoLXrW8u39sXxL3/rDA4evuDK5gl26Pdag+V8a+dyxbuEegJDW REnJACwdLbhqIW0VI7hFhNdAz991X8Qj7EexaSKReXlvvyPQSJmoinU89UTHp2LyhYwH G/xw7lBPgUqdw+j+rSTn6OJlA5c7+Sr6+up2ig8nlmSW1pOkQH4id1xy4iwXXH3YmSGd +pXrRv9OKPveM+quB5CedrCqEusE8YJNBgS6UFHO0HmU91TTSAI9LoML4mO4GjzntDrN 3CrwBkH8cmhvhqQPIyPRXN2bFN+1EW54UhqFFyBBNr12F1PZv3TVMW90zBJugH+QwD1s l/iA== 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=eJHTDBVJt/x8TZMShSjXBxMTx4a49GJvjpTL40XCLRU=; b=elyMT/CLU+I40NfZv9AtfTbgsXdQnXlvZTKLph/M2dBC0G95OcNZHa7yasD4ay02Ox Ahoi3V5z7D3z5KrCoj4FsCc0xCtIXp6iNCmwiDNuEVLqrkhJjWLTnRYcwJWfceDEReYp 8t1RUZDuUMK4wpHV8ADwixXGZEu9DTaMiihDKVDI5Zs8ux7AvTKpe4SfL5LT5lLdzUuV ZYFJlqU0BjMj183Kxbquu97xaYcQrEJT4/W3peuf5a3v5OCFw5oixgQWDBbLeyl8fAGn MaMR8fKTWgPQ6ZGa6P+D4heuCC6Dn1ey6+qoU9r/KoPdZ7y31b26FYbc8v+z4EQpO1++ VHIg== X-Gm-Message-State: AOAM531baLS9jfoc7K31la4ItZyywaNrCEnL5n6tEBXvbvf7eV9/iZAA 1Oxx0ShBYhWIHoiZKw8UXDE3T1J55Hg= X-Google-Smtp-Source: ABdhPJxwDyMepckk+ULd3P1B+8AbTI+IdE+LEwvW9hM1Rxf8+MIzPIIR9tyF24pj3JHyB7C8r4LOpw== X-Received: by 2002:adf:e752:: with SMTP id c18mr3334166wrn.353.1589537112981; Fri, 15 May 2020 03:05:12 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.171]) by smtp.gmail.com with ESMTPSA id m3sm2792326wrn.96.2020.05.15.03.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 03:05:12 -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/13] upload-pack: move 'struct upload_pack_data' around Date: Fri, 15 May 2020 12:04:44 +0200 Message-Id: <20200515100454.14486-4-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.26.2.639.gb7dde20fdf In-Reply-To: <20200515100454.14486-1-chriscool@tuxfamily.org> References: <20200515100454.14486-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 'struct upload_pack_data' and the related upload_pack_data_init() and upload_pack_data_clear() functions towards the beginning of the file, so that this struct and its related functions can then be used by upload_pack() in a followup commit. Signed-off-by: Christian Couder --- upload-pack.c | 112 +++++++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index e1b10522f7..9aeb3477c9 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -72,6 +72,62 @@ static int allow_ref_in_want; static int allow_sideband_all; +struct upload_pack_data { + struct string_list wanted_refs; + struct object_array want_obj; + struct object_array have_obj; + struct oid_array haves; + + struct object_array shallows; + struct string_list deepen_not; + int depth; + timestamp_t deepen_since; + int deepen_rev_list; + int deepen_relative; + + struct list_objects_filter_options filter_options; + + struct packet_writer writer; + + unsigned stateless_rpc : 1; + + unsigned use_thin_pack : 1; + unsigned use_ofs_delta : 1; + unsigned no_progress : 1; + unsigned use_include_tag : 1; + unsigned done : 1; +}; + +static void upload_pack_data_init(struct upload_pack_data *data) +{ + struct string_list wanted_refs = STRING_LIST_INIT_DUP; + struct object_array want_obj = OBJECT_ARRAY_INIT; + struct object_array have_obj = OBJECT_ARRAY_INIT; + struct oid_array haves = OID_ARRAY_INIT; + struct object_array shallows = OBJECT_ARRAY_INIT; + struct string_list deepen_not = STRING_LIST_INIT_DUP; + + memset(data, 0, sizeof(*data)); + data->wanted_refs = wanted_refs; + data->want_obj = want_obj; + data->have_obj = have_obj; + data->haves = haves; + data->shallows = shallows; + data->deepen_not = deepen_not; + packet_writer_init(&data->writer, 1); +} + +static void upload_pack_data_clear(struct upload_pack_data *data) +{ + string_list_clear(&data->wanted_refs, 1); + object_array_clear(&data->want_obj); + object_array_clear(&data->have_obj); + oid_array_clear(&data->haves); + object_array_clear(&data->shallows); + string_list_clear(&data->deepen_not, 0); + list_objects_filter_release(&data->filter_options); +} + static void reset_timeout(void) { alarm(timeout); @@ -1130,62 +1186,6 @@ void upload_pack(struct upload_pack_options *options) list_objects_filter_release(&filter_options); } -struct upload_pack_data { - struct string_list wanted_refs; - struct object_array want_obj; - struct object_array have_obj; - struct oid_array haves; - - struct object_array shallows; - struct string_list deepen_not; - int depth; - timestamp_t deepen_since; - int deepen_rev_list; - int deepen_relative; - - struct list_objects_filter_options filter_options; - - struct packet_writer writer; - - unsigned stateless_rpc : 1; - - unsigned use_thin_pack : 1; - unsigned use_ofs_delta : 1; - unsigned no_progress : 1; - unsigned use_include_tag : 1; - unsigned done : 1; -}; - -static void upload_pack_data_init(struct upload_pack_data *data) -{ - struct string_list wanted_refs = STRING_LIST_INIT_DUP; - struct object_array want_obj = OBJECT_ARRAY_INIT; - struct object_array have_obj = OBJECT_ARRAY_INIT; - struct oid_array haves = OID_ARRAY_INIT; - struct object_array shallows = OBJECT_ARRAY_INIT; - struct string_list deepen_not = STRING_LIST_INIT_DUP; - - memset(data, 0, sizeof(*data)); - data->wanted_refs = wanted_refs; - data->want_obj = want_obj; - data->have_obj = have_obj; - data->haves = haves; - data->shallows = shallows; - data->deepen_not = deepen_not; - packet_writer_init(&data->writer, 1); -} - -static void upload_pack_data_clear(struct upload_pack_data *data) -{ - string_list_clear(&data->wanted_refs, 1); - object_array_clear(&data->want_obj); - object_array_clear(&data->have_obj); - oid_array_clear(&data->haves); - object_array_clear(&data->shallows); - string_list_clear(&data->deepen_not, 0); - list_objects_filter_release(&data->filter_options); -} - static int parse_want(struct packet_writer *writer, const char *line, struct object_array *want_obj) { From patchwork Fri May 15 10:04: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: 11550991 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 1056190 for ; Fri, 15 May 2020 10:05:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED4242074D for ; Fri, 15 May 2020 10:05:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Qqa2AUIm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728164AbgEOKFU (ORCPT ); Fri, 15 May 2020 06:05:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728145AbgEOKFQ (ORCPT ); Fri, 15 May 2020 06:05:16 -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 F1EBDC061A0C for ; Fri, 15 May 2020 03:05:15 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id w64so1985330wmg.4 for ; Fri, 15 May 2020 03:05:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FovOELderClvRbKGKOJm679VE4oHeJYLd6RPTpl9PbM=; b=Qqa2AUImC9RYlnh/6IfoGEXrAHylcpJCkzDmKZA08cP3PqKDViDFYi6AAAHWJv8B3S 1h07SmH1zELcVFZNzE0wfGbwEOAdiJ9M2/OKGSXTpqKfXtd4olAEx67VuI9gaMJ3LInE JjwbuN2uCHNceJlnr2x/5h/INwc16NuUa0bwujyHj6D0FhdCPdZ7AnJxaXFpw2D6m6qT jElYW8UxBRCe8WtFtKVb9WaILk8bI/93lNmvUITnm8Ug/pgyO8fhuTOXMDzHNjRsL65/ 4051aM2B67Y6Qh0WDFt/atiNt8iKqswU0rN7Yx6DnrMQ4DrW/WMmXM9y7VQc1q6l3blU /7Cg== 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=FovOELderClvRbKGKOJm679VE4oHeJYLd6RPTpl9PbM=; b=rsxUmbP1TfLZWV1XqIVH4BS8tjR3oRB1Si4mCB+ITDv+1tnMwp22TcV5wstDpE2P4a XZ3ZthTF49MvDF4Lt2aw7GHwr5CxLm/PHCMPM14gg7oi256wE9jxnTV9kid4+K2w4Ivn VJbkO45wF8mLV6cKfkItI2Zj0nQBIKNoMy12XA5ohWTgeIJXy1a24hSy1DdNTHjZnc4H IsyjDbFUfmOhZydgeo9iQ/mYpjzyxCME75AysmJfg0mAI3E1Wp8bdABYf9yboOpueNWI M7MUdNwjAwiUZLo8w0ttWxyYmSTbv3RoMlonVdFbuIGnVESmzzVqh23JN8ogLk0jqPX+ ti2g== X-Gm-Message-State: AOAM532ThvDFkH1EpaaO9C44pt4IDinvr0YLfVqbCBvsTtG6HseuSzbE HkqTdUS1B+iriysACk0xolQu1LVVVL4= X-Google-Smtp-Source: ABdhPJwdRX7CHykSa8fs7tLIutlks6akxehHxFV7j1FCKbMr4BOUdy26WHC8iwyFz1F9h70HJu7rbw== X-Received: by 2002:a1c:740e:: with SMTP id p14mr3317025wmc.102.1589537114264; Fri, 15 May 2020 03:05:14 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.171]) by smtp.gmail.com with ESMTPSA id m3sm2792326wrn.96.2020.05.15.03.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 03:05: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 Subject: [PATCH 04/13] upload-pack: use 'struct upload_pack_data' in upload_pack() Date: Fri, 15 May 2020 12:04:45 +0200 Message-Id: <20200515100454.14486-5-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.26.2.639.gb7dde20fdf In-Reply-To: <20200515100454.14486-1-chriscool@tuxfamily.org> References: <20200515100454.14486-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 use 'struct upload_pack_data' in upload_pack(). This will make it possible in followup commits to remove a lot of static variables and local variables that have the same name and purpose as fields in 'struct upload_pack_data'. This will also make upload_pack() work in a more similar way as upload_pack_v2(). Signed-off-by: Christian Couder --- upload-pack.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 9aeb3477c9..cb336c5713 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1144,18 +1144,17 @@ static int upload_pack_config(const char *var, const char *value, void *unused) void upload_pack(struct upload_pack_options *options) { struct string_list symref = STRING_LIST_INIT_DUP; - struct object_array want_obj = OBJECT_ARRAY_INIT; struct packet_reader reader; - struct list_objects_filter_options filter_options; + struct upload_pack_data data; stateless_rpc = options->stateless_rpc; timeout = options->timeout; daemon_mode = options->daemon_mode; - memset(&filter_options, 0, sizeof(filter_options)); - git_config(upload_pack_config, NULL); + upload_pack_data_init(&data); + head_ref_namespaced(find_symref, &symref); if (options->advertise_refs || !stateless_rpc) { @@ -1169,21 +1168,24 @@ void upload_pack(struct upload_pack_options *options) for_each_namespaced_ref(check_ref, NULL); } string_list_clear(&symref, 1); - if (options->advertise_refs) - return; - packet_reader_init(&reader, 0, NULL, 0, - PACKET_READ_CHOMP_NEWLINE | - PACKET_READ_DIE_ON_ERR_PACKET); + if (!options->advertise_refs) { + packet_reader_init(&reader, 0, NULL, 0, + PACKET_READ_CHOMP_NEWLINE | + PACKET_READ_DIE_ON_ERR_PACKET); - receive_needs(&reader, &want_obj, &filter_options); - if (want_obj.nr) { - struct object_array have_obj = OBJECT_ARRAY_INIT; - get_common_commits(&reader, &have_obj, &want_obj); - create_pack_file(&have_obj, &want_obj, &filter_options); + receive_needs(&reader, &data.want_obj, &data.filter_options); + if (data.want_obj.nr) { + get_common_commits(&reader, + &data.have_obj, + &data.want_obj); + create_pack_file(&data.have_obj, + &data.want_obj, + &data.filter_options); + } } - list_objects_filter_release(&filter_options); + upload_pack_data_clear(&data); } static int parse_want(struct packet_writer *writer, const char *line, From patchwork Fri May 15 10:04: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: 11550993 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 7E59614C0 for ; Fri, 15 May 2020 10:05:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6716D2074D for ; Fri, 15 May 2020 10:05:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lBjARWVE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728191AbgEOKFW (ORCPT ); Fri, 15 May 2020 06:05:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728151AbgEOKFT (ORCPT ); Fri, 15 May 2020 06:05:19 -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 5119EC05BD09 for ; Fri, 15 May 2020 03:05:17 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id l17so2848050wrr.4 for ; Fri, 15 May 2020 03:05: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=g2XmECCDpN7avLXXM5UDqxaEKa6CbOJoQ4eZmU9tV8o=; b=lBjARWVEvU2t5eA1Uxq7qS90eCBiaBHp6UksnAFEGey7CuZdhI/8YCj1gxtZ5CC9hV KD8XlQZVKoOGyNRvsYZyZ1X0sps0+ND6rGX0oUF8Fal7hoQDWPQkKna90fs/Adg9Z3Xw Y82/PJOtG8PDthOkYymXMQ9Eu4gCZNUI3cD9dexnkKhXIHft/YA2TXjZ1QLXLqYQ/PV2 AW/4s0ZIVghicdPUWc6eM5rnacu4pfhgQ/y0gwurGrrC1eP6wwoshWgbJ8JzawjdEW19 4wkKhiKU8sRUloynwfLeHjGSL16Sj0XGCDTYK+Mf8MOQC+kbdAqq7ZUCpA4GxoGo4C2M 0Cng== 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=g2XmECCDpN7avLXXM5UDqxaEKa6CbOJoQ4eZmU9tV8o=; b=MiL5Xk9hCLZVXqzopC11BgvGy0Inz7LPiFLgRKVWUjnk+4UF6Y90FjYwRwmMUkxNJC FccHOOpsefH0R+7QXK9nlwQp3dA8Alh6eZmyZcTs9P8F8imH+znmT3zGr4kn4ZglaE0i 0MXYot2X0BvD9NvOy1ntCH4z0uYL87WGfUN7r+mOTq2hclJ52uHQ2foVQ2wKhcjAwBRm 3loRud3pnKovdrgTLpc9kf3g+S2e8Xw2OfM/diVeUeit3tFX1Sd3cCOEB788W1U45FWI QOymB8J91DlYmfyFmEpvxT6yLIAmWK+Vok33momgBmfjvBwsPK+4OFe8LW9miKUut6ez Wgjw== X-Gm-Message-State: AOAM533v4HBwGz8plx0/e7IHDgZy9ZXdP63vcFcCHOzkQg2xzjL5zMwi GEck5MFxC0otLtYtDnrX8WCubBi5adk= X-Google-Smtp-Source: ABdhPJws/pEhYpUSYhOqNVrAe859EoHeAomOFI7vUZ6DWvGP/dWBVD07MYw4ZScMIiWTECYaKToXLA== X-Received: by 2002:adf:a118:: with SMTP id o24mr3305114wro.330.1589537115623; Fri, 15 May 2020 03:05:15 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.171]) by smtp.gmail.com with ESMTPSA id m3sm2792326wrn.96.2020.05.15.03.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 03:05: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 Subject: [PATCH 05/13] upload-pack: pass upload_pack_data to get_common_commits() Date: Fri, 15 May 2020 12:04:46 +0200 Message-Id: <20200515100454.14486-6-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.26.2.639.gb7dde20fdf In-Reply-To: <20200515100454.14486-1-chriscool@tuxfamily.org> References: <20200515100454.14486-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 'struct upload_pack_data' to get_common_commits(), so that this function and the functions it calls can use all the fields of that struct in followup commits. Signed-off-by: Christian Couder --- upload-pack.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index cb336c5713..7953a33189 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -414,9 +414,8 @@ static int ok_to_give_up(const struct object_array *have_obj, min_generation); } -static int get_common_commits(struct packet_reader *reader, - struct object_array *have_obj, - struct object_array *want_obj) +static int get_common_commits(struct upload_pack_data *data, + struct packet_reader *reader) { struct object_id oid; char last_hex[GIT_MAX_HEXSZ + 1]; @@ -432,12 +431,14 @@ static int get_common_commits(struct packet_reader *reader, reset_timeout(); if (packet_reader_read(reader) != PACKET_READ_NORMAL) { - if (multi_ack == 2 && got_common - && !got_other && ok_to_give_up(have_obj, want_obj)) { + if (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 (have_obj->nr == 0 || multi_ack) + if (data->have_obj.nr == 0 || multi_ack) packet_write_fmt(1, "NAK\n"); if (no_done && sent_ready) { @@ -451,10 +452,11 @@ static int get_common_commits(struct packet_reader *reader, continue; } if (skip_prefix(reader->line, "have ", &arg)) { - switch (got_oid(arg, &oid, have_obj)) { + switch (got_oid(arg, &oid, &data->have_obj)) { case -1: /* they have what we do not */ got_other = 1; - if (multi_ack && ok_to_give_up(have_obj, want_obj)) { + if (multi_ack + && ok_to_give_up(&data->have_obj, &data->want_obj)) { const char *hex = oid_to_hex(&oid); if (multi_ack == 2) { sent_ready = 1; @@ -470,14 +472,14 @@ static int get_common_commits(struct packet_reader *reader, packet_write_fmt(1, "ACK %s common\n", last_hex); else if (multi_ack) packet_write_fmt(1, "ACK %s continue\n", last_hex); - else if (have_obj->nr == 1) + else if (data->have_obj.nr == 1) packet_write_fmt(1, "ACK %s\n", last_hex); break; } continue; } if (!strcmp(reader->line, "done")) { - if (have_obj->nr > 0) { + if (data->have_obj.nr > 0) { if (multi_ack) packet_write_fmt(1, "ACK %s\n", last_hex); return 0; @@ -1176,9 +1178,7 @@ void upload_pack(struct upload_pack_options *options) receive_needs(&reader, &data.want_obj, &data.filter_options); if (data.want_obj.nr) { - get_common_commits(&reader, - &data.have_obj, - &data.want_obj); + get_common_commits(&data, &reader); create_pack_file(&data.have_obj, &data.want_obj, &data.filter_options); From patchwork Fri May 15 10:04: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: 11550989 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 3720914C0 for ; Fri, 15 May 2020 10:05:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B72D2073E for ; Fri, 15 May 2020 10:05:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PWU2y31p" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728179AbgEOKFU (ORCPT ); Fri, 15 May 2020 06:05:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728128AbgEOKFT (ORCPT ); Fri, 15 May 2020 06:05:19 -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 A3BCEC05BD0A for ; Fri, 15 May 2020 03:05:18 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id w7so2776825wre.13 for ; Fri, 15 May 2020 03:05:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j5bWbdiPefzdp1+8Fhl/fWfUwo6VIAL6w6+ThJxHuyA=; b=PWU2y31p1U3sSAOHilzWBD9L1n02T2/dvHNqmDZRmooYym4la4MgzE1LJxScrcYas4 20e5W7++w7zEqKRHpjvR4c2dRMLvcvuamB/auyWv+iFt50YcM7jfa2YM9HqN34naIi/g 694kfcJGGbhSHN9bhq0OmIRSE2K/LHkI69oyRx5dgEmDrLQl6+tEh91iSCzUiGq9KYhc Dg+Gpht7trpgLwnc7Vr5t61GZC0jMtsdJPIGd0Y0HRfaZDRd1PGbqqujv5MqBz8N1Emf q5d5BKo6ULXtUChI+Dd3MQx6gr/rLyy5GI2v3I8smCFr6HAC2zjrOvDT/9fypDZdRTaI Pgng== 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=j5bWbdiPefzdp1+8Fhl/fWfUwo6VIAL6w6+ThJxHuyA=; b=HrQLCKkCUvzy8g0jgTCP9JW86VYaaPI/dS3Ze+afAaEFTYt+RFH+e6wemHC5w9A+rp 3MldJHVLFSr66D5tLuaDEuPvnNIpvO1Gp58P0DTDY40cxi/IQHH02T5k8hpExVfHJYQI c+7wZjE+wIM1PqCXWSQK3SGepubZQMIOA9NE4dZvhnQcqCBNkkN1uksFsZiZ267AKSOq U85U06M01+XNob7jhsTUG1ldXg8/Sa9yppwx8T0LsiyhC/i5wUr37YMIgw71fA2Gv0B8 6DN68eQo73f+byCGWCeDQlBATY266vG6038QNpd6GLkhlyAv+t9Pfek/eYmT6hgtIajQ R55Q== X-Gm-Message-State: AOAM530fymsLFmKsRjsQmmbaP/EixB5O+TfD5Zz1s93ZaYbkZsRswwrq zx8NxMS9P4UHF3x+/ajV4m5vvIhsG0k= X-Google-Smtp-Source: ABdhPJyKR/8nyeDwI5Ycczh+fubOG6W35HizJKVedtBi5LbxMD1k4qdPPYVnKn2vu7/cJldKykJ0jw== X-Received: by 2002:adf:e783:: with SMTP id n3mr829246wrm.157.1589537116988; Fri, 15 May 2020 03:05:16 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.171]) by smtp.gmail.com with ESMTPSA id m3sm2792326wrn.96.2020.05.15.03.05.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 03:05: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 Subject: [PATCH 06/13] upload-pack: pass upload_pack_data to receive_needs() Date: Fri, 15 May 2020 12:04:47 +0200 Message-Id: <20200515100454.14486-7-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.26.2.639.gb7dde20fdf In-Reply-To: <20200515100454.14486-1-chriscool@tuxfamily.org> References: <20200515100454.14486-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 'struct upload_pack_data' to receive_needs(), so that this function and the functions it calls can use all the fields of that struct in followup commits. Signed-off-by: Christian Couder --- upload-pack.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 7953a33189..94bf9cd088 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -907,9 +907,8 @@ static int process_deepen_not(const char *line, struct string_list *deepen_not, return 0; } -static void receive_needs(struct packet_reader *reader, - struct object_array *want_obj, - struct list_objects_filter_options *filter_options) +static void receive_needs(struct upload_pack_data *data, + struct packet_reader *reader) { struct object_array shallows = OBJECT_ARRAY_INIT; struct string_list deepen_not = STRING_LIST_INIT_DUP; @@ -944,8 +943,8 @@ static void receive_needs(struct packet_reader *reader, if (skip_prefix(reader->line, "filter ", &arg)) { if (!filter_capability_requested) die("git upload-pack: filtering capability not negotiated"); - list_objects_filter_die_if_populated(filter_options); - parse_list_objects_filter(filter_options, arg); + list_objects_filter_die_if_populated(&data->filter_options); + parse_list_objects_filter(&data->filter_options, arg); continue; } @@ -990,7 +989,7 @@ static void receive_needs(struct packet_reader *reader, if (!((allow_unadvertised_object_request & ALLOW_ANY_SHA1) == ALLOW_ANY_SHA1 || is_our_ref(o))) has_non_tip = 1; - add_object_array(o, NULL, want_obj); + add_object_array(o, NULL, &data->want_obj); } } @@ -1002,7 +1001,7 @@ static void receive_needs(struct packet_reader *reader, * by another process that handled the initial request. */ if (has_non_tip) - check_non_tip(want_obj, &writer); + check_non_tip(&data->want_obj, &writer); if (!use_sideband && daemon_mode) no_progress = 1; @@ -1012,7 +1011,7 @@ static void receive_needs(struct packet_reader *reader, if (send_shallow_list(&writer, depth, deepen_rev_list, deepen_since, &deepen_not, deepen_relative, &shallows, - want_obj)) + &data->want_obj)) packet_flush(1); object_array_clear(&shallows); } @@ -1176,7 +1175,7 @@ void upload_pack(struct upload_pack_options *options) PACKET_READ_CHOMP_NEWLINE | PACKET_READ_DIE_ON_ERR_PACKET); - receive_needs(&reader, &data.want_obj, &data.filter_options); + receive_needs(&data, &reader); if (data.want_obj.nr) { get_common_commits(&data, &reader); create_pack_file(&data.have_obj, From patchwork Fri May 15 10:04: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: 11550997 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 9BA4490 for ; Fri, 15 May 2020 10:05:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 848172073E for ; Fri, 15 May 2020 10:05:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fVgQs6rv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728215AbgEOKFZ (ORCPT ); Fri, 15 May 2020 06:05:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728151AbgEOKFX (ORCPT ); Fri, 15 May 2020 06:05:23 -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 A8AFCC05BD0A for ; Fri, 15 May 2020 03:05:22 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id h4so1701936wmb.4 for ; Fri, 15 May 2020 03:05: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=OmRY5N7KfrpjN5YWGcwt+7y/AoCt5pYfFpCIUp6pr9s=; b=fVgQs6rvaYWeVwfMkb3pvKLfuTQNnclwUedGYcLmjbookCb9AEqwmAKWLxjm52J9Qt KpVdl9wTeNoxqJxqRFp7rlnrDHs3adoZjaYEx5Qn4So1MiiYj8DaCI8P1C9gkyjWqi6P jYY616RqLyMopsVaDNSYuMUY01FREw6Jy9B3gbB6j+m4gcHpdmeAO6vS5XhMgvuiN4jS b+pkDBymTCptOI0ZKhdmBWfND4Iib4SCbwudfUJRuUudmDwor7S7xzZ3qNV88WgFpqaY J0cXprHF2yVWV045nHxdn4Rdb7PMt0iBrja7Bc/UO0q5s2ftjcDv18/Zufo8vE6TCSov reYQ== 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=OmRY5N7KfrpjN5YWGcwt+7y/AoCt5pYfFpCIUp6pr9s=; b=G3H6yvDOxLlsf3wHYEJceReETzbzJm/Gv/dD/74nv+n99zzqJTXDx/r889J787hakv /DKC8Zd4rjLI9jDzMn7R+OghKiB9TrqeGWeT1Z7mPvEK4ZepGr2G0dEXhfm+08H9cikm mw58FPq3E9f3twgWgBc6s0cWrDE7ebLy4KzIo00584ufdyig8Ips80sThQhCt2kbJzQg cmliXE22Sl9/U7nQughwvgXDfVlqiM8S1kQM3B51hxE7syhNqUElXaTCAJBnio7tymtb bnwvYEwjs5pvnd/N6ywDM10QnQam86MebC1+YlZmygJV7SxTazunQAmkdDRTTDrdEbWK pWFA== X-Gm-Message-State: AOAM530Cc1LPmrjQUvM+MgplM9KsixnfWfjaBwpitV4OdkVIStoBolng dPDoLS96C9DGQD/VrmYL3TznNkdrtPg= X-Google-Smtp-Source: ABdhPJzTZ093PEsnRadfQezOZ/OpMlXc9RmRJn31AIuIG8KTdQ1x7aIynx1f0WSjgyrJse7FujrkjA== X-Received: by 2002:a1c:9cd4:: with SMTP id f203mr3378622wme.26.1589537118085; Fri, 15 May 2020 03:05:18 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.171]) by smtp.gmail.com with ESMTPSA id m3sm2792326wrn.96.2020.05.15.03.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 03:05:17 -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/13] upload-pack: use upload_pack_data writer in receive_needs() Date: Fri, 15 May 2020 12:04:48 +0200 Message-Id: <20200515100454.14486-8-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.26.2.639.gb7dde20fdf In-Reply-To: <20200515100454.14486-1-chriscool@tuxfamily.org> References: <20200515100454.14486-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 use the 'struct packet_writer writer' field from 'struct upload_pack_data' in receive_needs(), instead of a local 'struct packet_writer writer' variable. Signed-off-by: Christian Couder --- upload-pack.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 94bf9cd088..399ec60ade 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -917,10 +917,8 @@ static void receive_needs(struct upload_pack_data *data, timestamp_t deepen_since = 0; int deepen_rev_list = 0; int deepen_relative = 0; - struct packet_writer writer; shallow_nr = 0; - packet_writer_init(&writer, 1); for (;;) { struct object *o; const char *features; @@ -978,7 +976,7 @@ static void receive_needs(struct upload_pack_data *data, o = parse_object(the_repository, &oid_buf); if (!o) { - packet_writer_error(&writer, + packet_writer_error(&data->writer, "upload-pack: not our ref %s", oid_to_hex(&oid_buf)); die("git upload-pack: not our ref %s", @@ -1001,7 +999,7 @@ static void receive_needs(struct upload_pack_data *data, * by another process that handled the initial request. */ if (has_non_tip) - check_non_tip(&data->want_obj, &writer); + check_non_tip(&data->want_obj, &data->writer); if (!use_sideband && daemon_mode) no_progress = 1; @@ -1009,7 +1007,7 @@ static void receive_needs(struct upload_pack_data *data, if (depth == 0 && !deepen_rev_list && shallows.nr == 0) return; - if (send_shallow_list(&writer, depth, deepen_rev_list, deepen_since, + if (send_shallow_list(&data->writer, depth, deepen_rev_list, deepen_since, &deepen_not, deepen_relative, &shallows, &data->want_obj)) packet_flush(1); From patchwork Fri May 15 10:04: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: 11550995 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 0F80814C0 for ; Fri, 15 May 2020 10:05:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED0C32074D for ; Fri, 15 May 2020 10:05:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O/FfoXH1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728204AbgEOKFX (ORCPT ); Fri, 15 May 2020 06:05:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728128AbgEOKFV (ORCPT ); Fri, 15 May 2020 06:05:21 -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 D5E6AC061A0C for ; Fri, 15 May 2020 03:05:20 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id n5so2015574wmd.0 for ; Fri, 15 May 2020 03:05: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=pR80uivEZOrWUeo4orvhK4n9OcNxsnR4EAIxK7J3saU=; b=O/FfoXH1L94NT8uHTu6hnghd1fmQFL4+UHgOEM7/wF3xACAgme4WkZ+IxCS00Le4db OLHRvFbxYmp0hekp0AvaC7dNUr/OS6wj641qHscHaUUlLSmTq7qXl5XubD1R/L0nlCC8 JDa1ofz2jWHo+tZI1NHxhs8PvotYOOuzEZPb7DG2YQayNdDAcQa5xV6L3IbvWnpOOn5v s2iW1skqmDM65JRJwoI5eW1fyWjqRN9nRvvz1PAlQM00X8R7d23fWzyNn4nWqJSIplf4 OZTpVq9fpxjQ5T94H3lOUAatwV4g56908rmcXniXAuFw3mJ/TtBy1WklRxh+t3omjBAK LPMw== 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=pR80uivEZOrWUeo4orvhK4n9OcNxsnR4EAIxK7J3saU=; b=OclBNjFV7MxcHDuB/sfFckQmznbzVC7LAkmuH4HaNc/LAb5kKKFdSnAXPgtrKa74at BapEfhN4QzJQ+EnclQPoYoxS+0d+G5SZWURSUlhb1d7/QO0WJc7SYkqC18fAIoal43t6 f2741O3z9Hi06RNEoMH/PMhywFPQhzBbddAQIsNedXN9Lkg+xZ9mpwvNF9U+aH8PcaSd clJKjetiDdOp7S4eWNcbLS5Xtf6lMlTODqlX24gVxf7VPRJ1RNcvR/W9r7bVypO/iUs/ 2dlAAxtNPZdx8w/c3aIgCUcGiqlKUHp+q0QufXKoaDqODtXWlzVMbCTYMH+o66r+9579 0wjw== X-Gm-Message-State: AOAM530AVlAvPm1LNN4T2wWGuZhr+bNo1EGwa3mPZQy6Jb3vZ95Z98+3 2M/TBbfh6zAF+vakaP+PEohjvAxtgyk= X-Google-Smtp-Source: ABdhPJyHBxlZLLx2GWHVE2yNrkbCFA3UeZRGssSCu3Iwy8+C6FJm75rSmrPWjZUhVWpMXsfJdRU85A== X-Received: by 2002:a7b:cf25:: with SMTP id m5mr3372531wmg.65.1589537119249; Fri, 15 May 2020 03:05:19 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.171]) by smtp.gmail.com with ESMTPSA id m3sm2792326wrn.96.2020.05.15.03.05.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 03:05: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 Subject: [PATCH 08/13] upload-pack: move symref to upload_pack_data Date: Fri, 15 May 2020 12:04:49 +0200 Message-Id: <20200515100454.14486-9-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.26.2.639.gb7dde20fdf In-Reply-To: <20200515100454.14486-1-chriscool@tuxfamily.org> References: <20200515100454.14486-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, we are passing around that struct to many functions, so let's also pass 'struct string_list symref' around at the same time by moving it from a local variable in upload_pack() into a field of 'struct upload_pack_data'. 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 399ec60ade..c7e35a7fc9 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -73,6 +73,7 @@ static int allow_ref_in_want; static int allow_sideband_all; struct upload_pack_data { + struct string_list symref; struct string_list wanted_refs; struct object_array want_obj; struct object_array have_obj; @@ -100,6 +101,7 @@ struct upload_pack_data { static void upload_pack_data_init(struct upload_pack_data *data) { + struct string_list symref = STRING_LIST_INIT_DUP; struct string_list wanted_refs = STRING_LIST_INIT_DUP; struct object_array want_obj = OBJECT_ARRAY_INIT; struct object_array have_obj = OBJECT_ARRAY_INIT; @@ -108,6 +110,7 @@ static void upload_pack_data_init(struct upload_pack_data *data) struct string_list deepen_not = STRING_LIST_INIT_DUP; memset(data, 0, sizeof(*data)); + data->symref = symref; data->wanted_refs = wanted_refs; data->want_obj = want_obj; data->have_obj = have_obj; @@ -119,6 +122,7 @@ static void upload_pack_data_init(struct upload_pack_data *data) static void upload_pack_data_clear(struct upload_pack_data *data) { + string_list_clear(&data->symref, 1); string_list_clear(&data->wanted_refs, 1); object_array_clear(&data->want_obj); object_array_clear(&data->have_obj); @@ -1142,7 +1146,6 @@ static int upload_pack_config(const char *var, const char *value, void *unused) void upload_pack(struct upload_pack_options *options) { - struct string_list symref = STRING_LIST_INIT_DUP; struct packet_reader reader; struct upload_pack_data data; @@ -1154,19 +1157,18 @@ void upload_pack(struct upload_pack_options *options) upload_pack_data_init(&data); - head_ref_namespaced(find_symref, &symref); + head_ref_namespaced(find_symref, &data.symref); if (options->advertise_refs || !stateless_rpc) { reset_timeout(); - head_ref_namespaced(send_ref, &symref); - for_each_namespaced_ref(send_ref, &symref); + head_ref_namespaced(send_ref, &data.symref); + for_each_namespaced_ref(send_ref, &data.symref); advertise_shallow_grafts(1); packet_flush(1); } else { head_ref_namespaced(check_ref, NULL); for_each_namespaced_ref(check_ref, NULL); } - string_list_clear(&symref, 1); if (!options->advertise_refs) { packet_reader_init(&reader, 0, NULL, 0, From patchwork Fri May 15 10:04: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: 11550999 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 E392414C0 for ; Fri, 15 May 2020 10:05:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB2242073E for ; Fri, 15 May 2020 10:05:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WnWNmSK5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728209AbgEOKFY (ORCPT ); Fri, 15 May 2020 06:05:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728194AbgEOKFW (ORCPT ); Fri, 15 May 2020 06:05:22 -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 F118CC05BD09 for ; Fri, 15 May 2020 03:05:21 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id w64so1985643wmg.4 for ; Fri, 15 May 2020 03:05: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=twgQ2UZz4sfi3eKXcgAhoOu+YLzubvDfZSxV8cgeS8g=; b=WnWNmSK5gk6p7Ol449g3CirpOHcOP1RlLCAnP2+M3cvbwlfudqpNh92LqtC2Ah3NB2 igey+azjmB+QqWvZeJieOHhGDc+82LY1SgHJthzldRmIL5Vpc0O8k5BYpxBKuBPx3LUF 2uv9fqvUZ0YGWk/66c5d+HYj8C4us8UbuEAjaSIBD0tPtjdVLAovRq37scRhaTTBcFvQ Rmd1TOU2v0A4F5LbQ+KDtRQEUZHxVQGFYP9YlmaieGZ7BMuviWLz1MP8Bx23EXrMowyw McTMheyXiBW0J6ebD6zyfpk/PzeiPOq/HHHrSI7/bnT+g2ayiZSDEid3hC9Q7hJpIRNv NYSg== 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=twgQ2UZz4sfi3eKXcgAhoOu+YLzubvDfZSxV8cgeS8g=; b=Gq8vH+1bCQIvJylCp6fJdPo23oG6/aFhyKxgPs0VeFM+N6RJUHLFJ5X84XPKFBGrKM VniL0aehWyBQg9s8rXWrHccp0o2iylGQrFoKt2mCWdamQ8YpxIcNILg9N8bL3CltJcc1 32KQwKejwbs9mixdd9fo8IJ1UQGkey/09eI7B6Lp58MXOltbnKhhwz1HqvAwhKdvo31P jaSPohCbIYOgLMhQVnFFBXg0MT5VEpJvDqwa8uVCumHhGe8quzY6y5aubfTBtQvfSZob CvdtqELQ9+ktWsjIg28ODV0FmQUwr2GyJmsJEIo2XvQCQcjnNiVxreAhZZHtke2LIfHT AroA== X-Gm-Message-State: AOAM532WHWNtYPTPMwLo/o6Iv7essdMupJXWYpTHqygV8ZL/ebKwSS/l JXtXl+ZHZ0b1nJyVJzSa8lVA5QGVS48= X-Google-Smtp-Source: ABdhPJyJa27N3jjNyCFw1fPknZN5OS2VlTQOIUyI0TKVJLZe5qRB+P9NpgJmD7jyJIorJzu+6AeFFQ== X-Received: by 2002:a1c:a3c4:: with SMTP id m187mr3201519wme.50.1589537120357; Fri, 15 May 2020 03:05:20 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.171]) by smtp.gmail.com with ESMTPSA id m3sm2792326wrn.96.2020.05.15.03.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 03:05: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 Subject: [PATCH 09/13] upload-pack: pass upload_pack_data to send_ref() Date: Fri, 15 May 2020 12:04:50 +0200 Message-Id: <20200515100454.14486-10-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.26.2.639.gb7dde20fdf In-Reply-To: <20200515100454.14486-1-chriscool@tuxfamily.org> References: <20200515100454.14486-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 send_ref(), so that this function, and the functions it calls, can use all the fields of the struct in followup commits. Signed-off-by: Christian Couder --- upload-pack.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index c7e35a7fc9..bc259f1713 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1059,6 +1059,7 @@ static int send_ref(const char *refname, const struct object_id *oid, " deepen-relative no-progress include-tag multi_ack_detailed"; const char *refname_nons = strip_namespace(refname); struct object_id peeled; + struct upload_pack_data *data = cb_data; if (mark_our_ref(refname_nons, refname, oid)) return 0; @@ -1066,7 +1067,7 @@ static int send_ref(const char *refname, const struct object_id *oid, if (capabilities) { struct strbuf symref_info = STRBUF_INIT; - format_symref_info(&symref_info, cb_data); + format_symref_info(&symref_info, &data->symref); packet_write_fmt(1, "%s %s%c%s%s%s%s%s%s agent=%s\n", oid_to_hex(oid), refname_nons, 0, capabilities, @@ -1161,8 +1162,8 @@ void upload_pack(struct upload_pack_options *options) if (options->advertise_refs || !stateless_rpc) { reset_timeout(); - head_ref_namespaced(send_ref, &data.symref); - for_each_namespaced_ref(send_ref, &data.symref); + head_ref_namespaced(send_ref, &data); + for_each_namespaced_ref(send_ref, &data); advertise_shallow_grafts(1); packet_flush(1); } else { From patchwork Fri May 15 10:04:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11551007 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 2CD9690 for ; Fri, 15 May 2020 10:05:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 174B72074D for ; Fri, 15 May 2020 10:05:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tk8mWrHf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728245AbgEOKF2 (ORCPT ); Fri, 15 May 2020 06:05:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728196AbgEOKFX (ORCPT ); Fri, 15 May 2020 06:05:23 -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 22EBCC061A0C for ; Fri, 15 May 2020 03:05:23 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id z4so543414wmi.2 for ; Fri, 15 May 2020 03:05: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=82o38QBR6yozcXy267KbHiFIkbot/catexYuNhkYE+E=; b=tk8mWrHf39oOzWmLZXCQLdrYYndu12AF6eHj6tmhvNSWAeIK9ov7jv4jSm2JFcKU8g QX7N5k9KEQzA6hSBWNf93l2VQDASqi4PbHOR+fa/bXX8mRZUXhKumqxM+mwFGS8oiQVW piz8wqcgLBMAutP6PnlSh98jcfDf7oS0BO5y5YWBdEqvS8dQGN9DC4kvn6q87vWYjgzd uvEDxlH5IrmPYxbyt5f++RS9mxqkx0IJO+GKOltUaThfu72w/6ACiA5LsSWikZCiFKvK rCAOirj5PZ4v1cp0gaCS/ajyUbezS46lukg7Lgu3kcCZgxCTL58QDjnDvz3rM4jDi+Yb I7SQ== 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=82o38QBR6yozcXy267KbHiFIkbot/catexYuNhkYE+E=; b=qmjdY0DBJsAq1ezE1deTgltZCntup6aZoWtxWFHxnI7FSc1Cyz5azTnsw1ZIeQ7fIF qF4f/mkHmmTUbrga6rhAlAsM9S34SFyiRs5m/i7sddJ1Y1dk69AV7JfjE9fpy5KNQWIH DiE5rRE4ud8M3iHKsWE9HX2tbtuAf4u5Z0C5c+UajHWxNKISbDlPYhhyTbgVo2xjCgGE wLyfph3XijLQUzRyHwUYwuIsPWNK8XnjyP81jQn8wMLuCbqhD/vSO7yzIBodf00wyMYu AaMDEuXMjEARkBWBPNcNz9lrYN0z5G+ozvwDAz9q2R6LAaBH7yv4Cg1vLWS4I6Yudzko VV2w== X-Gm-Message-State: AOAM531o/+jvaokOvCpPGofGBa0g4FUK+PCTrRgljipWuNBN2jCGSO+P SbKvgGyHm6P95Jdk9tLxK1cQiooMT3E= X-Google-Smtp-Source: ABdhPJwCoTS//3U9uay8uSOK4Y6/uCyeWdSM5Mus7GhqtZITpmG+GOIhSRuxWReDJfF2yqbknMYE+w== X-Received: by 2002:a1c:5502:: with SMTP id j2mr3379040wmb.56.1589537121508; Fri, 15 May 2020 03:05:21 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.171]) by smtp.gmail.com with ESMTPSA id m3sm2792326wrn.96.2020.05.15.03.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 03:05: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 Subject: [PATCH 10/13] upload-pack: pass upload_pack_data to check_non_tip() Date: Fri, 15 May 2020 12:04:51 +0200 Message-Id: <20200515100454.14486-11-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.26.2.639.gb7dde20fdf In-Reply-To: <20200515100454.14486-1-chriscool@tuxfamily.org> References: <20200515100454.14486-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 check_non_tip(), so that this function and the functions it calls, can use all the fields of the struct in followup commits. Signed-off-by: Christian Couder --- upload-pack.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index bc259f1713..680c38cc13 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -654,8 +654,7 @@ static int has_unreachable(struct object_array *src) return 1; } -static void check_non_tip(struct object_array *want_obj, - struct packet_writer *writer) +static void check_non_tip(struct upload_pack_data *data) { int i; @@ -666,16 +665,16 @@ static void check_non_tip(struct object_array *want_obj, */ if (!stateless_rpc && !(allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1)) goto error; - if (!has_unreachable(want_obj)) + if (!has_unreachable(&data->want_obj)) /* All the non-tip ones are ancestors of what we advertised */ return; error: /* Pick one of them (we know there at least is one) */ - for (i = 0; i < want_obj->nr; i++) { - struct object *o = want_obj->objects[i].item; + for (i = 0; i < data->want_obj.nr; i++) { + struct object *o = data->want_obj.objects[i].item; if (!is_our_ref(o)) { - packet_writer_error(writer, + packet_writer_error(&data->writer, "upload-pack: not our ref %s", oid_to_hex(&o->oid)); die("git upload-pack: not our ref %s", @@ -1003,7 +1002,7 @@ static void receive_needs(struct upload_pack_data *data, * by another process that handled the initial request. */ if (has_non_tip) - check_non_tip(&data->want_obj, &data->writer); + check_non_tip(data); if (!use_sideband && daemon_mode) no_progress = 1; From patchwork Fri May 15 10:04:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11551005 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 4A53214C0 for ; Fri, 15 May 2020 10:05:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 324A82073E for ; Fri, 15 May 2020 10:05:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aVDIezmM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728255AbgEOKF3 (ORCPT ); Fri, 15 May 2020 06:05:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728151AbgEOKF0 (ORCPT ); Fri, 15 May 2020 06:05:26 -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 64C96C05BD09 for ; Fri, 15 May 2020 03:05:24 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id f13so1689809wmc.5 for ; Fri, 15 May 2020 03:05:24 -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=friTYmnGhW5bqnhTppOnCfdbrBVFGESA+3rhTEdSCEk=; b=aVDIezmMXrcVCdsvxBX6PnQU7r2FP2YGSVeGxGpws6qScxEsvR1TumEFvChZ1X6j/S XV2O9ZM8KmsgdntD+Azhnmv/JcR2INq1DFQVjUD8R/K8PdPAfxSO0Jba8PF+Q7PPfn8/ YGLgtIrix7U+1S8IS7onzkp9AgSu+VK535lKX8WUjOmMn7dCxDFKgzSxpAxpECSjKhSx 1geEss3y7xCnuSr90cLDPkgktp/E428LRz+4fa/EqJgcj8bkEWsKAwK3of6r/chXBm0r fCSuhPUh7TbggPTAUNy6gxLgKqcNUY6v/T0t1bKQ7BRV76HrZriPtDGUbqeZbYws4ZB+ 5q8A== 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=friTYmnGhW5bqnhTppOnCfdbrBVFGESA+3rhTEdSCEk=; b=CnBOXKlNu+l+CSP4IHwoI3NsXYFkjIsMjQx7u9ebrvqgUg/Fnfg+bA9z019r/zTHWH m+k5OOtb22MIzT8KSApqjzzrM0nD4YAX1aaJWRy62JHs27AoNZL3qJi116oiNu97vYpC e/WiGaaIA2RGx1zNC54W5e9itSpxMUvilrmq9oRR9OAleIlOJE0+QtACD+cFSwUSwNUV blQ2KmYqdsV/sXC6PuzQu318eXE2nr+62uXGuwH0PXpTe1IElwG4NuOL1Ml0D6fMB+nA HxTdJM+tNAuZsyd/63oKzpCIcwQjXvjZZzmG3oz7NSgMuC0A4Zg2ZtCyNuDrszOGgJOx 6LBA== X-Gm-Message-State: AOAM530pui9920Hc/P6/Llsy7FK4tqWqFSfqG2hJfgmhoeoAdNtpptGx SoUQD5MT+f4prI66Juitq6rSXVNAcEE= X-Google-Smtp-Source: ABdhPJyO1kVvQ8QADmqjfBpahBfK5cL1irTx5554SPBRGdcbbXB1JmaCDDuuDsOe9M9HAyAkF8YO4A== X-Received: by 2002:a1c:bbc4:: with SMTP id l187mr3312547wmf.183.1589537122709; Fri, 15 May 2020 03:05:22 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.171]) by smtp.gmail.com with ESMTPSA id m3sm2792326wrn.96.2020.05.15.03.05.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 03:05:22 -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/13] upload-pack: remove static variable 'stateless_rpc' Date: Fri, 15 May 2020 12:04:52 +0200 Message-Id: <20200515100454.14486-12-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.26.2.639.gb7dde20fdf In-Reply-To: <20200515100454.14486-1-chriscool@tuxfamily.org> References: <20200515100454.14486-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 remove the 'stateless_rpc' static variable, as we can now use the field of 'struct upload_pack_data' with the same name instead. Signed-off-by: Christian Couder --- upload-pack.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 680c38cc13..4ac40c5b04 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -63,7 +63,6 @@ static int keepalive = 5; * otherwise maximum packet size (up to 65520 bytes). */ static int use_sideband; -static int stateless_rpc; static const char *pack_objects_hook; static int filter_capability_requested; @@ -449,7 +448,7 @@ static int get_common_commits(struct upload_pack_data *data, packet_write_fmt(1, "ACK %s\n", last_hex); return 0; } - if (stateless_rpc) + if (data->stateless_rpc) exit(0); got_common = 0; got_other = 0; @@ -663,7 +662,8 @@ static void check_non_tip(struct upload_pack_data *data) * uploadpack.allowReachableSHA1InWant, * non-tip requests can never happen. */ - if (!stateless_rpc && !(allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1)) + if (!data->stateless_rpc + && !(allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1)) goto error; if (!has_unreachable(&data->want_obj)) /* All the non-tip ones are ancestors of what we advertised */ @@ -1074,7 +1074,7 @@ static int send_ref(const char *refname, const struct object_id *oid, " allow-tip-sha1-in-want" : "", (allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1) ? " allow-reachable-sha1-in-want" : "", - stateless_rpc ? " no-done" : "", + data->stateless_rpc ? " no-done" : "", symref_info.buf, allow_filter ? " filter" : "", git_user_agent_sanitized()); @@ -1149,7 +1149,6 @@ void upload_pack(struct upload_pack_options *options) struct packet_reader reader; struct upload_pack_data data; - stateless_rpc = options->stateless_rpc; timeout = options->timeout; daemon_mode = options->daemon_mode; @@ -1157,9 +1156,11 @@ void upload_pack(struct upload_pack_options *options) upload_pack_data_init(&data); + data.stateless_rpc = options->stateless_rpc; + head_ref_namespaced(find_symref, &data.symref); - if (options->advertise_refs || !stateless_rpc) { + if (options->advertise_refs || !data.stateless_rpc) { reset_timeout(); head_ref_namespaced(send_ref, &data); for_each_namespaced_ref(send_ref, &data); From patchwork Fri May 15 10:04:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11551001 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 4ABAC90 for ; Fri, 15 May 2020 10:05:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 339E62073E for ; Fri, 15 May 2020 10:05:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DpSAfcwX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728230AbgEOKF1 (ORCPT ); Fri, 15 May 2020 06:05:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728050AbgEOKF0 (ORCPT ); Fri, 15 May 2020 06:05:26 -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 B55F4C061A0C for ; Fri, 15 May 2020 03:05:25 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id f13so1689884wmc.5 for ; Fri, 15 May 2020 03:05: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=6J+bvf2W1Bq5ralxG1MCJLMyYI7YmjMRNa40bnF0DiI=; b=DpSAfcwX7odvJSIDReop3IG1ckLI/WMmvF5fvNFluIPXMNR810mI962bqcCxkNSWat MSR1cEDlAIwwd8zsKHGwC9dTA/kIh1BWYP9QlsHU48fEDV895iaijysNplKCqOzpKlqf 6vgteqMCs0JAjx1XWuOqY2GZIss4JIpXvS4KvgAeiYewJFF3Y/Bjp8Xug8EIlXA/O7T6 6Li/LnGEqFbO7UITZ3Jir2ZEJJTqHowehWevyGpXJOhrWOf/6uHFKjHeK/07+GPXGOsG t+IuwvQGYY1Af9TwxvrC9MbJeXpZIco7QY2RdmqXgAY3df/aIUkELRo5PPjgNiUrulom TrRA== 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=6J+bvf2W1Bq5ralxG1MCJLMyYI7YmjMRNa40bnF0DiI=; b=LVpqqn3Zso5IsvKx1xYO54cC9kHAxna0GEN6xS07xRRYZ6OvQi2Z7jP6p7s2HH7ujI ASNKCiC3IYeaxPVq9mYOeKJ3dbbkdhu5fQr6X3g7fZsVkasu3d2I66ecU0RPTiLyANHm Tv+CtihsWvoSLUxZ++OsiaoFg4k3/hQZl7lrHRGp1qBidRlDePQo0gi8c5LZFcq/TeTU uXkZgJJy918UrP+eDjQ9UuArZmfocgxCkFSiU/hqYWZ8VB6DPnRGKjNLEuVPF8A5pPB7 gnXwnaHJNlkR7ktGGiEbEOcwzUvQrpN3xKpbd9cmsDtpnbATccOM+uszaJjOCljTmPox 27Pg== X-Gm-Message-State: AOAM53372np6okUL6U5YaU2Iel4cdozlV7f9Yu62FInDKt15wqqoLify qCrvVRDhlRyplIHIaWSwb/HwitdWLB4= X-Google-Smtp-Source: ABdhPJz8jP+ljFkDD2iPfrtpei4ABLLQxElhLLisdrrX5yaqCP/Dk6zLwwLQIiKLpYkTrBzZ3D68Ng== X-Received: by 2002:a7b:cf15:: with SMTP id l21mr3188205wmg.172.1589537124012; Fri, 15 May 2020 03:05:24 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.171]) by smtp.gmail.com with ESMTPSA id m3sm2792326wrn.96.2020.05.15.03.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 03:05: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 Subject: [PATCH 12/13] upload-pack: pass upload_pack_data to create_pack_file() Date: Fri, 15 May 2020 12:04:53 +0200 Message-Id: <20200515100454.14486-13-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.26.2.639.gb7dde20fdf In-Reply-To: <20200515100454.14486-1-chriscool@tuxfamily.org> References: <20200515100454.14486-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 create_pack_file(), so that this function, and the function it calls, can use all the fields of the struct. Signed-off-by: Christian Couder --- upload-pack.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 4ac40c5b04..93cf4b1fe5 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -161,9 +161,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data) return 0; } -static void create_pack_file(const struct object_array *have_obj, - const struct object_array *want_obj, - struct list_objects_filter_options *filter_options) +static void create_pack_file(struct upload_pack_data *pack_data) { struct child_process pack_objects = CHILD_PROCESS_INIT; char data[8193], progress[128]; @@ -200,9 +198,9 @@ static void create_pack_file(const struct object_array *have_obj, argv_array_push(&pack_objects.args, "--delta-base-offset"); if (use_include_tag) argv_array_push(&pack_objects.args, "--include-tag"); - if (filter_options->choice) { + if (pack_data->filter_options.choice) { const char *spec = - expand_list_objects_filter_spec(filter_options); + expand_list_objects_filter_spec(&pack_data->filter_options); if (pack_objects.use_shell) { struct strbuf buf = STRBUF_INIT; sq_quote_buf(&buf, spec); @@ -226,13 +224,13 @@ static void create_pack_file(const struct object_array *have_obj, if (shallow_nr) for_each_commit_graft(write_one_shallow, pipe_fd); - for (i = 0; i < want_obj->nr; i++) + for (i = 0; i < pack_data->want_obj.nr; i++) fprintf(pipe_fd, "%s\n", - oid_to_hex(&want_obj->objects[i].item->oid)); + oid_to_hex(&pack_data->want_obj.objects[i].item->oid)); fprintf(pipe_fd, "--not\n"); - for (i = 0; i < have_obj->nr; i++) + for (i = 0; i < pack_data->have_obj.nr; i++) fprintf(pipe_fd, "%s\n", - oid_to_hex(&have_obj->objects[i].item->oid)); + oid_to_hex(&pack_data->have_obj.objects[i].item->oid)); for (i = 0; i < extra_edge_obj.nr; i++) fprintf(pipe_fd, "%s\n", oid_to_hex(&extra_edge_obj.objects[i].item->oid)); @@ -1179,9 +1177,7 @@ void upload_pack(struct upload_pack_options *options) receive_needs(&data, &reader); if (data.want_obj.nr) { get_common_commits(&data, &reader); - create_pack_file(&data.have_obj, - &data.want_obj, - &data.filter_options); + create_pack_file(&data); } } @@ -1525,9 +1521,7 @@ int upload_pack_v2(struct repository *r, struct argv_array *keys, send_shallow_info(&data); packet_writer_write(&data.writer, "packfile\n"); - create_pack_file(&data.have_obj, - &data.want_obj, - &data.filter_options); + create_pack_file(&data); state = FETCH_DONE; break; case FETCH_DONE: From patchwork Fri May 15 10:04:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11551003 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 F391190 for ; Fri, 15 May 2020 10:05:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DAF512074D for ; Fri, 15 May 2020 10:05:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A0iSZVDm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728258AbgEOKFa (ORCPT ); Fri, 15 May 2020 06:05:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728228AbgEOKF1 (ORCPT ); Fri, 15 May 2020 06:05:27 -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 E4550C061A0C for ; Fri, 15 May 2020 03:05:26 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id z72so2000080wmc.2 for ; Fri, 15 May 2020 03:05:26 -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=HfUC+WdGxe2JbHaPxGDUlL77vYVbSqjVQzMoGehgWOg=; b=A0iSZVDmUIshforVvKKKtI1bvv3MiPut72aTR8/SYegoWr3fI1XgZGIQ4lpI5XwY9o AIeDJWfUpx6vzlReH5yJ7FZhQpyCzgAPlb+DaCTIfEA9IcAFePoRxIAkH/kidE7i2VYb bith3jRpOwUcFOOJk9uRY/60jghPjp17J5ttajn2hkH+ZjtvbuzzL9kC9yBV+SNXyh6l rwFdxfoknavrnqR+rI6jDlVtinYNG1B92QJBz2+HTYlXDLlCv30O3helWsTAVRfMPh8I uUBiRlmGIUsNo1fT9olC/zL43Y/zcnjjJzYumtlzu2IEy+HycFOblGQoKvvUArjllc6b S7mw== 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=HfUC+WdGxe2JbHaPxGDUlL77vYVbSqjVQzMoGehgWOg=; b=G//YQSDAJLJqT4q7iQ044pvFtpjWfjgs40prgRZHL1Pi+g/StqL2tikmNPg8EonxiH EAVyAhsps+LlxpZhn4bjq/qbxjDuFzhgw5haJcHsUeB2tDVQSJ5VIi87z+LonkGedinH CVacvYM0zsH11gQRjc4jVAZHWIIQwE8g7VcX9Y75XQ/fIW5IAu9lAG4q6cnZlvqmwqUE vJ+6jXlenRjReWBipJiMA7jiUexHYwtyPNduUuY9Uk5pMJTLNECkm5qaiwTkTkvPjcc0 h6aBN0MvUnTJar/+R6R8bOGleo7jDJ25kuDVZpSReEivytQ5RIeWpQ6FmvEcDOjOhgLC pH0Q== X-Gm-Message-State: AOAM530wMUcFWEZFQQ4R+CAioQ4DXLLYCdWD9QJGt60ZnNaJO5MV1wRU FHHovlfq5j9a/4F5gtIQitKwfIhy4+k= X-Google-Smtp-Source: ABdhPJw6cCxmRm2/6MoxaAQ5ju27aYtHNu1mz1MU2ZEet1nMqyBwvvShaYTtqCv6aM/7qtvaz86DOw== X-Received: by 2002:a1c:dc05:: with SMTP id t5mr3352590wmg.112.1589537125270; Fri, 15 May 2020 03:05:25 -0700 (PDT) Received: from localhost.localdomain ([193.57.121.171]) by smtp.gmail.com with ESMTPSA id m3sm2792326wrn.96.2020.05.15.03.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 03:05:24 -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 13/13] upload-pack: use upload_pack_data fields in receive_needs() Date: Fri, 15 May 2020 12:04:54 +0200 Message-Id: <20200515100454.14486-14-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.26.2.639.gb7dde20fdf In-Reply-To: <20200515100454.14486-1-chriscool@tuxfamily.org> References: <20200515100454.14486-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 use fields from this struct in receive_needs(), instead of local variables with the same name and purpose. Signed-off-by: Christian Couder --- upload-pack.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 93cf4b1fe5..401c9e6c4b 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -911,13 +911,7 @@ static int process_deepen_not(const char *line, struct string_list *deepen_not, static void receive_needs(struct upload_pack_data *data, struct packet_reader *reader) { - struct object_array shallows = OBJECT_ARRAY_INIT; - struct string_list deepen_not = STRING_LIST_INIT_DUP; - int depth = 0; int has_non_tip = 0; - timestamp_t deepen_since = 0; - int deepen_rev_list = 0; - int deepen_relative = 0; shallow_nr = 0; for (;;) { @@ -930,13 +924,13 @@ static void receive_needs(struct upload_pack_data *data, if (packet_reader_read(reader) != PACKET_READ_NORMAL) break; - if (process_shallow(reader->line, &shallows)) + if (process_shallow(reader->line, &data->shallows)) continue; - if (process_deepen(reader->line, &depth)) + if (process_deepen(reader->line, &data->depth)) continue; - if (process_deepen_since(reader->line, &deepen_since, &deepen_rev_list)) + if (process_deepen_since(reader->line, &data->deepen_since, &data->deepen_rev_list)) continue; - if (process_deepen_not(reader->line, &deepen_not, &deepen_rev_list)) + if (process_deepen_not(reader->line, &data->deepen_not, &data->deepen_rev_list)) continue; if (skip_prefix(reader->line, "filter ", &arg)) { @@ -953,7 +947,7 @@ static void receive_needs(struct upload_pack_data *data, "expected to get object ID, not '%s'", reader->line); if (parse_feature_request(features, "deepen-relative")) - deepen_relative = 1; + data->deepen_relative = 1; if (parse_feature_request(features, "multi_ack_detailed")) multi_ack = 2; else if (parse_feature_request(features, "multi_ack")) @@ -1005,14 +999,18 @@ static void receive_needs(struct upload_pack_data *data, if (!use_sideband && daemon_mode) no_progress = 1; - if (depth == 0 && !deepen_rev_list && shallows.nr == 0) + if (data->depth == 0 && !data->deepen_rev_list && data->shallows.nr == 0) return; - if (send_shallow_list(&data->writer, depth, deepen_rev_list, deepen_since, - &deepen_not, deepen_relative, &shallows, + if (send_shallow_list(&data->writer, + data->depth, + data->deepen_rev_list, + data->deepen_since, + &data->deepen_not, + data->deepen_relative, + &data->shallows, &data->want_obj)) packet_flush(1); - object_array_clear(&shallows); } /* return non-zero if the ref is hidden, otherwise 0 */