From patchwork Thu Aug 26 14:05:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12459961 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4D61C4320E for ; Thu, 26 Aug 2021 14:05:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CDE086054E for ; Thu, 26 Aug 2021 14:05:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230343AbhHZOGq (ORCPT ); Thu, 26 Aug 2021 10:06:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242798AbhHZOGp (ORCPT ); Thu, 26 Aug 2021 10:06:45 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A38A0C061757 for ; Thu, 26 Aug 2021 07:05:57 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id z4so5277085wrr.6 for ; Thu, 26 Aug 2021 07:05:57 -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=4tzrIxU5v6V3L1HK6JGmMguPaPGPiU/TLevxFGLgGko=; b=Qs+w0WVcIsBjvAg7pbuzJizeE84Fpg280IHtTQgplf+rZIOvHSYmruOuO3C8o7ZuP9 +1DYRuI3P3dUco72YdG1w8yBZF1bfcUNrDnV+wLQoBDcl9tSOC5NU8E6cF3WZbQmoi0i JlSxh09bkCMB2YlCAE7fDMu7HcbTlCJ1NGXpxasHF2q8D5xW84YUtWh212d+/5YipKin 9bXAUnLZP7A9oxqMRG3VjT9M12WsU5vrSmyPv6mt+jPvIAASY9SI83czejQzvesSDRsv RqNEeSH0MDgir8mKjUnbI40oPAkHHHYuVbDh6TkADuNufXJbaQ4AV+EY7LPCdflTeuvC rMeg== 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=4tzrIxU5v6V3L1HK6JGmMguPaPGPiU/TLevxFGLgGko=; b=hsVgDKAt2U5k5VLOucwVg0dRxW80ZnNxL6aLyp14/+724JVZ7vEpE6z22KVj8d9znZ zAc+Vp6uJJ8JPCSiaWQLKoBAgQ56V7VNvxOEMfFoud8PMXq6+PezG67FMpYWTo9uQPak fGvS9ptyy/r/olnGxxgWYtZYCRZVKb6Pv+p22CXI2dzPBwtRkAA0U5UcE2TQxW5qaajJ e5Xi2oOvnk1TswdAY+7XXOzMcuqOVxO3m7osAZTTXRa9VIMa32X+AplrSuPOgvWOBpJY 3pyXs6m2rOvG7WlToHHW3rvdFPp9Y41j2JRkoikB05RXIlhDvNtSj0fUcVugf0mOptbH UrBQ== X-Gm-Message-State: AOAM5304PJmxrQuoIgTNTBokr4FakDucJUk0QdXHisjswmGcAyOuvSqq aPe2Jip4RfPIWbnKL09msUxD8thh87ygSQ== X-Google-Smtp-Source: ABdhPJx9gPfFq1D4RX8wySn1G4RleC21256yZcyj3a8e/16kH+SxEoswS8wFu9e/Gi87AK7zdVD1YA== X-Received: by 2002:a5d:40c9:: with SMTP id b9mr4180354wrq.212.1629986756048; Thu, 26 Aug 2021 07:05:56 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id k13sm2471987wms.33.2021.08.26.07.05.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 07:05:55 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Emily Shaffer , Derrick Stolee , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 1/5] bundle API: start writing API documentation Date: Thu, 26 Aug 2021 16:05:47 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.733.ga72a4f1c2e1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There are no other API docs in bundle.h, but this is at least a start. We'll add a parameter to this function in a subsequent commit, but let's start by documenting it. The "/**" comment (as opposed to "/*") signifies the start of API documentation. See [1] and bdfdaa4978d (strbuf.h: integrate api-strbuf.txt documentation, 2015-01-16) and 6afbbdda333 (strbuf.h: unify documentation comments beginnings, 2015-01-16) for a discussion of that convention. 1. https://lore.kernel.org/git/874kbeecfu.fsf@evledraar.gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason --- bundle.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bundle.h b/bundle.h index 1927d8cd6a4..84a6df1b65d 100644 --- a/bundle.h +++ b/bundle.h @@ -27,6 +27,13 @@ int create_bundle(struct repository *r, const char *path, int version); int verify_bundle(struct repository *r, struct bundle_header *header, int verbose); #define BUNDLE_VERBOSE 1 + +/** + * Unbundle after reading the header with read_bundle_header(). + * + * We'll invoke "git index-pack --stdin --fix-thin" for you on the + * provided `bundle_fd` from read_bundle_header(). + */ int unbundle(struct repository *r, struct bundle_header *header, int bundle_fd, int flags); int list_bundle_refs(struct bundle_header *header, From patchwork Thu Aug 26 14:05:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12459965 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7577AC432BE for ; Thu, 26 Aug 2021 14:06:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 557D160E0B for ; Thu, 26 Aug 2021 14:06:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242846AbhHZOGt (ORCPT ); Thu, 26 Aug 2021 10:06:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242838AbhHZOGq (ORCPT ); Thu, 26 Aug 2021 10:06:46 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79745C061757 for ; Thu, 26 Aug 2021 07:05:58 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id k20-20020a05600c0b5400b002e87ad6956eso2323217wmr.1 for ; Thu, 26 Aug 2021 07:05:58 -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=bjNUgIYblg+sK68bz8yXT3BAS/9Dv0yaeblduHUUInw=; b=B6Qga7sE+EBtsoo4ljE0i5tf54VuUlquOojTkTqd8VnV4EtimAmizE19kbiQRBBshZ K+S/OomrcGcGBTUHsE13qRl87wf2fLDm2vNotgzWDGvuNjUPdhjMDezRgzrgzcSduO2U U4CSM/tU00Q6jV/0DITfttqRdr6e1aOmMpX5R6YOdiQLp6g27xLmpLcB54lDLUnCMhup O9iOmmlE03f1lUYcEwh9Pp6eny/CP3wuDNrjPNzSzIpXfCr19NoLZ4vo+I5RUo2/IWpO PHKRwxP+IcyFg2HwO6MdNCX8XCVXFvKTI8VTZ4KkROf9n1J7FaQBxTXwX4LR1drSJF7v 7OUA== 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=bjNUgIYblg+sK68bz8yXT3BAS/9Dv0yaeblduHUUInw=; b=KGfTHv/HprBBy9WJaFyP2fKNOSLIEltIGjGqZIP9G05l2yF+k1wNdetIlCy/QjJeVo ursjG82vt3J0ka0vBsJtIjN0C335Lxq9u5xGnC3xLARef4RaG8OQJu8kSKW14+wo0iLD e8PC3DT30PgJAH3JIMKVcdGhliIfF6CswILElWSlfXVBA1cjzXeBQ5C6XgwYxGhMSvkC neMavjwsfKKRl59+4wPLI6V2SO/p+rDDsC5jwhQtoYI3U57XvS2xAYx14UbFI130TJO+ 1zh15oF0iqA0e2JwtuH2f4uq2Y+U42UaB2olU8nqATUR/4MEYxIiLJc9tha/39hsJcSK 8ykQ== X-Gm-Message-State: AOAM531hUssWa0pvKlcYaql7FUTNB8zGvUxawQMekYXjAuWTm2Zxe6ji E3qLO5Ur2gUT34ozzfcPjloQWM3haWPE9A== X-Google-Smtp-Source: ABdhPJwZRAMMxWay48znTn70bOlvP3FjKobGquQetOpk6pE353ZOMuGKMxaNnOSvlPBtZBTD0f+IJg== X-Received: by 2002:a05:600c:a41:: with SMTP id c1mr3775948wmq.109.1629986756771; Thu, 26 Aug 2021 07:05:56 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id k13sm2471987wms.33.2021.08.26.07.05.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 07:05:56 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Emily Shaffer , Derrick Stolee , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 2/5] strvec: add a strvec_pushvec() Date: Thu, 26 Aug 2021 16:05:48 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.733.ga72a4f1c2e1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add a strvec_pushvec() function to concatenate two "struct strvec *" together, and modify code added in 50d89ad6542 (submodule: use argv_array instead of hand-building arrays, 2012-09-01) to use it. In a subsequent commit we'll gain another API user. This could also have been named strvec_concat()[1], but I opted to make its name consistent with the strbuf_addbuf() function instead. We only name these sorts of functions *_concat() in one instance: parse_options_concat(). 1. http://lore.kernel.org/git/30620e13-4509-1905-7644-9962b6adf9c5@gmail.com Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Jeff King --- strvec.c | 8 ++++++++ strvec.h | 7 +++++++ submodule.c | 4 +--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/strvec.c b/strvec.c index 61a76ce6cb9..54ed8427c13 100644 --- a/strvec.c +++ b/strvec.c @@ -56,6 +56,14 @@ void strvec_pushv(struct strvec *array, const char **items) strvec_push(array, *items); } +void strvec_pushvec(struct strvec *array, const struct strvec *items) +{ + int i; + + for (i = 0; i < items->nr; i++) + strvec_push(array, items->v[i]); +} + void strvec_pop(struct strvec *array) { if (!array->nr) diff --git a/strvec.h b/strvec.h index fdcad75b45b..9003bde2b7d 100644 --- a/strvec.h +++ b/strvec.h @@ -62,6 +62,13 @@ void strvec_pushl(struct strvec *, ...); /* Push a null-terminated array of strings onto the end of the array. */ void strvec_pushv(struct strvec *, const char **); +/** + * Push the contents of another "struct strvec *" onto the end of the + * array. Like strvec_pushv(), this is a convenience wrapper that + * calls strvec_push() in a loop. + */ +void strvec_pushvec(struct strvec *, const struct strvec *); + /** * Remove the final element from the array. If there are no * elements in the array, do nothing. diff --git a/submodule.c b/submodule.c index 8e611fe1dbf..84b5f5dc0e0 100644 --- a/submodule.c +++ b/submodule.c @@ -1606,7 +1606,6 @@ int fetch_populated_submodules(struct repository *r, int default_option, int quiet, int max_parallel_jobs) { - int i; struct submodule_parallel_fetch spf = SPF_INIT; spf.r = r; @@ -1622,8 +1621,7 @@ int fetch_populated_submodules(struct repository *r, die(_("index file corrupt")); strvec_push(&spf.args, "fetch"); - for (i = 0; i < options->nr; i++) - strvec_push(&spf.args, options->v[i]); + strvec_pushvec(&spf.args, options); strvec_push(&spf.args, "--recurse-submodules-default"); /* default value, "--submodule-prefix" and its value are added later */ From patchwork Thu Aug 26 14:05:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12459963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D595C432BE for ; Thu, 26 Aug 2021 14:06:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 580046054E for ; Thu, 26 Aug 2021 14:06:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242763AbhHZOGs (ORCPT ); Thu, 26 Aug 2021 10:06:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242841AbhHZOGq (ORCPT ); Thu, 26 Aug 2021 10:06:46 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3714BC0613D9 for ; Thu, 26 Aug 2021 07:05:59 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id u9so5258821wrg.8 for ; Thu, 26 Aug 2021 07:05:59 -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=ps8HRtoNAscl+odIZ94LR++flJGNyECZhOpaNUkHcaM=; b=Fo4Lf//QEP51jZ5oAn2WmJ9re5TjGc/ImCzX1X943OEXU78163DGhFvBVXzPgYwhOK 9TODOCZFqKMCoZx5uhoaQmIjdkGrc38M0CdK+LFmW27rFohvAThZDlzUtIPCCXmCkPuD gRsIiah8l2X8LQOEF0RVYbImt9Xtluubm/l7v12Vbt/QRlE3gxB60mFRq7tu8qsvVr9M kA6A1w3jjB26+djUU8jRleCSgJOJGLSdvvW+29qYL+a99USYDjH9WHtIi9xAGiml/Atr mGB+m0DHb5+3yaPxh4UFEjcUBJHK2MuROUznY/aCg6LZnjEn5FGvriKCA4288mPq8o/K FV9g== 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=ps8HRtoNAscl+odIZ94LR++flJGNyECZhOpaNUkHcaM=; b=HDQ8L+pqc4yj+p4Qnwl3rhXzKm8tPNJUz1TCkAMW/g0Q0OwrvWDCSlKRGNmOou4Gts fXELyqmxc98z2jyrF6A6tGBFJeIGu6w+ZFARbxg3c3nAVWqCZ3V+++wWlDaTWgTDyKxs fH7CPflQF9DoUK3BjJa5+R8bxtUA6p5306rJ1AmHI1NKbS4py1YJKSWZkjpD7Fvzr/3C vq6VJ2gMfnTP6krJ3DZSZJXRk50peBl0F/dCcF707BHuBA8n0pfleG9JUB4TfJEvCpyY nW0vWGaNK9jKaCwbbxOjdTz3TdtfySE7N7keKX5P2LqJAgxvmJQL0NDWFjIKS0QOjfxY CLeg== X-Gm-Message-State: AOAM530spuOCkvpCUcl1VB46TyR1u1vQsAzuVeUgAcuX71C9EHM04caP fc7TMr70+kU2YMMnW560qEvETgovY+PcfA== X-Google-Smtp-Source: ABdhPJzcZg62Fmk+iYOLHo0A4A7Gul1RXgvqa6uCzhXBjo/GHUVCn3f1HzvqkLyx66D70LeI6Er69g== X-Received: by 2002:a5d:674b:: with SMTP id l11mr4181722wrw.357.1629986757618; Thu, 26 Aug 2021 07:05:57 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id k13sm2471987wms.33.2021.08.26.07.05.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 07:05:57 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Emily Shaffer , Derrick Stolee , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 3/5] bundle API: change "flags" to be "extra_index_pack_args" Date: Thu, 26 Aug 2021 16:05:49 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.733.ga72a4f1c2e1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Since the "flags" parameter was added in be042aff24c (Teach progress eye-candy to fetch_refs_from_bundle(), 2011-09-18) there's never been more than the one flag: BUNDLE_VERBOSE. Let's have the only caller who cares about that pass "-v" itself instead through new "extra_index_pack_args" parameter. The flexibility of being able to pass arbitrary arguments to "unbundle" will be used in a subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/bundle.c | 2 +- bundle.c | 14 ++++++++------ bundle.h | 8 ++++++-- transport.c | 6 +++++- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/builtin/bundle.c b/builtin/bundle.c index 053a51bea1b..f9360c32c6c 100644 --- a/builtin/bundle.c +++ b/builtin/bundle.c @@ -177,7 +177,7 @@ static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix) } if (!startup_info->have_repository) die(_("Need a repository to unbundle.")); - ret = !!unbundle(the_repository, &header, bundle_fd, 0) || + ret = !!unbundle(the_repository, &header, bundle_fd, NULL) || list_bundle_refs(&header, argc, argv); bundle_header_release(&header); cleanup: diff --git a/bundle.c b/bundle.c index ab63f402261..10d20bb0c48 100644 --- a/bundle.c +++ b/bundle.c @@ -569,18 +569,20 @@ int create_bundle(struct repository *r, const char *path, } int unbundle(struct repository *r, struct bundle_header *header, - int bundle_fd, int flags) + int bundle_fd, struct strvec *extra_index_pack_args) { - const char *argv_index_pack[] = {"index-pack", - "--fix-thin", "--stdin", NULL, NULL}; struct child_process ip = CHILD_PROCESS_INIT; - if (flags & BUNDLE_VERBOSE) - argv_index_pack[3] = "-v"; + strvec_push(&ip.args, "index-pack"); + strvec_push(&ip.args, "--fix-thin"); + strvec_push(&ip.args, "--stdin"); + if (extra_index_pack_args) { + strvec_pushvec(&ip.args, extra_index_pack_args); + strvec_clear(extra_index_pack_args); + } if (verify_bundle(r, header, 0)) return -1; - ip.argv = argv_index_pack; ip.in = bundle_fd; ip.no_stdout = 1; ip.git_cmd = 1; diff --git a/bundle.h b/bundle.h index 84a6df1b65d..d47a7a3c69c 100644 --- a/bundle.h +++ b/bundle.h @@ -26,16 +26,20 @@ int create_bundle(struct repository *r, const char *path, int argc, const char **argv, struct strvec *pack_options, int version); int verify_bundle(struct repository *r, struct bundle_header *header, int verbose); -#define BUNDLE_VERBOSE 1 /** * Unbundle after reading the header with read_bundle_header(). * * We'll invoke "git index-pack --stdin --fix-thin" for you on the * provided `bundle_fd` from read_bundle_header(). + * + * Provide extra_index_pack_args to pass any extra arguments + * (e.g. "-v" for verbose/progress), NULL otherwise. The provided + * extra_index_pack_args (if any) will be strvec_clear()'d for you + * (like the run-command.h API itself does). */ int unbundle(struct repository *r, struct bundle_header *header, - int bundle_fd, int flags); + int bundle_fd, struct strvec *extra_index_pack_args); int list_bundle_refs(struct bundle_header *header, int argc, const char **argv); diff --git a/transport.c b/transport.c index 17e9629710a..99b2498e5dd 100644 --- a/transport.c +++ b/transport.c @@ -162,12 +162,16 @@ static int fetch_refs_from_bundle(struct transport *transport, int nr_heads, struct ref **to_fetch) { struct bundle_transport_data *data = transport->data; + struct strvec extra_index_pack_args = STRVEC_INIT; int ret; + if (transport->progress) + strvec_push(&extra_index_pack_args, "-v"); + if (!data->get_refs_from_bundle_called) get_refs_from_bundle(transport, 0, NULL); ret = unbundle(the_repository, &data->header, data->fd, - transport->progress ? BUNDLE_VERBOSE : 0); + transport->progress ? &extra_index_pack_args : NULL); transport->hash_algo = data->header.hash_algo; return ret; } From patchwork Thu Aug 26 14:05:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12459967 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA3C9C432BE for ; Thu, 26 Aug 2021 14:06:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6D8A60E0B for ; Thu, 26 Aug 2021 14:06:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242837AbhHZOGx (ORCPT ); Thu, 26 Aug 2021 10:06:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242843AbhHZOGr (ORCPT ); Thu, 26 Aug 2021 10:06:47 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08152C061757 for ; Thu, 26 Aug 2021 07:06:00 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id u16so5293889wrn.5 for ; Thu, 26 Aug 2021 07:05:59 -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=pwXtiWsoBT3/ETQ8XHJLKtZU/HCggU775XJY5RyTI3c=; b=fr5eXCIcDpbBA1Ng8hzxQoBd6edVNR8S10tTqL3/lGCZf02x1JZvo/OvBDBvsZHLOe zNiiK1MBCmx/2rvs1+BQcjF2X2CoKXVqrYb3GUr+/TeICTZWLuVkuelom0AOeiOK0Gsb Qr7cQSSxB2cPNK3hdmfdtZd4U+Ea4HUIfG5wFxIE6ay/6Kc/f0qxrEZCoo2p14tF8qAg oTwVPjvdnmudGgEjiqyJSGbL1oRDyPTxfd1VINLuGSS8Kx2BvQjR+9b+mBSIMB420Vjs CmaVHaWsv1+plliQRhLkb8avwU0xewJtFJbR7dsvMAfGvspUdXsKjNOMV8vgZeZXCPXK eRug== 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=pwXtiWsoBT3/ETQ8XHJLKtZU/HCggU775XJY5RyTI3c=; b=mac3LtTMvhldlH0HjiVoEk+d7HJOdrDUqexEIn+7dF8JViZCMt9X/4mcx/RPU9vc+x NpfiZmA+BAhbP7bTk5adPIY0O3ISspNUkQkZBOVONCSvvA8Iy3lOe62g/5bHrt3keSEZ pwzEvNX0mxC1izJjW4jVoUJCu2cDt1zrNBcYL8H+/AP00c14/4HguWchaAJzRnuB37Aa QVEx+U8OrcwnJwldd9eyTzjaiOPSxxXlxCQ+gYOaLkEKSrPvv769rDNezS6rFx5txiDZ nZVOZ2lwaeNwsLzoqgvFKuM51PVwjmy83SBYQP4VkvM5X/1CPOGca9cCzq/zCRaeki/J tJiw== X-Gm-Message-State: AOAM5335ipPYieZSdFvDqjZQrB65U6hl3vZMY1z1jEhR5x7bY62HHId/ fDhOcRBl7gdmTsao3SgDoO1ISFHqRWC4uQ== X-Google-Smtp-Source: ABdhPJytEOeMI3SWt27LOduc26SMeQD43HuA2wVOftReOt8tT/WJGxCjlO1cSu+Trng95Lb21FmUXQ== X-Received: by 2002:adf:eb83:: with SMTP id t3mr4185765wrn.365.1629986758423; Thu, 26 Aug 2021 07:05:58 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id k13sm2471987wms.33.2021.08.26.07.05.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 07:05:57 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Emily Shaffer , Derrick Stolee , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 4/5] index-pack: add --progress-title option Date: Thu, 26 Aug 2021 16:05:50 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.733.ga72a4f1c2e1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add a --progress-title option to index-pack, when data is piped into index-pack its progress is a proxy for whatever's feeding it data. This option will allow us to set a more relevant progress bar title in "git bundle unbundle", and is also used in my "bundle-uri" RFC patches[1] by a new caller in fetch-pack.c. The code change in cmd_index_pack() won't handle "--progress-title=xyz", only "--progress-title xyz", and the "(i+1)" style (as opposed to "i + 1") is a bit odd. Not using the "--long-option=value" style is inconsistent with existing long options handled by cmd_index_pack(), but makes the code that needs to call it better (two strvec_push(), instead of needing a strvec_pushf()). Since the option is internal-only the inconsistency shouldn't matter. I'm copying the pattern to handle it as-is from the handling of the existing "-o" option in the same function, see 9cf6d3357aa (Add git-index-pack utility, 2005-10-12) for its addition. Eventually we'd like to migrate all of this this to parse_options(), which would make these differences in behavior go away. 1. https://lore.kernel.org/git/RFC-cover-00.13-0000000000-20210805T150534Z-avarab@gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/git-index-pack.txt | 6 ++++++ builtin/index-pack.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/Documentation/git-index-pack.txt b/Documentation/git-index-pack.txt index 7fa74b9e798..1f1e3592251 100644 --- a/Documentation/git-index-pack.txt +++ b/Documentation/git-index-pack.txt @@ -82,6 +82,12 @@ OPTIONS --strict:: Die, if the pack contains broken objects or links. +--progress-title:: + For internal use only. ++ +Set the title of the progress bar. The title is "Receiving objects" by +default and "Indexing objects" when `--stdin` is specified. + --check-self-contained-and-connected:: Die if the pack contains broken links. For internal use only. diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 8336466865c..0841c039ae2 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -122,6 +122,7 @@ static int strict; static int do_fsck_object; static struct fsck_options fsck_options = FSCK_OPTIONS_MISSING_GITMODULES; static int verbose; +static const char *progress_title; static int show_resolving_progress; static int show_stat; static int check_self_contained_and_connected; @@ -1157,6 +1158,7 @@ static void parse_pack_objects(unsigned char *hash) if (verbose) progress = start_progress( + progress_title ? progress_title : from_stdin ? _("Receiving objects") : _("Indexing objects"), nr_objects); for (i = 0; i < nr_objects; i++) { @@ -1806,6 +1808,10 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix) input_len = sizeof(*hdr); } else if (!strcmp(arg, "-v")) { verbose = 1; + } else if (!strcmp(arg, "--progress-title")) { + if (progress_title || (i+1) >= argc) + usage(index_pack_usage); + progress_title = argv[++i]; } else if (!strcmp(arg, "--show-resolving-progress")) { show_resolving_progress = 1; } else if (!strcmp(arg, "--report-end-of-input")) { From patchwork Thu Aug 26 14:05:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12459969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98905C4320E for ; Thu, 26 Aug 2021 14:06:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8294C60E0B for ; Thu, 26 Aug 2021 14:06:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242854AbhHZOG5 (ORCPT ); Thu, 26 Aug 2021 10:06:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242798AbhHZOGs (ORCPT ); Thu, 26 Aug 2021 10:06:48 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C175FC061757 for ; Thu, 26 Aug 2021 07:06:00 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id h13so5321296wrp.1 for ; Thu, 26 Aug 2021 07:06:00 -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=RyAcrN9MRvHtfPfkXyWg6sEvHQJZNU5V/0uNpUlL1vY=; b=Fnt8aSYu/G2IANzIzxWHfQN7k8W8x+4EP53ULBXxspuAMpNR+lN4zJzBDEDajTC52b HqknnGot3rFFFX4Ypc9sfKb4bOuNpW16teudooHqMkR1xeDvxiOEUed3DFGcCS2+eexe S4gnzknGHk/ZAD3/1m7UDkqDDCNVpxnDMbB2ycY8GdeA4J6XWKZXIYEGc/ATcumxciXG ILSOuUSo7gWvvJa4auUoHu44ZW/FraqE6SHUS6vc6c4jS/0zIRnhplU6ZSeGKu8uz8mZ dawKgKtl7HwX9M0GU2egR7revDkMCejS/OuGdzyJ1tUCr7BxufEJEjQjcQG7rbuvQBX7 ymuQ== 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=RyAcrN9MRvHtfPfkXyWg6sEvHQJZNU5V/0uNpUlL1vY=; b=KjFftFkrMMNHrAbC5jAMxGYZkUBZOsPmtHI82Tf3NXr8JL35i2uaJMQVUo46XS18Ws zyn1ZPDgvUYu7IvCkXxHWJG+5tJJq9J4TZmVSkmnJExhaRUjo62g6TAWqcBGiZ8faml0 L6fWdcg4m4q+juSw5ReT8zt6DjRaf9RBir0Ot2+aF1inyN25a03VVg6RUL+6pVcwfXJq NvjdkKuvekNOFtrTotSvm40Xz4dCT7GeW3jMqBOuHY7n0wqTUnLKorQDIwMQz8784duc GS2G26+ssP7dLNUmVj+ByID8AnKom1+miae3eshIXkSkBbCvOoQ57P2KHcds/F2j5KOc pdKw== X-Gm-Message-State: AOAM530jP577mh3gvdwho3tGXuA1MOOO+4aEoMlE38K8w00RahckmEVa VSrYBqQCGJq5WBeWEKFDdoQNZa2OSdYbaw== X-Google-Smtp-Source: ABdhPJzjewECe1uKZnrdiaiP0Zd+NXn2JqqhwDvMyC3++eRtWh+UGOswnW5PSdB+W97K5OpD93O9pg== X-Received: by 2002:a05:6000:1864:: with SMTP id d4mr4415390wri.250.1629986759181; Thu, 26 Aug 2021 07:05:59 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id k13sm2471987wms.33.2021.08.26.07.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 07:05:58 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Emily Shaffer , Derrick Stolee , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 5/5] bundle: show progress on "unbundle" Date: Thu, 26 Aug 2021 16:05:51 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.733.ga72a4f1c2e1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The "unbundle" command added in 2e0afafebd8 (Add git-bundle: move objects and references by archive, 2007-02-22) did not show progress output, even though the underlying API learned how to show progress in be042aff24c (Teach progress eye-candy to fetch_refs_from_bundle(), 2011-09-18). Now we'll show "Unbundling objects" using the new --progress-title option to "git index-pack", to go with its existing "Receiving objects" and "Indexing objects" (which it shows when invoked with "--stdin", and with a pack file, respectively). Unlike "git bundle create" we don't handle "--quiet" here, nor "--all-progress" and "--all-progress-implied". Those are all specific to "create" (and "verify", in the case of "--quiet"). The structure of the existing documentation is a bit unclear, e.g. the documentation for the "--quiet" option added in 79862b6b77c (bundle-create: progress output control, 2019-11-10) only describes how it works for "create", and not for "verify". That and other issues in it should be fixed, but I'd like to avoid untangling that mess right now. Let's just support the standard "--no-progress" implicitly here, and leave cleaning up the general behavior of "git bundle" for a later change. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/git-bundle.txt | 2 +- builtin/bundle.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Documentation/git-bundle.txt b/Documentation/git-bundle.txt index ac0d0038350..71b5ecabd1f 100644 --- a/Documentation/git-bundle.txt +++ b/Documentation/git-bundle.txt @@ -13,7 +13,7 @@ SYNOPSIS [--version=] 'git bundle' verify [-q | --quiet] 'git bundle' list-heads [...] -'git bundle' unbundle [...] +'git bundle' unbundle [--progress] [...] DESCRIPTION ----------- diff --git a/builtin/bundle.c b/builtin/bundle.c index f9360c32c6c..1fbfe280c57 100644 --- a/builtin/bundle.c +++ b/builtin/bundle.c @@ -162,10 +162,15 @@ static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix) struct bundle_header header = BUNDLE_HEADER_INIT; int bundle_fd = -1; int ret; + int progress = isatty(2); + struct option options[] = { + OPT_BOOL(0, "progress", &progress, + N_("show progress meter")), OPT_END() }; char *bundle_file; + struct strvec extra_args = STRVEC_INIT; argc = parse_options_cmd_bundle(argc, argv, prefix, builtin_bundle_unbundle_usage, options, &bundle_file); @@ -177,7 +182,15 @@ static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix) } if (!startup_info->have_repository) die(_("Need a repository to unbundle.")); - ret = !!unbundle(the_repository, &header, bundle_fd, NULL) || + + if (progress) { + strvec_push(&extra_args, "-v"); + strvec_push(&extra_args, "--progress-title"); + strvec_push(&extra_args, _("Unbundling objects")); + } + + ret = !!unbundle(the_repository, &header, bundle_fd, progress ? + &extra_args : NULL) || list_bundle_refs(&header, argc, argv); bundle_header_release(&header); cleanup: