From patchwork Fri Jun 10 02:01:13 2022 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: 12876283 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51A75C433EF for ; Fri, 10 Jun 2022 02:01:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243048AbiFJCBw (ORCPT ); Thu, 9 Jun 2022 22:01:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242173AbiFJCBt (ORCPT ); Thu, 9 Jun 2022 22:01:49 -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 5ACCECE5D8 for ; Thu, 9 Jun 2022 19:01:46 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id c21so1531896wrb.1 for ; Thu, 09 Jun 2022 19:01:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aZm+F2jAqfX+TaU66E5IsHdaEc2h/PR1TlRlEu2HR7c=; b=DnPHlRyGikh7wCJs0TDt8GttB1bnFd6aOXqOrm++iCHX+Bv9hf703rQub5uF+ZhYGQ G5opEkbIMqF+0YJ1MajC6wdHHqQrrSWUCGoejikBAl19XzRvvRNSsevLuy6+hqPWKh41 brJnhWhaxpdZ3gKhpVq4wLtWTqJLmJ8ZUsQwvijTkusAz2F2yROtUY2aXCrDlOOsQzsO mWBg1RuzEmX8G1/ejqETa4oIwD1Me5JP5g+lcwsQKQm5WLEOwzVOz6a3uqRq8H8eUgNt f3AYXWucOoYraJr6yiDMBzND1V+8Mdfd93mQP0mi7tecucnGf2i8n7nReDPxhBfZapm/ efvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aZm+F2jAqfX+TaU66E5IsHdaEc2h/PR1TlRlEu2HR7c=; b=7UJtp7Ksrku3D30B+6syUboKChRn7uPLnHMNhZSSAfsS1QiivpbG3Ziivdfd8+XaWM ZPuZkbEYqOx+e7tHVxg09Mccb95lKoXh1AtsmO+fDbzpoSX77hIEIRK4K+tp5d6EGek1 d8Ih5rbgSY7IfuIsBOGjUbhK3V5s5jzF+I+uGHWX0HDfcnhHbR4aRlE+HVrYwjJAEal5 ZBuA6fsdJPIEGXfPO7FlV38KK5ieRdQzztVXYyZCK3eYMc4TN3nF0PxSnQkUtmMxA3hn hq1K3apTaMlSudddx4w4RJ3L6Hg5T2LTjaFRUB0+CPRM4MoWfSkxg23Un5mL3EwZghxc 0slw== X-Gm-Message-State: AOAM5309U41dDbusKUHW09Myq4b3VUfJ25TTOMcmIb4NH09ksa9DwTY7 Cj5V00nks/p5Ber0/XzN3jVbXxRtjCGy2A== X-Google-Smtp-Source: ABdhPJydEi8Sa0vqXiFUf1g9y3ms64fhViFH1VcSHNvKvDBUQmYBKQ9oBlndqwebCthcZhIKvrK8wg== X-Received: by 2002:adf:eb46:0:b0:210:997:42c with SMTP id u6-20020adfeb46000000b002100997042cmr40946608wrn.555.1654826504609; Thu, 09 Jun 2022 19:01:44 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.01.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:01:44 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 01/20] git-submodule.sh: remove unused sanitize_submodule_env() Date: Fri, 10 Jun 2022 04:01:13 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The sanitize_submodule_env() function was last used in b3c5f5cb048 (submodule: move core cmd_update() logic to C, 2022-03-15), let's remove it. This also allows us to remove clear_local_git_env() from git-sh-setup.sh. That function hasn't been documented in Documentation/git-sh-setup.sh, and since 14111fc4927 (git: submodule honor -c credential.* from command line, 2016-02-29) it had only been used in the sanitize_submodule_env() function being removed here. Signed-off-by: Ævar Arnfjörð Bjarmason --- git-sh-setup.sh | 7 ------- git-submodule.sh | 11 ----------- 2 files changed, 18 deletions(-) diff --git a/git-sh-setup.sh b/git-sh-setup.sh index d92df37e992..ecb60d9e3cb 100644 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -285,13 +285,6 @@ get_author_ident_from_commit () { parse_ident_from_commit author AUTHOR } -# Clear repo-local GIT_* environment variables. Useful when switching to -# another repository (e.g. when entering a submodule). See also the env -# list in git_connect() -clear_local_git_env() { - unset $(git rev-parse --local-env-vars) -} - # Generate a virtual base file for a two-file merge. Uses git apply to # remove lines from $1 that are not in $2, leaving only common lines. create_virtual_base() { diff --git a/git-submodule.sh b/git-submodule.sh index fd0b4a2c947..bc436c4ca47 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -56,17 +56,6 @@ isnumber() n=$(($1 + 0)) 2>/dev/null && test "$n" = "$1" } -# Sanitize the local git environment for use within a submodule. We -# can't simply use clear_local_git_env since we want to preserve some -# of the settings from GIT_CONFIG_PARAMETERS. -sanitize_submodule_env() -{ - save_config=$GIT_CONFIG_PARAMETERS - clear_local_git_env - GIT_CONFIG_PARAMETERS=$save_config - export GIT_CONFIG_PARAMETERS -} - # # Add a new submodule to the working tree, .gitmodules and the index # From patchwork Fri Jun 10 02:01:14 2022 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: 12876285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 563EAC433EF for ; Fri, 10 Jun 2022 02:01:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345642AbiFJCBz (ORCPT ); Thu, 9 Jun 2022 22:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242371AbiFJCBt (ORCPT ); Thu, 9 Jun 2022 22:01:49 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E77BDC5D8D for ; Thu, 9 Jun 2022 19:01:47 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id o8so6798242wro.3 for ; Thu, 09 Jun 2022 19:01:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ChJ0UWGnKWNAzJEGuVJvGlHsRUoBcHgWoK5/26y+PJk=; b=TwVG16mBwv20S0yQZHwVcfLqBJ61i40QuT99lgQcDGe/C6+zl/58//LYvV928I+x78 KD8LoZwzhhqa6ULnlR7A08kxqw7EMPSLUKkY3yA7J5TU0Ehg1klOgO0GLQIB2vErPBvI p7sHGovnl3qqftQix5TS48ZeSKJRA2aJqjQyKYMBZva9Ticsn3Exi0nfOpsg9OSyKyMc h6k/1e3n/LBdbIx3psQHjy1IvoanColv0m8IZqaCOapiVpk3k7tWLLw6MpM6DBiQ2CbG n3+phJ5ilWB5xjVuVGu9ZRp2TJrd4OJUtfpCvjaQwv7FwTRUW0p2F1oWcGxlSihYbAJT 75ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ChJ0UWGnKWNAzJEGuVJvGlHsRUoBcHgWoK5/26y+PJk=; b=zeWRzCHpeVcljBN2Z5W8b9jkruyREKORvmlrzQy8XmXiFSJH6S7q5toznNtsRIxDgp l/oiGuri8WaPI1s/Qr6KAo6fCQL/UaHx+D91R3Ry/UdLNhxvY/hQ89ou5r56v8X2oA8a mKouDSEkxZ/ToFR48Jlvmw/KH8gnAeez/ymcCxhRyyyv8KxF01NlWneRyp0b4NL0fLZu u5afuXeIUX+lMYnsBA1t+W44PUyBbSoez95/J5L2o8V7q4gI8VsouoS+0Oaf3odukp7x Ese+Kk7xxSCLJCOiZ5lWfFYLqsxO9TAd/fjnG1xAmg0KBeosMcBYE56mS9vwWz7v+Maz RSvA== X-Gm-Message-State: AOAM532hYTnwhMKEXQUvFI/Gid3P9F4qh9VCiHy5LUnrKpePV5PTMfm6 WzKpgBhb614Ryksclg5+DQaSUjr88nvWXQ== X-Google-Smtp-Source: ABdhPJxfAKjqiaRx/Gc+VmV4le4hgo7BykU3uVjs1suHqq0BjmYnND6gEUM5QG/lfJ7POsC6eDiGaw== X-Received: by 2002:adf:fd0f:0:b0:210:32d7:4cb5 with SMTP id e15-20020adffd0f000000b0021032d74cb5mr41437194wrr.565.1654826505935; Thu, 09 Jun 2022 19:01:45 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.01.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:01:44 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 02/20] git-submodule.sh: remove unused $prefix variable Date: Fri, 10 Jun 2022 04:01:14 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove the $prefix variable which is never set, and never resulted in an option being passed to our "git submodule--helper". The --recursive-prefix option to "git submodule--helper" is still used, but only when it invokes itself. Signed-off-by: Ævar Arnfjörð Bjarmason --- git-submodule.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index bc436c4ca47..53847bbf6e2 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -41,7 +41,6 @@ files= remote= nofetch= update= -prefix= custom_name= depth= progress= @@ -127,7 +126,7 @@ cmd_add() usage fi - git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper add ${GIT_QUIET:+--quiet} ${force:+--force} ${progress:+"--progress"} ${branch:+--branch "$branch"} ${reference_path:+--reference "$reference_path"} ${dissociate:+--dissociate} ${custom_name:+--name "$custom_name"} ${depth:+"$depth"} -- "$@" + git ${wt_prefix:+-C "$wt_prefix"} submodule--helper add ${GIT_QUIET:+--quiet} ${force:+--force} ${progress:+"--progress"} ${branch:+--branch "$branch"} ${reference_path:+--reference "$reference_path"} ${dissociate:+--dissociate} ${custom_name:+--name "$custom_name"} ${depth:+"$depth"} -- "$@" } # @@ -189,7 +188,7 @@ cmd_init() shift done - git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper init ${GIT_QUIET:+--quiet} -- "$@" + git ${wt_prefix:+-C "$wt_prefix"} submodule--helper init ${GIT_QUIET:+--quiet} -- "$@" } # @@ -346,7 +345,6 @@ cmd_update() ${init:+--init} \ ${nofetch:+--no-fetch} \ ${wt_prefix:+--prefix "$wt_prefix"} \ - ${prefix:+--recursive-prefix "$prefix"} \ ${update:+--update "$update"} \ ${reference:+"$reference"} \ ${dissociate:+"--dissociate"} \ From patchwork Fri Jun 10 02:01:15 2022 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: 12876287 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B36BFC43334 for ; Fri, 10 Jun 2022 02:02:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345854AbiFJCCD (ORCPT ); Thu, 9 Jun 2022 22:02:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242442AbiFJCBu (ORCPT ); Thu, 9 Jun 2022 22:01:50 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FC52C5E66 for ; Thu, 9 Jun 2022 19:01:48 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id k16so34649771wrg.7 for ; Thu, 09 Jun 2022 19:01:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TAbyg0JbTlrDxmih6UvEBUcaeXgJS0dGfj5b2o6l0Rk=; b=gspviPmUuB4vDQyH3B/DJ2z7CovsfP7nLTmDT6EmhDgQcPbGNI/hSrnLxyEuW9saZU j3y1gXJN+/qIO/mfjfaiWjHAxEZ233BcLIp1KNFPuPdzfv+JtZz7hnx8EhUcSFEgwPSS IcGefLXSW2hnA3RVWSvmgR6Voj3h8uaeFZeL2EVGtDC9u/MR0RlQbfE/Vrrmu5m+wQJF J5A3C6TK9p31eWu/5dtn9JIAgmyblDYBygV+XlGlXTDNB0luFbAdW+NSlmjj6l0MmDfw 6g5HW7z+mdYzu3FaMSvJ8fIhLkL6/hSJc6l4YIpuC3UZLhj6foE3DbFtTMCEorrdWjiV X2Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TAbyg0JbTlrDxmih6UvEBUcaeXgJS0dGfj5b2o6l0Rk=; b=HOtEIr/L1sEoH4WoCFxtu1tiyYArIFfdM3Q1wbwQL1PWAszY/IoS6TwXeCcq5D+OCd IP28al7d2fWj9ECrPtpTZ3PtqiVk4eR80YcgaoSq3KRCfQ6v6sDN2nXVNTzCyudC2cbz 9ajSb2+Z84Cf1zKEcsks/oPNZGbLwv40kokm99JG7GMNQde0gvJnxOVrJPBudG8KmNAe TroZpZNL/3w/ioZc47T2M58K68y5wBqFjc9aCF9VxczF2NcDPRJKAB8LSROPAVQ7gknu IPQAwPKEx7d+Lnb5ua6O/ZkOusKGNHs8ckUpSFl/DC0Fkzaom8uUj3ArU/L9TCTpZj/b nQ8g== X-Gm-Message-State: AOAM530LKaSguGhPmt/InuYnnnGR+G7MkGRDxyjBNrpLEGlQ54Wd8GZ1 LaUTuwTqvOV2DisdSooKYyY9NRMGgHV37w== X-Google-Smtp-Source: ABdhPJyjnzKe6xZXC/gARRO7w1Hsx2+mf+ERdG6/I8LVsY141jXyoeqcN8BM7/dXMZjNhErpZtxG8Q== X-Received: by 2002:adf:dc87:0:b0:216:cfca:65d with SMTP id r7-20020adfdc87000000b00216cfca065dmr29455441wrj.316.1654826506881; Thu, 09 Jun 2022 19:01:46 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.01.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:01:46 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 03/20] git-submodule.sh: remove unused --super-prefix logic Date: Fri, 10 Jun 2022 04:01:15 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The "$prefix" variable has not been set since b3c5f5cb048 (submodule: move core cmd_update() logic to C, 2022-03-15), so we'd never pass the --super-prefix option to "git submodule--helper", and can therefore remove the handling of it from builtin/submodule--helper.c as well. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/submodule--helper.c | 53 +++++++++++++++---------------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index c6c2ba1b6dc..70693205764 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -3364,35 +3364,32 @@ static int module_add(int argc, const char **argv, const char *prefix) return 0; } -#define SUPPORT_SUPER_PREFIX (1<<0) - struct cmd_struct { const char *cmd; int (*fn)(int, const char **, const char *); - unsigned option; }; static struct cmd_struct commands[] = { - {"list", module_list, 0}, - {"name", module_name, 0}, - {"clone", module_clone, 0}, - {"add", module_add, SUPPORT_SUPER_PREFIX}, - {"update", module_update, 0}, - {"resolve-relative-url-test", resolve_relative_url_test, 0}, - {"foreach", module_foreach, SUPPORT_SUPER_PREFIX}, - {"init", module_init, SUPPORT_SUPER_PREFIX}, - {"status", module_status, SUPPORT_SUPER_PREFIX}, - {"sync", module_sync, SUPPORT_SUPER_PREFIX}, - {"deinit", module_deinit, 0}, - {"summary", module_summary, SUPPORT_SUPER_PREFIX}, - {"push-check", push_check, 0}, - {"absorb-git-dirs", absorb_git_dirs, SUPPORT_SUPER_PREFIX}, - {"is-active", is_active, 0}, - {"check-name", check_name, 0}, - {"config", module_config, 0}, - {"set-url", module_set_url, 0}, - {"set-branch", module_set_branch, 0}, - {"create-branch", module_create_branch, 0}, + {"list", module_list}, + {"name", module_name}, + {"clone", module_clone}, + {"add", module_add}, + {"update", module_update}, + {"resolve-relative-url-test", resolve_relative_url_test}, + {"foreach", module_foreach}, + {"init", module_init}, + {"status", module_status}, + {"sync", module_sync}, + {"deinit", module_deinit}, + {"summary", module_summary}, + {"push-check", push_check}, + {"absorb-git-dirs", absorb_git_dirs}, + {"is-active", is_active}, + {"check-name", check_name}, + {"config", module_config}, + {"set-url", module_set_url}, + {"set-branch", module_set_branch}, + {"create-branch", module_create_branch}, }; int cmd_submodule__helper(int argc, const char **argv, const char *prefix) @@ -3401,15 +3398,9 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix) if (argc < 2 || !strcmp(argv[1], "-h")) usage("git submodule--helper "); - for (i = 0; i < ARRAY_SIZE(commands); i++) { - if (!strcmp(argv[1], commands[i].cmd)) { - if (get_super_prefix() && - !(commands[i].option & SUPPORT_SUPER_PREFIX)) - die(_("%s doesn't support --super-prefix"), - commands[i].cmd); + for (i = 0; i < ARRAY_SIZE(commands); i++) + if (!strcmp(argv[1], commands[i].cmd)) return commands[i].fn(argc - 1, argv + 1, prefix); - } - } die(_("'%s' is not a valid submodule--helper " "subcommand"), argv[1]); From patchwork Fri Jun 10 02:01:16 2022 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: 12876286 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1DEAC433EF for ; Fri, 10 Jun 2022 02:02:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241068AbiFJCB5 (ORCPT ); Thu, 9 Jun 2022 22:01:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242460AbiFJCBu (ORCPT ); Thu, 9 Jun 2022 22:01:50 -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 D26E4CA3F7 for ; Thu, 9 Jun 2022 19:01:49 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id s1so11523121wra.9 for ; Thu, 09 Jun 2022 19:01:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wxo57WXrbB1s9uw2aXgTIZGpxcgEDIRRjIaQehMuEbo=; b=T+Zq1N9jkt0p9IFUr2w9Isl64DfI8jDh1zub7sGfeNmhwTV2sAPxYLj01n2Ubce3wd Ed2wG1mSuzaUXp6aSuWjenBzQ0RQ8Q98Dv9ictzVKNJV0MI7geJoUjUDzKa8/QaXn7q6 j4yli3IkUWd/CxeJ8Jron7j0x3+cOMp5BbiPE/hGJVP/Uolxu0kgTMMoFb7cNWhAdMCR JoSvwCjxmkNyXNwBm5JoC67MFtAWTp3ww+87+va/M9MLFRFinB175YyUvMTi7MB9P4NP 9eQXfgdfxVsBqT7YoagnKKS4hOUYc5/l7iW/fSgSLCPIcW/q0ocWIT7OK04Hi/kycKuC 8wnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wxo57WXrbB1s9uw2aXgTIZGpxcgEDIRRjIaQehMuEbo=; b=PL+n0ZijQ5eZ6GK3NU0owLQE4lG5os0yt9dtJ6ltt5hT0O7fv81tff7HhcyDRaAQJ5 nXAc9uZKmHfG3HMrtATDaxlf/S14KyeeEukAe2MP6HnP1nFTgSqvXIFRaOt4bPTn9Gz2 EjANw8O+wKqkWNFXhKzg0mfrwLuJ2ypJIGkmf4D8+Rb4p/8pavGJrbQHLzuvrgP4E5gB 8WX6vontENAs4xZvIbKbo3Xq7FPppv5TBOjMCMhnDo1OFMVmY9MVZ88qXKtEwwwbc0zY EXsNEJPDcRjwZfDc37LYtyifHnlavYYXe7Ooo9a/5w4n75kMom/4wo0iPAR2cB0EGK4C X12w== X-Gm-Message-State: AOAM531ZFUAC+znVwrut4DvYtbcq/YeD8Z+BMCDJYQUiqFuno5SoNBty nvirOICccwkop8K43LKDUrAKArIOWV4AlQ== X-Google-Smtp-Source: ABdhPJymVJvaQt8srqdh0Xfa3YFtCLuSvLTPxMmXF12zCj/2/Z0pG2jEIf+SdSQwBcm7ktBXRsnYDQ== X-Received: by 2002:adf:e58c:0:b0:210:2f76:93fc with SMTP id l12-20020adfe58c000000b002102f7693fcmr39306674wrm.573.1654826508049; Thu, 09 Jun 2022 19:01:48 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.01.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:01:47 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 04/20] git-submodule.sh: normalize parsing of "--branch" Date: Fri, 10 Jun 2022 04:01:16 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In 5c08dbbdf1a (git-submodule: fix subcommand parser, 2008-01-15) the "--branch" option was supported as an option to "git submodule" itself, i.e. "git submodule --branch" as a side-effect of its implementation. Then in b57e8119e6e (submodule: teach set-branch subcommand, 2019-02-08) when the "set-branch" subcommand was added the assertion that we shouldn't have "--branch" anywhere except as an argument to "add" and "set-branch" was copy/pasted from the adjacent check for "--cache" added (or rather modified) in 496eeeb19b9 (git-submodule.sh: avoid "test -a/-o ", 2014-06-10). But there's been a logic error in that check, this looked like it should be supporting: git submodule --branch (add | set-branch) [] But due to "||" in the condition (as opposed to "&&" for "--cache") if we have "--branch" here already we'll emit usage, even for "add" and "set-branch". Since nobody's complained about "--branch " not being supported as argument to "git submodule" itself, i.e. we want to support: git submodule (add | set-branch) --branch [] But not the first form noted above. Let's just remove this code, we've never documented "--branch" as a top-level option (unlike "--quiet"), so this looks like it was an accident of the implementation, which we broke v2.22.0, so we also know it must not have been important to anyone. Signed-off-by: Ævar Arnfjörð Bjarmason --- git-submodule.sh | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index 53847bbf6e2..1b0a31b8383 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -574,14 +574,6 @@ do -q|--quiet) GIT_QUIET=1 ;; - -b|--branch) - case "$2" in - '') - usage - ;; - esac - branch="$2"; shift - ;; --cached) cached="$1" ;; @@ -609,12 +601,6 @@ then fi fi -# "-b branch" is accepted only by "add" and "set-branch" -if test -n "$branch" && (test "$command" != add || test "$command" != set-branch) -then - usage -fi - # "--cached" is accepted only by "status" and "summary" if test -n "$cached" && test "$command" != status && test "$command" != summary then From patchwork Fri Jun 10 02:01:17 2022 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: 12876288 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98930C43334 for ; Fri, 10 Jun 2022 02:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237390AbiFJCCK (ORCPT ); Thu, 9 Jun 2022 22:02:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242557AbiFJCBv (ORCPT ); Thu, 9 Jun 2022 22:01:51 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E073D18360 for ; Thu, 9 Jun 2022 19:01:50 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id k19so34625373wrd.8 for ; Thu, 09 Jun 2022 19:01:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SWCDf5jIVJYzwbGqgU48nEU444oCC3CpSqOR4EuHxoA=; b=IZm0GseT7F1OWnRzRE6QBEBc5ffzxNFRugIBczUQHaRJeD8HVvfLcFzKoyzo7yNck8 QgPoN/bSyHHENdBADfdNWUh7TX5pi8Ke9AuNLnu+BHQlWwQ+BF5sVjy2QhmdQFSDcjis pjHxkzDNJm5LFcx4b6NjGBLYPa/XNul97atWGZft1oifzGSVmxkyAicMudjKwTB5vpYs g39EM71y15uAe4gEKS5KY2Lvdg5xx337lSky4s61686HBQ4JRXx25Ei39CD8lRG9b/hV +LjS2QK7M45qi+Jot1MllWTQevdxd3KiTp0up/40LC33l1Db+pfTSL8CkQoaKYkKLlYU GZ9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SWCDf5jIVJYzwbGqgU48nEU444oCC3CpSqOR4EuHxoA=; b=SNB4L31H7etzsitIRXiJTHMGOrTaJj7z6JtR3V1TB48NCZnznHOLKtGDiiPAOdvQP6 veebvmid9Xwr+xbHvHEog9LOxsS2Ih4tH1E553BaKBQcC6I/lC7M+E7TNd5vqNqkdMnm Ydn6Fa09g1c3eaV7mi+ysTQS8QCl2JVxQvUoD/9Yjo+z6pLpv9PGNxULm8buWnpD3QLA JGEjWMkMEpl7W7cuIUwQ3j6kZ/jJRTjBABJbsCXWKRjVw9Y/i2ptrUz3Ci3BKbFxKEa/ OwwIdlhTDODItzjFcZrvM232cuPElxKpByq+tIezYb2YBLQqaW29iRPijQAltQvehcgm Vx7g== X-Gm-Message-State: AOAM533/9FKyTpCO/JcD3I8vUf12qCQvFScIr7RQfzTerPWceHTgz6qe 4BgNah9Zmkg1OxPJzIcRkRxBtm44+pRQEw== X-Google-Smtp-Source: ABdhPJyCGHf5F3tI6hVO9fEItDUO/m8QJ72vVramToMxcCsidE//MysjtpU3z/+0+3q5sl3S7/OV2g== X-Received: by 2002:a5d:584c:0:b0:218:4e98:770a with SMTP id i12-20020a5d584c000000b002184e98770amr17082092wrf.271.1654826509165; Thu, 09 Jun 2022 19:01:49 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:01:48 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 05/20] git-submodule.sh: normalize parsing of --cached Date: Fri, 10 Jun 2022 04:01:17 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove the assignment of "$1" to the "$cached" variable. As seen in the initial implementation in 70c7ac22de6 (Add git-submodule command, 2007-05-26) we only need to keep track of if we've seen the --cached option. In 28f9af5d25e (git-submodule summary: code framework, 2008-03-11) "$1" was assigned to it, but there was no reason to do so. Let's undo that. Signed-off-by: Ævar Arnfjörð Bjarmason --- git-submodule.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index 1b0a31b8383..20fc1b620fa 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -446,7 +446,7 @@ cmd_summary() { do case "$1" in --cached) - cached="$1" + cached=1 ;; --files) files="$1" @@ -575,7 +575,7 @@ do GIT_QUIET=1 ;; --cached) - cached="$1" + cached=1 ;; --) break From patchwork Fri Jun 10 02:01:18 2022 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: 12876289 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5771EC43334 for ; Fri, 10 Jun 2022 02:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345879AbiFJCCO (ORCPT ); Thu, 9 Jun 2022 22:02:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243263AbiFJCBw (ORCPT ); Thu, 9 Jun 2022 22:01:52 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09189712C3 for ; Thu, 9 Jun 2022 19:01:52 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id k16so34649882wrg.7 for ; Thu, 09 Jun 2022 19:01:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=idPxVm3MrWX38t7tUL3/ybXujWginnzzFX6suHt0nOw=; b=e8lu9C6wEhKFPPQ3iiXQO8g+CUTWq+EQ3e7yOJKpOszDwrMxqhn0ZQyqqZJ2w2E/N+ YU20XB1r2xnGrwZbXfid0Rov8vW2ScpJIzFh46hwUVBBeU86OB5sGD/dwr7eY+4jbb3s mwhK6JDGj6zfumxLX/OYWPGwk+Om2rN9ylRgMxw9CyWXbx1P5TQGPH+1VK1r/lqVX50m vVQnlm49XDRImqkFs/SQJ0BSKYVIUelYjpiIPaOhrahcLnTLaMuxCsW/oHCQosxLfouN BREuNzsyZu3tvwyDvK2erWjkAwmmHuKqzleO5YNKLhzrVXGaBO0t6U9R6v1IkcURWym9 qpDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=idPxVm3MrWX38t7tUL3/ybXujWginnzzFX6suHt0nOw=; b=d5ZUrOccLLGPpNrFdpQvck3virislgxN1GoMsCPscIwCz5UHRVz6WEiNrpac3C0w5Y kEMEMeVy2r85OnpnhDveOn17SnMd8Ax85YlBwa9IjDk/zAcG6UNCovaaussvdO2JLRP6 cAIkf2ZEc2XNjj76g1U2ul4wr/tQ0O7RgQcp1vx1RE0temN5oBx8J7VmDxblVLv2hrXo cQQ6/vECq1P2QB8FZwyV8lNpJMjQgIYKB32/NgFFCfmz5HT1jOqSZ9UzZdLqk7thhNFv m5oksJeZP49akP/NvBy11iVt3fyULwX0J7RhWVMwNj3ld6G6ZPilUt3lEP2sERnGGVfu I6Uw== X-Gm-Message-State: AOAM531bQq2kLs3Iqgoeqr24k4jUwCEAic3ta1UhPihakquhcmadKzoU t2bEQcGQDP5eVzykzZxSVV1rFsSWaDPCYA== X-Google-Smtp-Source: ABdhPJzJgbsdEgF2vO6aj5pSAXM+T8NjJY62n8t+ygEU5502phT08Tsi76QfxpcyUKXlYktHE4Vqpg== X-Received: by 2002:a5d:67c8:0:b0:20f:fcae:57f8 with SMTP id n8-20020a5d67c8000000b0020ffcae57f8mr24375616wrw.262.1654826510314; Thu, 09 Jun 2022 19:01:50 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.01.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:01:49 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 06/20] submodule--helper: rename "absorb-git-dirs" to "absorbgitdirs" Date: Fri, 10 Jun 2022 04:01:18 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Rename the "absorb-git-dirs" subcommand to "absorbgitdirs", which is what the "git submodule" command itself has called it since the subcommand was implemented in f6f85861400 (submodule: add absorb-git-dir function, 2016-12-12). Having these two be different will make it more tedious to dispatch to "git submodule--helper" directly, so let's get rid of this needless inconsistency. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/submodule--helper.c | 4 ++-- git-submodule.sh | 2 +- submodule.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 70693205764..8df1541baf8 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2784,7 +2784,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix) }; const char *const git_submodule_helper_usage[] = { - N_("git submodule--helper absorb-git-dirs [] [...]"), + N_("git submodule--helper absorbgitdirs [] [...]"), NULL }; @@ -3383,7 +3383,7 @@ static struct cmd_struct commands[] = { {"deinit", module_deinit}, {"summary", module_summary}, {"push-check", push_check}, - {"absorb-git-dirs", absorb_git_dirs}, + {"absorbgitdirs", absorb_git_dirs}, {"is-active", is_active}, {"check-name", check_name}, {"config", module_config}, diff --git a/git-submodule.sh b/git-submodule.sh index 20fc1b620fa..70258eaf38e 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -556,7 +556,7 @@ cmd_sync() cmd_absorbgitdirs() { - git submodule--helper absorb-git-dirs --prefix "$wt_prefix" "$@" + git submodule--helper absorbgitdirs --prefix "$wt_prefix" "$@" } # This loop parses the command line arguments to find the diff --git a/submodule.c b/submodule.c index 7923e951e1c..9129cd564c8 100644 --- a/submodule.c +++ b/submodule.c @@ -2374,7 +2374,7 @@ void absorb_git_dir_into_superproject(const char *path, cp.no_stdin = 1; strvec_pushl(&cp.args, "--super-prefix", sb.buf, "submodule--helper", - "absorb-git-dirs", NULL); + "absorbgitdirs", NULL); prepare_submodule_repo_env(&cp.env_array); if (run_command(&cp)) die(_("could not recurse into submodule '%s'"), path); From patchwork Fri Jun 10 02:01:19 2022 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: 12876290 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 380AFC433EF for ; Fri, 10 Jun 2022 02:02:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345956AbiFJCCS (ORCPT ); Thu, 9 Jun 2022 22:02:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242173AbiFJCBx (ORCPT ); Thu, 9 Jun 2022 22:01:53 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3C4C18360 for ; Thu, 9 Jun 2022 19:01:52 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id k19so34625439wrd.8 for ; Thu, 09 Jun 2022 19:01:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XGNmSpSpfSDkLWTSy2n/vhwP9r9FFd+nv1nUtVBWVLY=; b=XKURAhSdIhIo5Pd0o8wQdW4f9/eGWIfn2gRnxpH+TjgcM6OZaYRjUsS9ecaG3wncr2 +RSAodctTdITziVCkG8mz+qD3Cubub/kNbC4AEjJgQ+7uPldsF/PpiMHHkHw+nJSqnYG dVbKUnsRnuBZrh6+kzwWzICP7gY318PluPPygqsrYjJKpEjCOUhTzw6EmxQAJu2bBMRs qRcPnEXsoM0c2VQlRzSrM/+L3EChguE9rl7TCaS6cUZ+Rvq3eEFlUY3OeFhW0P47zHQy uV25oEWEDOKv64IOeiQam6ujYS3tLhnYq2VDvVStmDT4iXCGIAVqRaeoVpwnozF5A3df 6K/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XGNmSpSpfSDkLWTSy2n/vhwP9r9FFd+nv1nUtVBWVLY=; b=MLgJyb0TBFbUqpSLKlv6dP7FmG3RlorQVimxDj3uZBN1SxwIrCucM2Y7QQLb+q9480 JCfX2ntlCiFfFTIWZKMua4wRtYeiP8wul5UZXnuAiRcSeK/WRaiAADKoribEh2BDfpuR 5FoaqttE/tT1HjVhTN9uXvkSqvM8x2KoAZzcO79f4akXPdi6BdoxUPbQUW5zCpsqN8qW F2ZeMCj2FPtyxvTDWNdgmobFZA6xj0MXIVGIrqlVQbeGyLIxjRvGFv35E8XrsasJWT/t BWjfZqWLJgRdce0xsQITbYDyzVx+q0g/UjPE0aCZVnYENK086oFZmTq4iBUz/sLqRBJG NwMg== X-Gm-Message-State: AOAM5313NEKFzPQL3rZZqH/zSTY0aGXnlwnbODH8ggMZBEyx4PK3qNix YNwaUbigEfTbdglffSEBNhOqa0d4m6YStA== X-Google-Smtp-Source: ABdhPJz7v7EbmrYyGoqir9A0vYe9zIzW97fJkzKjUZeqUKoO3Qnt2QZ7d5GUBEhcbtSfcZoA/3cKGg== X-Received: by 2002:a05:6000:1847:b0:218:4336:5590 with SMTP id c7-20020a056000184700b0021843365590mr22980120wri.511.1654826511174; Thu, 09 Jun 2022 19:01:51 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.01.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:01:50 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 07/20] git-submodule.sh: create a "case" dispatch statement Date: Fri, 10 Jun 2022 04:01:19 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Create a "case/esac" dispatch statement at the end of git-submodule.sh and move the contents of the trivial cmd_absorbgitdirs() function to it. This template will be expanded on in subsequent commits, but for now we're moving the trivial "git submodule absorb-git-dirs" to it. Signed-off-by: Ævar Arnfjörð Bjarmason --- git-submodule.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index 70258eaf38e..fb13f818c63 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -554,11 +554,6 @@ cmd_sync() git ${wt_prefix:+-C "$wt_prefix"} submodule--helper sync ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- "$@" } -cmd_absorbgitdirs() -{ - git submodule--helper absorbgitdirs --prefix "$wt_prefix" "$@" -} - # This loop parses the command line arguments to find the # subcommand name to dispatch. Parsing of the subcommand specific # options are primarily done by the subcommand implementations. @@ -607,4 +602,11 @@ then usage fi -"cmd_$(echo $command | sed -e s/-/_/g)" "$@" +case "$command" in +absorbgitdirs) + git submodule--helper "$command" --prefix "$wt_prefix" "$@" + ;; +*) + "cmd_$(echo $command | sed -e s/-/_/g)" "$@" + ;; +esac From patchwork Fri Jun 10 02:01:20 2022 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: 12876292 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B726C433EF for ; Fri, 10 Jun 2022 02:02:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345885AbiFJCCX (ORCPT ); Thu, 9 Jun 2022 22:02:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244188AbiFJCBz (ORCPT ); Thu, 9 Jun 2022 22:01:55 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D51296D1B6 for ; Thu, 9 Jun 2022 19:01:53 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id x17so34640535wrg.6 for ; Thu, 09 Jun 2022 19:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yuiohgOZJcJpB/4P2Kb33rwOlO2lK/7Zha5CpV6bUKw=; b=JslQr7Ke5tLvjdsvEzzcUXqn5CuwckPdHuY4obH1xgQoAP0tKByL40zP/yykhr9oxb TycAwr+w6XFytlh9lpzWUN0AAS+OvXYZwkjclq0bEP/CHYo8J+VD/hfotO0dwEheTNLS jVObdLCW9VAA6JF0tbUYYBMPnr0shSxtT4w1QZtUnuqhfSrQmJJ3JycMr1MmJpZsVF/M EVgizzLS6k8GtTGk3kHQy8HyQ0Y570v/9j8LsknQJ5ePpgV4u29Hyg/qw/rx+0iQcSvD oX/aX1BFZPzbWZZtD80DQgvgZmG3Q54OOuPAouszdkw+28XBIpsSEHq8XyMcNRjnQisu /nFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yuiohgOZJcJpB/4P2Kb33rwOlO2lK/7Zha5CpV6bUKw=; b=h/Rz5fgXEO0aGPmBKV3sPjABptCV73vJjKTsrb/1cCHuLj0KAD/xg/yUJCdKo5tDCK GWq5GHC1UxMD3zQDG22j8KsSPyGJPlYLa+6J4/mba1Ys3j316Q8Y4XuaCUZEUUptpLtS qFFHFoBB8SzsS4mJD6nG9G0NSgmXdMe60Q4hoIIcdzcDCSSGwtMR3pspYOlYAu816Pik qAS6MbrAdrulatZdUc1+m2BkgBfY1QrNVVlNLGXVZhvlqJHyMI6Ffb8pJtdX1oZdjEAx iwurZWGnz51h1GTv/hK/2V2WL6XnKqrro3CLa/wcJB2ZplnBzvzeLM2zgW1IneIp8W2g V0Mw== X-Gm-Message-State: AOAM530J/le/RWf/UdHs6oSlTYE9Uypx/ay6/zxgDfCFNgjfu3HxLZjh jcYYj/Tw+LhpOMFl5Cjzloy71PbEEl7Oww== X-Google-Smtp-Source: ABdhPJzOyR14Vuv/+TBSuDClxYSgsVoMU8WJV593NWN3CExYBzekHRigbm4bKhQhGrbJl49q687O+g== X-Received: by 2002:adf:f14b:0:b0:213:b98e:c0df with SMTP id y11-20020adff14b000000b00213b98ec0dfmr37109230wro.79.1654826512088; Thu, 09 Jun 2022 19:01:52 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.01.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:01:51 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 08/20] submodule--helper: pretend to be "git submodule" in "-h" output Date: Fri, 10 Jun 2022 04:01:20 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the usage output for "git submodule--helper" so that it will pretend to be named "git submodule". This will allow us to dispatch further into "git submodule--helper" from git-submodule.sh while emitting the correct usage output. This fixes a bug that's been there ever since "git submodule absorbgitdirs" was added in f6f85861400 (submodule: add absorb-git-dir function, 2016-12-12). Before this we'd emit e.g. this on invalid usage: $ git submodule absorbgitdirs --blah error: unknown option `blah' usage: git submodule--helper absorbgitdirs [] [...] Now we'll emit the same, except that the usage line is now referring to the correct command run by the user: usage: git submodule absorbgitdirs [] [...] [.. same usage output ...] Note that in the case of "status", "deinit" and "update" we were already referring to ourselves as "git submodule" in builtin/submodule--helper.c. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/submodule--helper.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 8df1541baf8..3173295ed8e 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -286,7 +286,7 @@ static int module_list(int argc, const char **argv, const char *prefix) }; const char *const git_submodule_helper_usage[] = { - N_("git submodule--helper list [--prefix=] [...]"), + N_("git submodule list [--prefix=] [...]"), NULL }; @@ -444,7 +444,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix) }; const char *const git_submodule_helper_usage[] = { - N_("git submodule--helper foreach [--quiet] [--recursive] [--] "), + N_("git submodule foreach [--quiet] [--recursive] [--] "), NULL }; @@ -582,7 +582,7 @@ static int module_init(int argc, const char **argv, const char *prefix) }; const char *const git_submodule_helper_usage[] = { - N_("git submodule--helper init [] []"), + N_("git submodule init [] []"), NULL }; @@ -786,7 +786,7 @@ static int module_name(int argc, const char **argv, const char *prefix) const struct submodule *sub; if (argc != 2) - usage(_("git submodule--helper name ")); + usage(_("git submodule name ")); sub = submodule_from_path(the_repository, null_oid(), argv[1]); @@ -1185,7 +1185,7 @@ static int module_summary(int argc, const char **argv, const char *prefix) }; const char *const git_submodule_helper_usage[] = { - N_("git submodule--helper summary [] [] [--] []"), + N_("git submodule summary [] [] [--] []"), NULL }; @@ -1349,7 +1349,7 @@ static int module_sync(int argc, const char **argv, const char *prefix) }; const char *const git_submodule_helper_usage[] = { - N_("git submodule--helper sync [--quiet] [--recursive] []"), + N_("git submodule sync [--quiet] [--recursive] []"), NULL }; @@ -1789,7 +1789,7 @@ static int module_clone(int argc, const char **argv, const char *prefix) }; const char *const git_submodule_helper_usage[] = { - N_("git submodule--helper clone [--prefix=] [--quiet] " + N_("git submodule clone [--prefix=] [--quiet] " "[--reference ] [--name ] [--depth ] " "[--single-branch] [--filter ] " "--url --path "), @@ -2784,7 +2784,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix) }; const char *const git_submodule_helper_usage[] = { - N_("git submodule--helper absorbgitdirs [] [...]"), + N_("git submodule absorbgitdirs [] [...]"), NULL }; @@ -2848,9 +2848,9 @@ static int module_config(int argc, const char **argv, const char *prefix) OPT_END() }; const char *const git_submodule_helper_usage[] = { - N_("git submodule--helper config []"), - N_("git submodule--helper config --unset "), - "git submodule--helper config --check-writeable", + N_("git submodule config []"), + N_("git submodule config --unset "), + "git submodule config --check-writeable", NULL }; @@ -2889,7 +2889,7 @@ static int module_set_url(int argc, const char **argv, const char *prefix) OPT_END() }; const char *const usage[] = { - N_("git submodule--helper set-url [--quiet] "), + N_("git submodule set-url [--quiet] "), NULL }; @@ -2928,8 +2928,8 @@ static int module_set_branch(int argc, const char **argv, const char *prefix) OPT_END() }; const char *const usage[] = { - N_("git submodule--helper set-branch [-q|--quiet] (-d|--default) "), - N_("git submodule--helper set-branch [-q|--quiet] (-b|--branch) "), + N_("git submodule set-branch [-q|--quiet] (-d|--default) "), + N_("git submodule set-branch [-q|--quiet] (-b|--branch) "), NULL }; @@ -2970,7 +2970,7 @@ static int module_create_branch(int argc, const char **argv, const char *prefix) OPT_END() }; const char *const usage[] = { - N_("git submodule--helper create-branch [-f|--force] [--create-reflog] [-q|--quiet] [-t|--track] [-n|--dry-run] "), + N_("git submodule create-branch [-f|--force] [--create-reflog] [-q|--quiet] [-t|--track] [-n|--dry-run] "), NULL }; @@ -3273,7 +3273,7 @@ static int module_add(int argc, const char **argv, const char *prefix) }; const char *const usage[] = { - N_("git submodule--helper add [] [--] []"), + N_("git submodule add [] [--] []"), NULL }; From patchwork Fri Jun 10 02:01:21 2022 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: 12876291 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2303EC433EF for ; Fri, 10 Jun 2022 02:02:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345792AbiFJCCU (ORCPT ); Thu, 9 Jun 2022 22:02:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345550AbiFJCBz (ORCPT ); Thu, 9 Jun 2022 22:01:55 -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 5FA7718360 for ; Thu, 9 Jun 2022 19:01:54 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id s1so11523121wra.9 for ; Thu, 09 Jun 2022 19:01:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PH0DHYFyM1zUOYBJNkj8Rj0V7ppES2EGrEmcZOyc6Zo=; b=S13iOPeK+OY3B2wgm24P0kJslKCLnzs//ae9t+OJywms770kTcnY+G2A5Zb9NJA4VZ EaUpUqFYGxFQOE8Mn8YPhO4GnmRryGgZTOjlmrNtMuyJEmxIPGGWMIjlfmS2tWT/nMGr DEbop+O7EtqPT5WV/pLyEOKRu5ckRRjr8qMI1FgLVk5+KbbwruyV0+YXpTlGzI9dUwlE llf/+1rC8Jq6+nQlqeReJIn9r2do7Uqc/D8SFqr2oVbfKy2AapHRLs7JF24jiekdXyML WVjzc0pgw2wsnJ6qUYF+nwOZnlwf4Y2kN5g82SVB2YPcuNv9E2PHatLveVqb8hxvEjaW u2Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PH0DHYFyM1zUOYBJNkj8Rj0V7ppES2EGrEmcZOyc6Zo=; b=VwRoEF0nE/G5fwdhq5JaZ8satuD8qadQxTtqfBataI4RxtfAJXEY3hOZoka7ayOMcI NnHIuza5STw8n0ibaSg55PtnwFYNZPh10PEOPzsyTjggo7L5onqlBiCvRCk7JW5IdJZs ViYwAagTqpN/sM6VsdzlYg48xDMN7eplMXbfkI7PJ66ZPMqxW/veC1MsOB4+oSVwguZM OhJe3ZbwqFSia44wiYa9LUa+8ocAnSnKMvl3gKAzhlNHmOCTqwFvQWx+Q/unCPHmfFdM r7omQuIsZ0TLLL+r9b3l0U9J/LmEaqzFb6anvd6ftBmpooaXTV/L1rGPmfNPhMpRkELA 3vMA== X-Gm-Message-State: AOAM530F9VNUK8JeZxiYfro+vi6TwAtd3h7+k4PB6WMQJy1j6iFyEhX6 9Ylrp2jI7yjCQ/q82ZoCxHjWRZBajBbE+A== X-Google-Smtp-Source: ABdhPJwEQZPCLwFtLCf9rg1YFO3b2TRJWJeKWuA6eWTJwUm2ovkxMUnpUND72vewlAHHbR4Wn3dVeA== X-Received: by 2002:a05:6000:1091:b0:213:b515:f46f with SMTP id y17-20020a056000109100b00213b515f46fmr37736833wrw.632.1654826513228; Thu, 09 Jun 2022 19:01:53 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.01.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:01:52 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 09/20] git-submodule.sh: dispatch "sync" to helper Date: Fri, 10 Jun 2022 04:01:21 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove the cmd_sync() wrapper for "git submodule--helper sync" in favor of dispatching the raw command-line directly to the helper. At this point we've already parsed out the optional "--quiet" flag that we need to support for "git submodule --quiet" (as opposed to "git submodule --quiet"). This changes the output we'll display on invalid usage for the better, before this we'd emit e.g.: $ git submodule sync --blah usage: git submodule [--quiet] [--cached] or: [...many lines of "or" usage omitted...] But now we'll emit the much more useful: $ git submodule sync --blah error: unknown option `blah' usage: git submodule sync [--quiet] [--recursive] [] -q, --quiet suppress output of synchronizing submodule url --recursive recurse into nested submodules This is because we'll now get as far as module_sync()'s failing call to parse_options() when we have invalid usage. Signed-off-by: Ævar Arnfjörð Bjarmason --- git-submodule.sh | 37 ++++--------------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index fb13f818c63..ddc2e4e4032 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -520,39 +520,6 @@ cmd_status() git ${wt_prefix:+-C "$wt_prefix"} submodule--helper status ${GIT_QUIET:+--quiet} ${cached:+--cached} ${recursive:+--recursive} -- "$@" } -# -# Sync remote urls for submodules -# This makes the value for remote.$remote.url match the value -# specified in .gitmodules. -# -cmd_sync() -{ - while test $# -ne 0 - do - case "$1" in - -q|--quiet) - GIT_QUIET=1 - shift - ;; - --recursive) - recursive=1 - shift - ;; - --) - shift - break - ;; - -*) - usage - ;; - *) - break - ;; - esac - done - - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper sync ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- "$@" -} # This loop parses the command line arguments to find the # subcommand name to dispatch. Parsing of the subcommand specific @@ -606,6 +573,10 @@ case "$command" in absorbgitdirs) git submodule--helper "$command" --prefix "$wt_prefix" "$@" ;; +sync) + git ${wt_prefix:+-C "$wt_prefix"} submodule--helper "$command" \ + ${GIT_QUIET:+--quiet} "$@" + ;; *) "cmd_$(echo $command | sed -e s/-/_/g)" "$@" ;; From patchwork Fri Jun 10 02:01:22 2022 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: 12876293 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2AF9C43334 for ; Fri, 10 Jun 2022 02:02:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345965AbiFJCC2 (ORCPT ); Thu, 9 Jun 2022 22:02:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243263AbiFJCCQ (ORCPT ); Thu, 9 Jun 2022 22:02:16 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E3CA6D1B6 for ; Thu, 9 Jun 2022 19:01:57 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 67-20020a1c1946000000b00397382b44f4so378443wmz.2 for ; Thu, 09 Jun 2022 19:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ct8LL4il4KO8GCD+7JiXZvXAzvuCFYMD33knjbIjgKs=; b=GrXGfQ48HV6VaKdDcsM9Cb5CJYwq7BBK+Cj3SAqO17Q884xtVoUW24OnHcmUdvr57W WrU68J2GlYwZtd2yAdKJuy54m5pO8uk/CXxqpTjSOSqUnxLW+sbU/pK48PM3nLzLXisB EOXC5FxOXwWOqXIpArhwR79CGgbCUrzgmXJa24xYyZnABFq3jVSchwO5Fvx98M+ThYpX BwH15e8jOKE1kTM6zIJBCNNOkCrIm/0PduuiX/8c3qulFrte2ymnLb1ilHP13n4Af6To dOYr+r6bXkAe4x7JZnPVr8OHKqApFmV3Iz9qm/nPD4F+x3OKoKjxmI7MagjluKZEik9N 3sVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ct8LL4il4KO8GCD+7JiXZvXAzvuCFYMD33knjbIjgKs=; b=lxim5PIzMk0xuVYVdgVOP7nNHp96uYAd/qvH8h2yQGIxA71xchkYvnJlSRgnfFRolk 56i17QSIPAN+PuFZGI7p4AGY4z/0+0VCSk83LcLmJcVUvWt6IUxDjHrGh1qPuJUOTx5H oqmRVKoRqUzTOvkU6O5DsBRkFALJKHp+T+sNEwIL4CCfaBJUceNoAp8UqmDJ0GZalGb5 9fmBBsnWoZErnW8iAcLXbZMY1JSu055XpeWP540ysO6JOfQyrjgaVO+4XRp/WIr1KE9o SjKwS2sdl9d5RFQzYf8iZaE8TlhkirCels0Kvqffvv5QEVBLQQ07B/CiIdePt45s8zpi mU9w== X-Gm-Message-State: AOAM533ZEkFCIp1DtLLyCyiPhBp8pPBgLd/EHeO2c+qkyVTXCB5+39et LTY6aqRaGVENkb52SIWeBv7SjuozFagL2A== X-Google-Smtp-Source: ABdhPJwB/ZED+Hk1tR8/oAKF/DPwZpqNjVs1M9G5BeyCUwZEOcQP2GE/P0IoaTHQB7e9GWJjbyK5WQ== X-Received: by 2002:a1c:e903:0:b0:397:36b8:795a with SMTP id q3-20020a1ce903000000b0039736b8795amr6249068wmc.98.1654826514779; Thu, 09 Jun 2022 19:01:54 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.01.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:01:54 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 10/20] git-submodule.sh: dispatch directly to helper Date: Fri, 10 Jun 2022 04:01:22 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the dispatching logic in "git-submodule.sh" for the "add", "init", "deinit", "set-branch", "set-url", "summary" and "status" sub-commands to do away with the argument parsing in git-submodule.sh, and instead dispatch directly to "git submodule--helper". As in a preceding commit the only functional change here should be that on invalid options we'll now emit more targeted "-h" output. The isnumber() helper function was only used in the now-removed cmd_summary(), the same goes for the $files variable. The $custom_name and $branch variables were only used in cmd_add(). Since there are no dashed commands anymore in git-submodule.sh we can get rid of the "$(echo | sed ...)" one-liner to change e.g. "set-url" to "set_url". Signed-off-by: Ævar Arnfjörð Bjarmason --- git-submodule.sh | 321 +---------------------------------------------- 1 file changed, 5 insertions(+), 316 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index ddc2e4e4032..61e4f17b805 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -30,18 +30,15 @@ GIT_PROTOCOL_FROM_USER=0 export GIT_PROTOCOL_FROM_USER command= -branch= force= reference= cached= recursive= init= require_init= -files= remote= nofetch= update= -custom_name= depth= progress= dissociate= @@ -50,86 +47,7 @@ jobs= recommend_shallow= filter= -isnumber() -{ - n=$(($1 + 0)) 2>/dev/null && test "$n" = "$1" -} - -# -# Add a new submodule to the working tree, .gitmodules and the index -# -# $@ = repo path -# -# optional branch is stored in global branch variable -# -cmd_add() -{ - # parse $args after "submodule ... add". - reference_path= - while test $# -ne 0 - do - case "$1" in - -b | --branch) - case "$2" in '') usage ;; esac - branch=$2 - shift - ;; - -f | --force) - force=$1 - ;; - -q|--quiet) - GIT_QUIET=1 - ;; - --progress) - progress=1 - ;; - --reference) - case "$2" in '') usage ;; esac - reference_path=$2 - shift - ;; - --reference=*) - reference_path="${1#--reference=}" - ;; - --dissociate) - dissociate=1 - ;; - --name) - case "$2" in '') usage ;; esac - custom_name=$2 - shift - ;; - --depth) - case "$2" in '') usage ;; esac - depth="--depth=$2" - shift - ;; - --depth=*) - depth=$1 - ;; - --) - shift - break - ;; - -*) - usage - ;; - *) - break - ;; - esac - shift - done - - if test -z "$1" - then - usage - fi - - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper add ${GIT_QUIET:+--quiet} ${force:+--force} ${progress:+"--progress"} ${branch:+--branch "$branch"} ${reference_path:+--reference "$reference_path"} ${dissociate:+--dissociate} ${custom_name:+--name "$custom_name"} ${depth:+"$depth"} -- "$@" -} -# # Execute an arbitrary command sequence in each checked out # submodule # @@ -160,73 +78,6 @@ cmd_foreach() git ${wt_prefix:+-C "$wt_prefix"} submodule--helper foreach ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- "$@" } -# -# Register submodules in .git/config -# -# $@ = requested paths (default to all) -# -cmd_init() -{ - # parse $args after "submodule ... init". - while test $# -ne 0 - do - case "$1" in - -q|--quiet) - GIT_QUIET=1 - ;; - --) - shift - break - ;; - -*) - usage - ;; - *) - break - ;; - esac - shift - done - - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper init ${GIT_QUIET:+--quiet} -- "$@" -} - -# -# Unregister submodules from .git/config and remove their work tree -# -cmd_deinit() -{ - # parse $args after "submodule ... deinit". - deinit_all= - while test $# -ne 0 - do - case "$1" in - -f|--force) - force=$1 - ;; - -q|--quiet) - GIT_QUIET=1 - ;; - --all) - deinit_all=t - ;; - --) - shift - break - ;; - -*) - usage - ;; - *) - break - ;; - esac - shift - done - - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper deinit ${GIT_QUIET:+--quiet} ${force:+--force} ${deinit_all:+--all} -- "$@" -} - # # Update each submodule path to correct revision, using clone and checkout as needed # @@ -359,168 +210,6 @@ cmd_update() "$@" } -# -# Configures a submodule's default branch -# -# $@ = requested path -# -cmd_set_branch() { - default= - branch= - - while test $# -ne 0 - do - case "$1" in - -q|--quiet) - # we don't do anything with this but we need to accept it - ;; - -d|--default) - default=1 - ;; - -b|--branch) - case "$2" in '') usage ;; esac - branch=$2 - shift - ;; - --) - shift - break - ;; - -*) - usage - ;; - *) - break - ;; - esac - shift - done - - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper set-branch ${GIT_QUIET:+--quiet} ${branch:+--branch "$branch"} ${default:+--default} -- "$@" -} - -# -# Configures a submodule's remote url -# -# $@ = requested path, requested url -# -cmd_set_url() { - while test $# -ne 0 - do - case "$1" in - -q|--quiet) - GIT_QUIET=1 - ;; - --) - shift - break - ;; - -*) - usage - ;; - *) - break - ;; - esac - shift - done - - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper set-url ${GIT_QUIET:+--quiet} -- "$@" -} - -# -# Show commit summary for submodules in index or working tree -# -# If '--cached' is given, show summary between index and given commit, -# or between working tree and given commit -# -# $@ = [commit (default 'HEAD'),] requested paths (default all) -# -cmd_summary() { - summary_limit=-1 - for_status= - diff_cmd=diff-index - - # parse $args after "submodule ... summary". - while test $# -ne 0 - do - case "$1" in - --cached) - cached=1 - ;; - --files) - files="$1" - ;; - --for-status) - for_status="$1" - ;; - -n|--summary-limit) - summary_limit="$2" - isnumber "$summary_limit" || usage - shift - ;; - --summary-limit=*) - summary_limit="${1#--summary-limit=}" - isnumber "$summary_limit" || usage - ;; - --) - shift - break - ;; - -*) - usage - ;; - *) - break - ;; - esac - shift - done - - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper summary ${files:+--files} ${cached:+--cached} ${for_status:+--for-status} ${summary_limit:+-n $summary_limit} -- "$@" -} -# -# List all submodules, prefixed with: -# - submodule not initialized -# + different revision checked out -# -# If --cached was specified the revision in the index will be printed -# instead of the currently checked out revision. -# -# $@ = requested paths (default to all) -# -cmd_status() -{ - # parse $args after "submodule ... status". - while test $# -ne 0 - do - case "$1" in - -q|--quiet) - GIT_QUIET=1 - ;; - --cached) - cached=1 - ;; - --recursive) - recursive=1 - ;; - --) - shift - break - ;; - -*) - usage - ;; - *) - break - ;; - esac - shift - done - - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper status ${GIT_QUIET:+--quiet} ${cached:+--cached} ${recursive:+--recursive} -- "$@" -} - # This loop parses the command line arguments to find the # subcommand name to dispatch. Parsing of the subcommand specific # options are primarily done by the subcommand implementations. @@ -573,11 +262,11 @@ case "$command" in absorbgitdirs) git submodule--helper "$command" --prefix "$wt_prefix" "$@" ;; -sync) - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper "$command" \ - ${GIT_QUIET:+--quiet} "$@" +foreach | update) + "cmd_$command" "$@" ;; -*) - "cmd_$(echo $command | sed -e s/-/_/g)" "$@" +add | init | deinit | set-branch | set-url | status | summary | sync) + git ${wt_prefix:+-C "$wt_prefix"} submodule--helper "$command" \ + ${GIT_QUIET:+--quiet} ${cached:+--cached} "$@" ;; esac From patchwork Fri Jun 10 02:01:23 2022 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: 12876295 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EAA1C433EF for ; Fri, 10 Jun 2022 02:02:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346001AbiFJCCb (ORCPT ); Thu, 9 Jun 2022 22:02:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345837AbiFJCCR (ORCPT ); Thu, 9 Jun 2022 22:02:17 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B43DB5798 for ; Thu, 9 Jun 2022 19:01:58 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id z17so8392099wmi.1 for ; Thu, 09 Jun 2022 19:01:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eAqVcp4UhXa/A07iwHrW4M56pNyB8B/KKMISTrT3Njc=; b=Ex8LFSk5J2SqOpLUvV9Empct14zjGiMdni+H5nwgepKakO6xU9f1MG5L1FQtXmrHB/ JOqR//uJy5oq3cypim7d7UzXeE2f2atG/ORiEQAy+1Ihaxz8Ab8Uya4LzU/v8GLlHefT dTD71/O7TcAVVQTzejyQbgr/KZno0QxS+IU5RkgfvSukiN2yQdRhi4jE82FnEaoN3cqf FU/Pi2HuChRtdFqJ5Yc42RcwP7048x/FZxvdFCfXsdtsVlUuIXPzNsv0g6wizos59XvS ouro83kKWk2+Ud/TfGW8u3z60F5xXiq/rnIPHl5T4ajnyZQfETastyP0DZBRFxDLYju1 tJdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eAqVcp4UhXa/A07iwHrW4M56pNyB8B/KKMISTrT3Njc=; b=eeSYvgHYQ2tVztbWHKRCGxit1MSuEvGo9LcW4TvoaVgP4os6l9lWu3jQ8+4r3uLuOz ZvXvDca6HufZ2iE3QMGXasfYcge27Fv+p7Wpa2pU6jYhxNdhORnnJfvTtnGWwSjU7yZ6 1ropUK5z8wgzX9RA7E6HTWyHZv199688AkUYfhx/SAovXvgh1PBlnpNWY55BrafU1xii PParDk+TQSPSU/kseSFVOqO2cfGKP4yF0ukcy2i0xoeB+xHDZ9CT4/rsm5XYOv1AquQy qBgCi8oXdhX+hy8eKb4fU5GLKo2xpAlxyU32mDv1LzrGlflQ59WLM6sZa5j68Eiam234 G6Qw== X-Gm-Message-State: AOAM53152kvdd9vnvDNV86/cSURFKZ1/9BYWcJMfZqHQHNiniBoTpodu re1cX2YvLNhrHqGDHgwr2jLPIgTGw1Wwxw== X-Google-Smtp-Source: ABdhPJzIXJ5DiZoAEDe+Fl5euAuo0o8HWpldL4gR8bSm8pQrSr7JaKBmrB8eq95C6LvAUT5M6mSKpQ== X-Received: by 2002:a7b:c404:0:b0:39c:4389:5834 with SMTP id k4-20020a7bc404000000b0039c43895834mr6320944wmi.70.1654826516696; Thu, 09 Jun 2022 19:01:56 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:01:55 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 11/20] git-submodule.sh: dispatch "foreach" to helper Date: Fri, 10 Jun 2022 04:01:23 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Dispatch the "git submodule foreach" command directly to "git submodule--helper foreach". This case requires the addition of the PARSE_OPT_STOP_AT_NON_OPTION flag, since the shellscript was unconditionally adding "--" to the "git submodule--helper" command-line. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/submodule--helper.c | 3 ++- git-submodule.sh | 37 +++---------------------------------- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 3173295ed8e..459260efc65 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -449,7 +449,8 @@ static int module_foreach(int argc, const char **argv, const char *prefix) }; argc = parse_options(argc, argv, prefix, module_foreach_options, - git_submodule_helper_usage, 0); + git_submodule_helper_usage, + PARSE_OPT_STOP_AT_NON_OPTION); if (module_list_compute(0, NULL, prefix, &pathspec, &list) < 0) return 1; diff --git a/git-submodule.sh b/git-submodule.sh index 61e4f17b805..de6c71d6bd5 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -47,37 +47,6 @@ jobs= recommend_shallow= filter= - -# Execute an arbitrary command sequence in each checked out -# submodule -# -# $@ = command to execute -# -cmd_foreach() -{ - # parse $args after "submodule ... foreach". - while test $# -ne 0 - do - case "$1" in - -q|--quiet) - GIT_QUIET=1 - ;; - --recursive) - recursive=1 - ;; - -*) - usage - ;; - *) - break - ;; - esac - shift - done - - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper foreach ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- "$@" -} - # # Update each submodule path to correct revision, using clone and checkout as needed # @@ -262,10 +231,10 @@ case "$command" in absorbgitdirs) git submodule--helper "$command" --prefix "$wt_prefix" "$@" ;; -foreach | update) - "cmd_$command" "$@" +update) + cmd_update "$@" ;; -add | init | deinit | set-branch | set-url | status | summary | sync) +add | foreach | init | deinit | set-branch | set-url | status | summary | sync) git ${wt_prefix:+-C "$wt_prefix"} submodule--helper "$command" \ ${GIT_QUIET:+--quiet} ${cached:+--cached} "$@" ;; From patchwork Fri Jun 10 02:01:24 2022 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: 12876294 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42438CCA47B for ; Fri, 10 Jun 2022 02:02:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345972AbiFJCCa (ORCPT ); Thu, 9 Jun 2022 22:02:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345801AbiFJCCR (ORCPT ); Thu, 9 Jun 2022 22:02:17 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5B61B82D0 for ; Thu, 9 Jun 2022 19:01:59 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 67-20020a1c1946000000b00397382b44f4so378470wmz.2 for ; Thu, 09 Jun 2022 19:01:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FdNv2954wsXdpYKN09KuCV8MoYNxoY9sm/uFA7dXlao=; b=DsK+uF4ITyiifkzHCIxdwKHMPv3VHXP+gUOhJQgACfOa5tibCfIWICve0lDNrHxDLx wWzovtk7J60s59E2F6ddRBrhkmghonXtagr2V9c5EUfqdkJ/Pt5tocdIjH7A5fSLS+B9 nWiMhqwgkCT2EWat3Ac7JvR+cUTJvwIjuoaHk4EqnnM8gFDweUEeuJP+tnuXiHwHQE81 NIWWa2hFb9z4CrLXisJaGSgnCpOewdqvsEfPNdVz9qZRNQjlNOQntdECeHxDZorYByHB nRvGLMQLvv8y5wnEl1NWSQL4f0OFh3BxpsgBOPBOJfqyJ2Dk29br56mF7LXW4YNM5ChS YYJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FdNv2954wsXdpYKN09KuCV8MoYNxoY9sm/uFA7dXlao=; b=OZVk++umtzzuNLpAlEtObjB7nL+ELVpuWW8b2cef2/SqUspyhHyY1TZCN+7D+bB5Au GTQu66AC47MZKHK6ygtQnBFyORe5BWZeYW5Djv+mCcnN62Tj3XlKAMXS5sb2TEzVPQAm gUvm5qqYHPvPs3MkoBnD5zxeLmI9aVQYLew2flKx34fPcUNy6XYRhXUGiU0T6UHc7cBT 8oK7o1PCpz1NT1jXDeW9lxiMRTIU/SWjHO62rermUUhSazX1gVgXW3R16m3Sx38heHzi Hhmnvv+s3FyvTpIzxskiZJWUwxQKrUWQJwW++9tDbYxyk6SBWGlpOjMQcPIkJcpKU5V9 BCjw== X-Gm-Message-State: AOAM530ehcd80Khg6SJonH9EqpllrJpuyw2ytWkyYAwABKqex8E/Tkf9 x21KLEI7LjBcQmS2fUgDbqnVEXbo7mnUzA== X-Google-Smtp-Source: ABdhPJy/sdqS3SQI0INJMg9u39ZBKZOldDNoqZnNdLdRqnbuFlG9fIpT3ESqZMyZunN906dQ2wUVhA== X-Received: by 2002:a05:600c:ac4:b0:39c:4f54:9c5f with SMTP id c4-20020a05600c0ac400b0039c4f549c5fmr6138573wmr.135.1654826517925; Thu, 09 Jun 2022 19:01:57 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.01.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:01:57 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 12/20] submodule--helper: have --require-init imply --init Date: Fri, 10 Jun 2022 04:01:24 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Adjust code added in 0060fd1511b (clone --recurse-submodules: prevent name squatting on Windows, 2019-09-12) to have the internal --require-init option imply --init, rather than having "git-submodule.sh" add it implicitly. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/submodule--helper.c | 5 ++++- git-submodule.sh | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 459260efc65..f1f5c6b84c6 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2619,7 +2619,7 @@ static int module_update(int argc, const char **argv, const char *prefix) OPT_BOOL(0, "progress", &opt.progress, N_("force cloning progress")), OPT_BOOL(0, "require-init", &opt.require_init, - N_("disallow cloning into non-empty directory")), + N_("disallow cloning into non-empty directory, implies --init")), OPT_BOOL(0, "single-branch", &opt.single_branch, N_("clone only one branch, HEAD or --branch")), OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options), @@ -2643,6 +2643,9 @@ static int module_update(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, module_update_options, git_submodule_helper_usage, 0); + if (opt.require_init) + opt.init = 1; + if (filter_options.choice && !opt.init) { usage_with_options(git_submodule_helper_usage, module_update_options); diff --git a/git-submodule.sh b/git-submodule.sh index de6c71d6bd5..43fe3bcb00b 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -71,7 +71,6 @@ cmd_update() init=1 ;; --require-init) - init=1 require_init=1 ;; --remote) From patchwork Fri Jun 10 02:01:25 2022 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: 12876302 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2946C433EF for ; Fri, 10 Jun 2022 02:03:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346052AbiFJCDD (ORCPT ); Thu, 9 Jun 2022 22:03:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345991AbiFJCCb (ORCPT ); Thu, 9 Jun 2022 22:02:31 -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 9F017CE5CE for ; Thu, 9 Jun 2022 19:02:10 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id q15so26596898wrc.11 for ; Thu, 09 Jun 2022 19:02:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=efHOzyjZ950i3UiKV6jUtbv/GdRv7QNPcTNCpJRrfmU=; b=kaDy9a+7gBQJ4ktO6oM/tEE820GHiog2/g7uHdk6pjo7LfAraIVbdQKU05dzD3syTy WG/Nt+KopkdSw4UZKENss3HyDxllL6jG+s0GbQhi/kaE1HoE3b2wwONFfDVkKQFbq7t0 9BUf1Hw9kciKCIEVFBZsV88jRr8AnaAJuPkzXTfH/5DkSD657M2gp4R2d1wXOSR5Jtd2 FcYxpFr7yGzWfFk7uazvri6qsdtLkQt7OKwpIGPkEvUlLewdirSIGH/969MRYAnE+4gv CTswtL+ymNZ3zN+kpAlI2dCOcG4Tej/mezcYcIVTPXNPUYUmfttFnBd4DdvTehFhvrrj BR0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=efHOzyjZ950i3UiKV6jUtbv/GdRv7QNPcTNCpJRrfmU=; b=5tBhZ96KB6T7tlFgvoHOkwKyOgvkfqGFa80NvWr9h2XrLQrZA9EvHx40f/5+CWAkte E9D2iyP2dLahaqVeV1lmvr2tPHelHN8HQCiga/yvnBJpSQJAne0dfCpeB+zRvk+qmsPN 63wdXH58J2p+sH0J3527fCDtLKSNSm1JrvNL66WI4JlBm29TOFns2kbJHpaX5ET1s1hF GqmzWuKnvDsFvr+fLnaC5kbLIOqsO4bOF7nyshSnzPTeylSCihEVSnO4ilX/aKrdAOxV yoiDvi3giIKQcaPEzjMgdMd8qCLJzYv07xOmwpMu3M09lxI/uy0/haVvVbSTvlc2EWWM kpVA== X-Gm-Message-State: AOAM533HVcajnDHHd/WSlhwfuALTdzb5BsZLSlSF6slacz2D5c5xC11/ v36SoJgLSnWiFTUZUOYsMT5n7ZCfa2CPpw== X-Google-Smtp-Source: ABdhPJz2sDRorYXZeCrNo3Jsag2EBzQl1H9lRXHHBcL8CW0JGnw/EynZpZF8ZNYLQn+z+gHyeW7KEQ== X-Received: by 2002:a5d:47a1:0:b0:218:423c:8448 with SMTP id 1-20020a5d47a1000000b00218423c8448mr23327480wrb.199.1654826518804; Thu, 09 Jun 2022 19:01:58 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:01:58 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 13/20] submodule--helper: understand --checkout, --merge and --rebase synonyms Date: Fri, 10 Jun 2022 04:01:25 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Understand --checkout, --merge and --rebase synonyms for --update={checkout,merge,rebase}, as well as the short options that 'git submodule' itself understands. This removes a difference between the CLI API of "git submodule" and "git submodule--helper", making it easier to make the latter an alias for the former. See 48308681b07 (git submodule update: have a dedicated helper for cloning, 2016-02-29) for the initial addition of --update. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/submodule--helper.c | 17 +++++++++++++++++ git-submodule.sh | 14 +++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index f1f5c6b84c6..64d7c5d7ba4 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2583,6 +2583,7 @@ static int module_update(int argc, const char **argv, const char *prefix) struct update_data opt = UPDATE_DATA_INIT; struct list_objects_filter_options filter_options; int ret; + enum submodule_update_type update_type = SM_UPDATE_UNSPECIFIED; struct option module_update_options[] = { OPT__FORCE(&opt.force, N_("force checkout updates"), 0), @@ -2604,6 +2605,15 @@ static int module_update(int argc, const char **argv, const char *prefix) OPT_STRING(0, "update", &opt.update_default, N_("string"), N_("rebase, merge, checkout or none")), + OPT_SET_INT(0, "checkout", &update_type, + N_("use the 'checkout' update strategy (default)"), + SM_UPDATE_CHECKOUT), + OPT_SET_INT('m', "merge", &update_type, + N_("use the 'merge' update strategy"), + SM_UPDATE_MERGE), + OPT_SET_INT('r', "rebase", &update_type, + N_("use the 'rebase' update strategy"), + SM_UPDATE_MERGE), OPT_STRING_LIST(0, "reference", &opt.references, N_("repo"), N_("reference repository")), OPT_BOOL(0, "dissociate", &opt.dissociate, @@ -2653,6 +2663,13 @@ static int module_update(int argc, const char **argv, const char *prefix) opt.filter_options = &filter_options; + if (update_type == SM_UPDATE_CHECKOUT) + opt.update_default = "checkout"; + else if (update_type == SM_UPDATE_MERGE) + opt.update_default = "merge"; + else if (update_type == SM_UPDATE_REBASE) + opt.update_default = "rebase"; + if (opt.update_default) if (parse_submodule_update_strategy(opt.update_default, &opt.update_strategy) < 0) diff --git a/git-submodule.sh b/git-submodule.sh index 43fe3bcb00b..d8abdd8e8ad 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -38,7 +38,9 @@ init= require_init= remote= nofetch= -update= +rebase= +merge= +checkout= depth= progress= dissociate= @@ -83,7 +85,7 @@ cmd_update() force=$1 ;; -r|--rebase) - update="rebase" + rebase=1 ;; --reference) case "$2" in '') usage ;; esac @@ -97,13 +99,13 @@ cmd_update() dissociate=1 ;; -m|--merge) - update="merge" + merge=1 ;; --recursive) recursive=1 ;; --checkout) - update="checkout" + checkout=1 ;; --recommend-shallow) recommend_shallow="--recommend-shallow" @@ -164,7 +166,9 @@ cmd_update() ${init:+--init} \ ${nofetch:+--no-fetch} \ ${wt_prefix:+--prefix "$wt_prefix"} \ - ${update:+--update "$update"} \ + ${rebase:+--rebase} \ + ${merge:+--merge} \ + ${checkout:+--checkout} \ ${reference:+"$reference"} \ ${dissociate:+"--dissociate"} \ ${depth:+"$depth"} \ From patchwork Fri Jun 10 02:01:26 2022 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: 12876297 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0360C43334 for ; Fri, 10 Jun 2022 02:02:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345926AbiFJCCg (ORCPT ); Thu, 9 Jun 2022 22:02:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345908AbiFJCCR (ORCPT ); Thu, 9 Jun 2022 22:02:17 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1302BA996 for ; Thu, 9 Jun 2022 19:02:01 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id a10so10689288wmj.5 for ; Thu, 09 Jun 2022 19:02:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wRA5jRM2zPUm87xWbXkGdgEjKraeJ92JI9CfybIBpxc=; b=BFgzRA38QtITsrnnt3SV2XejzefHosKzZX1bdHfohS/uqlSWCVN4ywFdPKrkkFjqpD oPnilLk7CcK3on38Zh7q1MiVlGyFj9OY0iVIyb1KFNAg2YxvUHJ4zNzjjp3Wo2qFMmSn zZMrHSDc4Le7lZmaGpiX5OeXnw/e8TkBMOuqrrpsOQGYy9MSbLXaV3hBhr6X9hST34Qg DQSn90O/NY/cdVc/FlSbw95HmOBSiOfox+yQJZVkA/0yIR0a8k3vio9U0KTfpOdiGZRE XOHtE0fQJvSdCVGpm8eHGcpzIKNjnEXgkGN6ABo4INwbRRWb+IEdQnOqRessbb6r9ucD vxRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wRA5jRM2zPUm87xWbXkGdgEjKraeJ92JI9CfybIBpxc=; b=avglNRaARROpN4LeF2J1g6nK2nX4X1TOz/cIBSknzu/uJBJ7ZsGA8dFxXmSUfBV2wi BvjDHAgyJqKVkZl2zD3FD7sGHPlqw2k6SDgtcBEkkIaEVrebQlnAkkLBlfgFwgsIEOBF BnpE5pIC6EaSwx2QxbhgIwPVmvRO6e5m4RpMuHDycyvMnJaL1FOs+yBot1edf/4JN/cY zXXK/2z3LPHSoeyLEwA6SAOUEekReVl2Hh1f81UY7Lw5OL+3QKmHMrLliBJ5JG+1OQEH OScxkuaPzmTeWezpxrEHbrnBW6xbKpxEd3oEINEhbYFhmFQuo3APixP5rxkDwAmJwjFB bFTQ== X-Gm-Message-State: AOAM531mTO7LrNbxUM6Q26++8NB1ri5BQM+aDesN80N8hYaIhQJ3Q0eM ufddxDF59ZFvNS728WGvFmeloT/rHuPLfg== X-Google-Smtp-Source: ABdhPJxq5xwvobXaiVDo+M59n6Rxd6vVCY7EOeCiRhxvfo6+kqDsbf6FKnMfvM2bsg9WIztUtiDgNQ== X-Received: by 2002:a05:600c:4e4c:b0:39c:5c73:b20c with SMTP id e12-20020a05600c4e4c00b0039c5c73b20cmr6163580wmq.37.1654826519470; Thu, 09 Jun 2022 19:01:59 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:01:59 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 14/20] git-submodule doc: document the -v" option to "update" Date: Fri, 10 Jun 2022 04:01:26 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In e84c3cf3dc3 (git-submodule.sh: accept verbose flag in cmd_update to be non-quiet, 2018-08-14) the "git submodule update" sub-command was made to understand "-v" for "don't be quiet" (but not "--verbose"). Let's update the documentation to reflect this. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/git-submodule.txt | 7 +++++-- git-submodule.sh | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt index 4d3ab6b9f92..5f1c552110e 100644 --- a/Documentation/git-submodule.txt +++ b/Documentation/git-submodule.txt @@ -14,7 +14,7 @@ SYNOPSIS 'git submodule' [--quiet] status [--cached] [--recursive] [--] [...] 'git submodule' [--quiet] init [--] [...] 'git submodule' [--quiet] deinit [-f|--force] (--all|[--] ...) -'git submodule' [--quiet] update [] [--] [...] +'git submodule' [--quiet] update [-v] [] [--] [...] 'git submodule' [--quiet] set-branch [] [--] 'git submodule' [--quiet] set-url [--] 'git submodule' [--quiet] summary [] [--] [...] @@ -133,7 +133,7 @@ If you really want to remove a submodule from the repository and commit that use linkgit:git-rm[1] instead. See linkgit:gitsubmodules[7] for removal options. -update [--init] [--remote] [-N|--no-fetch] [--[no-]recommend-shallow] [-f|--force] [--checkout|--rebase|--merge] [--reference ] [--depth ] [--recursive] [--jobs ] [--[no-]single-branch] [--filter ] [--] [...]:: +update [-v] [--init] [--remote] [-N|--no-fetch] [--[no-]recommend-shallow] [-f|--force] [--checkout|--rebase|--merge] [--reference ] [--depth ] [--recursive] [--jobs ] [--[no-]single-branch] [--filter ] [--] [...]:: + -- Update the registered submodules to match what the superproject @@ -270,6 +270,9 @@ OPTIONS --quiet:: Only print error messages. +-v:: + Don't be quiet. This option is only valid for the update command. + --progress:: This option is only valid for add and update commands. Progress status is reported on the standard error stream diff --git a/git-submodule.sh b/git-submodule.sh index d8abdd8e8ad..1929c34ae8b 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -10,7 +10,7 @@ USAGE="[--quiet] [--cached] or: $dashless [--quiet] status [--cached] [--recursive] [--] [...] or: $dashless [--quiet] init [--] [...] or: $dashless [--quiet] deinit [-f|--force] (--all| [--] ...) - or: $dashless [--quiet] update [--init [--filter=]] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference ] [--recursive] [--[no-]single-branch] [--] [...] + or: $dashless [--quiet] update [-v] [--init [--filter=]] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference ] [--recursive] [--[no-]single-branch] [--] [...] or: $dashless [--quiet] set-branch (--default|--branch ) [--] or: $dashless [--quiet] set-url [--] or: $dashless [--quiet] summary [--cached|--files] [--summary-limit ] [commit] [--] [...] From patchwork Fri Jun 10 02:01:27 2022 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: 12876296 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF69AC433EF for ; Fri, 10 Jun 2022 02:02:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345910AbiFJCCf (ORCPT ); Thu, 9 Jun 2022 22:02:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345906AbiFJCCR (ORCPT ); Thu, 9 Jun 2022 22:02:17 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D517ABA55B for ; Thu, 9 Jun 2022 19:02:01 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 67-20020a1c1946000000b00397382b44f4so378443wmz.2 for ; Thu, 09 Jun 2022 19:02:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pZIZtun4Grq8WUH21/BFtVaOnsQ6ZhWz6xTmg09hpFk=; b=ZBOkhCZNNk13k5u88et4kOCFyRWK58GdXRKlJWHD+sTLz3X8s4yl3tKMuNzkTeI7NH OXUsb4XpSKXc1fOJAc1KgkHHEfNyHHZ28ITQhkWhUUCxTpGIbmhVvGJZRAvDAwU8IpIp Dc/6czyZPAhpmArYXNYfAjKGhUXWzmhUBiS4qW8+L/edBw+WG4Q+C2ePsXJT591cEevu +IOKVipYmR9NG+rMqm1W1Ve69Gbue5fKhDFy05AOkAZSNmJEfJdCzk9V1EBOrlYZxs4b +CgyfKZkWWiFIxBddokZq/GryW0y7DEUjB7LnRpCgDj0++Q4AXPqhzBgFu5hrFBdCHnM yUyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pZIZtun4Grq8WUH21/BFtVaOnsQ6ZhWz6xTmg09hpFk=; b=6R6tmSZws7JtlnHSroIgZ85998wyoRlis7PQywdRcCyoJZykVB8y0Sw/OxksVs+wGX pdizWROiaXYilnElID7UFEMQtkh29/5MLaq7RjXxhpYy8U7h8Ci+mbz7aTTEuYc3OdE/ zsWF9/7i5sx1wYiQMo14rjZpJ99Yh8J/80kz3D1t6nS8CoeOlwbxKytLTbwXNenGDEbW vwTXqJZIRYfNAt4JRLVcJn+ycKoTDp6M3y5IMJSc7JdFGDIkPLf5R4obtsVqq1eOsDXG mU/654J+EmH26ACD9uP2RKE8Op/KPWulyGnN0sfr/+/3x2ga+Jq7NHnRjfZSH4cQU1iX Yzlg== X-Gm-Message-State: AOAM533Mr6Rq/1t0dB1CnyXro7dQmp3IRluAVcMvJrqxsW12bM+cxNWk Slbj5H8pjfIY0KFl9QjO1kc+qJPuBhf6/Q== X-Google-Smtp-Source: ABdhPJwrs6gFUKu5KpkeyAvs6FWejA8jorVk6I5zag9MFWx7XE1MbwJm+KhzqF/TqDzs2+lzNTu0Kg== X-Received: by 2002:a7b:c1c1:0:b0:39c:58c4:c701 with SMTP id a1-20020a7bc1c1000000b0039c58c4c701mr6333106wmj.117.1654826520700; Thu, 09 Jun 2022 19:02:00 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:01:59 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 15/20] submodule--helper: understand -v option for "update" Date: Fri, 10 Jun 2022 04:01:27 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the "OPT__QUIET()" in module_update() to use OPT__VERBOSITY() instead. This is in preparation for passing the command in "git-submodule.sh" to "git submodule update" directly. Note that this implementation supports the "--verbose" synonym for "-v", but "git-submodule.sh" does not. Once we make the switch to calling "git submodule--helper update" directly we should update the documentation to reflect that. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/submodule--helper.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 64d7c5d7ba4..94126bcca07 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2584,6 +2584,7 @@ static int module_update(int argc, const char **argv, const char *prefix) struct list_objects_filter_options filter_options; int ret; enum submodule_update_type update_type = SM_UPDATE_UNSPECIFIED; + int verbosity = 0; struct option module_update_options[] = { OPT__FORCE(&opt.force, N_("force checkout updates"), 0), @@ -2625,7 +2626,7 @@ static int module_update(int argc, const char **argv, const char *prefix) N_("parallel jobs")), OPT_BOOL(0, "recommend-shallow", &opt.recommend_shallow, N_("whether the initial clone should follow the shallow recommendation")), - OPT__QUIET(&opt.quiet, N_("don't print cloning progress")), + OPT__VERBOSITY(&verbosity), OPT_BOOL(0, "progress", &opt.progress, N_("force cloning progress")), OPT_BOOL(0, "require-init", &opt.require_init, @@ -2637,7 +2638,7 @@ static int module_update(int argc, const char **argv, const char *prefix) }; const char *const git_submodule_helper_usage[] = { - N_("git submodule [--quiet] update" + N_("git submodule [--quiet] update [-v | --verbose]" " [--init [--filter=]] [--remote]" " [-N|--no-fetch] [-f|--force]" " [--checkout|--merge|--rebase]" @@ -2656,6 +2657,9 @@ static int module_update(int argc, const char **argv, const char *prefix) if (opt.require_init) opt.init = 1; + if (verbosity < 0) + opt.quiet = 1; + if (filter_options.choice && !opt.init) { usage_with_options(git_submodule_helper_usage, module_update_options); From patchwork Fri Jun 10 02:01:28 2022 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: 12876303 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67F25C43334 for ; Fri, 10 Jun 2022 02:03:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346058AbiFJCDF (ORCPT ); Thu, 9 Jun 2022 22:03:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345887AbiFJCCS (ORCPT ); Thu, 9 Jun 2022 22:02:18 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F879BCE88 for ; Thu, 9 Jun 2022 19:02:03 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id a10so10689315wmj.5 for ; Thu, 09 Jun 2022 19:02:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i5yWOgGV6nkLRgqYQPcJed9enMkjAOg/wHLTF2newGs=; b=Sbr9R7ck9Pbkhp+1s+9+GU4awgiYUYy41LwSrH7Y4h6NxAjc0RD7zbiQsFGSbkxC/N aGky75KADwfgBA20tJfLp3/kfil6mMVxN/S4mS+/fwWxes6ec5JnMrib4f6LdJar1pFo s9isldZo+QqjSsCIbEmJYZkW4GiOPQ5q9dtBRFkmHBndLTygUIxsTiA24IkxU3aTHCHa lCcTvDn4dTGqv9cHdWCEOGWuf8o3C0wAqD5oq51p7GzubipE7kP9KDYEml1rkkjvIRG0 hcU/1CkYHfRB1KggelcrQtqczjpd4/SRWftSGX8c9sdr3lj10XkIa3yCGROj45KL8DYl yS9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i5yWOgGV6nkLRgqYQPcJed9enMkjAOg/wHLTF2newGs=; b=yrrs3qRKFFxgHr3sxMZ6izmSYaGakbFcyDhkEzLdHFi8H3C158SrSHEu8vRh6I/YBG r6ZTx26BF6+BBqxSO0rYTcVyWCwSqE1Jajmm5T7WMuqt0rseMiun2IWuCNfOkpvRV50l gM9c0jMnqCRFclkpNrDZYbU6AL+I9VztBucCK7Twu2wREaL34m3m3+3wWaSfibw0epDP QULG4Y8xWWgcRGwK4u7JTeymwdpJ4K83SOo9BnumTRrf6t9ilexZxPyBWlR7hLmYOr94 l8VoxWh7SB50ef9qrsI9KBnacene8I7jLffijlUl1lTQeLC8PYN/+IO6W5iHnlC32WZY oYsg== X-Gm-Message-State: AOAM532UY55Wq8Y1wKh8uylJf4H0PHHZ635cJ6MZzSPfPgX8NnBq+b8I LqsEEmk/u2i5qkAjxy4q/gdQvUZry448hw== X-Google-Smtp-Source: ABdhPJzfqXE62PZSBF0MYlfHsiMulH9BFcZWnjs6Iqem66S/k8AMsQOdWQYIbYtChfxrRTB9Im1v7Q== X-Received: by 2002:a05:600c:19cb:b0:397:51db:446f with SMTP id u11-20020a05600c19cb00b0039751db446fmr6098221wmq.182.1654826521630; Thu, 09 Jun 2022 19:02:01 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:02:00 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 16/20] git-submodule.sh: dispatch "update" to helper Date: Fri, 10 Jun 2022 04:01:28 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Dispatch the "update" command directly to "git submodule--helper update", rather than doing our own argument parsing in git-submodule.sh. As this is the last cmd_*() function to be removed from git-submodule.sh we can do some larger cleanup of that file as a result. As noted in a preceding commit the only behavior change here should be the desirable change of better "-h" output, and that this implementation understands the "--verbose" synonym for "-v". Let's update the documentation to reflect the new "--verbose" synonym. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/git-submodule.txt | 5 +- git-submodule.sh | 159 +------------------------------- 2 files changed, 5 insertions(+), 159 deletions(-) diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt index 5f1c552110e..95685ac4f1c 100644 --- a/Documentation/git-submodule.txt +++ b/Documentation/git-submodule.txt @@ -14,7 +14,7 @@ SYNOPSIS 'git submodule' [--quiet] status [--cached] [--recursive] [--] [...] 'git submodule' [--quiet] init [--] [...] 'git submodule' [--quiet] deinit [-f|--force] (--all|[--] ...) -'git submodule' [--quiet] update [-v] [] [--] [...] +'git submodule' [--quiet] update [-v | --verbose] [] [--] [...] 'git submodule' [--quiet] set-branch [] [--] 'git submodule' [--quiet] set-url [--] 'git submodule' [--quiet] summary [] [--] [...] @@ -133,7 +133,7 @@ If you really want to remove a submodule from the repository and commit that use linkgit:git-rm[1] instead. See linkgit:gitsubmodules[7] for removal options. -update [-v] [--init] [--remote] [-N|--no-fetch] [--[no-]recommend-shallow] [-f|--force] [--checkout|--rebase|--merge] [--reference ] [--depth ] [--recursive] [--jobs ] [--[no-]single-branch] [--filter ] [--] [...]:: +update [-v | --verbose] [--init] [--remote] [-N|--no-fetch] [--[no-]recommend-shallow] [-f|--force] [--checkout|--rebase|--merge] [--reference ] [--depth ] [--recursive] [--jobs ] [--[no-]single-branch] [--filter ] [--] [...]:: + -- Update the registered submodules to match what the superproject @@ -271,6 +271,7 @@ OPTIONS Only print error messages. -v:: +--verbose:: Don't be quiet. This option is only valid for the update command. --progress:: diff --git a/git-submodule.sh b/git-submodule.sh index 1929c34ae8b..e245b7fbaca 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -30,163 +30,7 @@ GIT_PROTOCOL_FROM_USER=0 export GIT_PROTOCOL_FROM_USER command= -force= -reference= cached= -recursive= -init= -require_init= -remote= -nofetch= -rebase= -merge= -checkout= -depth= -progress= -dissociate= -single_branch= -jobs= -recommend_shallow= -filter= - -# -# Update each submodule path to correct revision, using clone and checkout as needed -# -# $@ = requested paths (default to all) -# -cmd_update() -{ - # parse $args after "submodule ... update". - while test $# -ne 0 - do - case "$1" in - -q|--quiet) - GIT_QUIET=1 - ;; - -v) - unset GIT_QUIET - ;; - --progress) - progress=1 - ;; - -i|--init) - init=1 - ;; - --require-init) - require_init=1 - ;; - --remote) - remote=1 - ;; - -N|--no-fetch) - nofetch=1 - ;; - -f|--force) - force=$1 - ;; - -r|--rebase) - rebase=1 - ;; - --reference) - case "$2" in '') usage ;; esac - reference="--reference=$2" - shift - ;; - --reference=*) - reference="$1" - ;; - --dissociate) - dissociate=1 - ;; - -m|--merge) - merge=1 - ;; - --recursive) - recursive=1 - ;; - --checkout) - checkout=1 - ;; - --recommend-shallow) - recommend_shallow="--recommend-shallow" - ;; - --no-recommend-shallow) - recommend_shallow="--no-recommend-shallow" - ;; - --depth) - case "$2" in '') usage ;; esac - depth="--depth=$2" - shift - ;; - --depth=*) - depth=$1 - ;; - -j|--jobs) - case "$2" in '') usage ;; esac - jobs="--jobs=$2" - shift - ;; - --jobs=*) - jobs=$1 - ;; - --single-branch) - single_branch="--single-branch" - ;; - --no-single-branch) - single_branch="--no-single-branch" - ;; - --filter) - case "$2" in '') usage ;; esac - filter="--filter=$2" - shift - ;; - --filter=*) - filter="$1" - ;; - --) - shift - break - ;; - -*) - usage - ;; - *) - break - ;; - esac - shift - done - - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper update \ - ${GIT_QUIET:+--quiet} \ - ${force:+--force} \ - ${progress:+"--progress"} \ - ${remote:+--remote} \ - ${recursive:+--recursive} \ - ${init:+--init} \ - ${nofetch:+--no-fetch} \ - ${wt_prefix:+--prefix "$wt_prefix"} \ - ${rebase:+--rebase} \ - ${merge:+--merge} \ - ${checkout:+--checkout} \ - ${reference:+"$reference"} \ - ${dissociate:+"--dissociate"} \ - ${depth:+"$depth"} \ - ${require_init:+--require-init} \ - ${dissociate:+"--dissociate"} \ - $single_branch \ - $recommend_shallow \ - $jobs \ - $filter \ - -- \ - "$@" -} - -# This loop parses the command line arguments to find the -# subcommand name to dispatch. Parsing of the subcommand specific -# options are primarily done by the subcommand implementations. -# Subcommand specific options such as --branch and --cached are -# parsed here as well, for backward compatibility. while test $# != 0 && test -z "$command" do @@ -235,7 +79,8 @@ absorbgitdirs) git submodule--helper "$command" --prefix "$wt_prefix" "$@" ;; update) - cmd_update "$@" + git ${wt_prefix:+-C "$wt_prefix"} submodule--helper "$command" \ + ${GIT_QUIET:+--quiet} ${wt_prefix:+--prefix "$wt_prefix"} "$@" ;; add | foreach | init | deinit | set-branch | set-url | status | summary | sync) git ${wt_prefix:+-C "$wt_prefix"} submodule--helper "$command" \ From patchwork Fri Jun 10 02:01:29 2022 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: 12876301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EB6BC43334 for ; Fri, 10 Jun 2022 02:03:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345976AbiFJCC6 (ORCPT ); Thu, 9 Jun 2022 22:02:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345975AbiFJCCa (ORCPT ); Thu, 9 Jun 2022 22:02:30 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FB0CBCEA3 for ; Thu, 9 Jun 2022 19:02:04 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id l2-20020a05600c4f0200b0039c55c50482so447273wmq.0 for ; Thu, 09 Jun 2022 19:02:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QUWD5pzv1klZUb2fHnjW/w1WlwBT7PTobBqrUZ3Y7tE=; b=dQ/Rm7zHSXsEMFc1d7h3nqqxxboKHF/7h5BYIKxu2TBVfL1m78PhsZYS7hUC6avAPG 35yGpINj0Y8E2t2QpYcm6wIR9SRsxyiZQEjAF9jBKP3fl2VAkFfdcBA9ODzttAojHzNQ Eq4jSO54k2e57FoLH99QzYekVlC4JU37Uw3gRYcEZnlF0EA7ckVUrVUguHtb6WtXHMln D/6XJ4wYE/jN5N7cdhWoXbuaJfQTvws7R+yDou4+zTDekmyAW5ZhwWOjS05Y/ZdvgNHB Y+4L7Hbj8yid/IUNvjls14zX3eA0TtIR0dI+RnwnRHofa1n7+QY42kkZBmQTQeAU3c1N F9uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QUWD5pzv1klZUb2fHnjW/w1WlwBT7PTobBqrUZ3Y7tE=; b=y9go/WWXwh2tMhSq8Sr1SKbhpAnJnqv6AzLKWDBePeN8lRf9ziEdWuKO38ueGnc0lN xHPq56of7iJSUTERU1281VoB3aC4PYpl2j7gkUdLUoGFwAp5WY7Aoqp0wjgl90Vthgh0 KyoV1SeQp89Iz6IagShm2vaQe8hg9b4GSnHC9o+ZzsL2YzMm5twDSMmDSsCrqF0SgyiK Sc/7FIfz21r3jBzCyxM8isZLKXAEInncU9y7g3+tmK72UcC4ITcnsKG47DR75zz4JVcq FJSspK8NW1WETZuQXCIhxGzO7OQoUhNlEIBm/D8I0q1S4UAZMYJLNakHCx4/uZ+BkcDk yA0w== X-Gm-Message-State: AOAM531LG2U8t5z11HIXsg1Q50m23iCBrtf4TsG9zVuiJK5cPw2jH8ow qFadxRt9iyHXYtd0cyvZ1HTHBCUI18XoLQ== X-Google-Smtp-Source: ABdhPJxZUuiZgps8s6im+AeDK605+AJtpdIGQdsb7b0CEkBbENAHEXAWiXzQc2JWNLeoLFqdJNt+4g== X-Received: by 2002:a05:600c:4f4e:b0:39c:1bbb:734f with SMTP id m14-20020a05600c4f4e00b0039c1bbb734fmr6241809wmq.116.1654826522910; Thu, 09 Jun 2022 19:02:02 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.02.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:02:01 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 17/20] git-submodule.sh: use "$quiet", not "$GIT_QUIET" Date: Fri, 10 Jun 2022 04:01:29 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove the use of the "$GIT_QUIET" variable in favor of our own "$quiet", ever since b3c5f5cb048 (submodule: move core cmd_update() logic to C, 2022-03-15) we have not used the "say" function in git-sh-setup.sh, which is the only thing that's affected by using "GIT_QUIET". We still want to support --quiet for our own use though, but let's use our own variable for that. This change could have come before the preceding commits which removed cmd_*() functions from this file, but that would have been a much more verbose change. Since we were removing most of the uses of "$GIT_QUIET" this change comes after those. Signed-off-by: Ævar Arnfjörð Bjarmason --- git-submodule.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index e245b7fbaca..cad9948c047 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -30,6 +30,7 @@ GIT_PROTOCOL_FROM_USER=0 export GIT_PROTOCOL_FROM_USER command= +quiet= cached= while test $# != 0 && test -z "$command" @@ -39,7 +40,7 @@ do command=$1 ;; -q|--quiet) - GIT_QUIET=1 + quiet=1 ;; --cached) cached=1 @@ -80,10 +81,10 @@ absorbgitdirs) ;; update) git ${wt_prefix:+-C "$wt_prefix"} submodule--helper "$command" \ - ${GIT_QUIET:+--quiet} ${wt_prefix:+--prefix "$wt_prefix"} "$@" + ${quiet:+--quiet} ${wt_prefix:+--prefix "$wt_prefix"} "$@" ;; add | foreach | init | deinit | set-branch | set-url | status | summary | sync) git ${wt_prefix:+-C "$wt_prefix"} submodule--helper "$command" \ - ${GIT_QUIET:+--quiet} ${cached:+--cached} "$@" + ${quiet:+--quiet} ${cached:+--cached} "$@" ;; esac From patchwork Fri Jun 10 02:01:30 2022 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: 12876298 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8F3EC43334 for ; Fri, 10 Jun 2022 02:02:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346009AbiFJCCj (ORCPT ); Thu, 9 Jun 2022 22:02:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345943AbiFJCCR (ORCPT ); Thu, 9 Jun 2022 22:02:17 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB7F4BDA15 for ; Thu, 9 Jun 2022 19:02:05 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id j5-20020a05600c1c0500b0039c5dbbfa48so418081wms.5 for ; Thu, 09 Jun 2022 19:02:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c07e5/LSFi4qo8tGTS5JLNXr3xBds4Onc4VXcs4bjKw=; b=eVCRFE9AJLzvfK/aLQOV3cWjVHxXs/bKNSVi5naDmU1DMsybRPDtFTXCK1fj5A/TK1 QyWpCzm7jWOVqNvS2ZKzxCi4/cCBpbCTDd3RDHjA5Uot96OREx18Ueq/7dGNZumVfxS8 5iBiz9Z8tx9+2cXNZq+pOfrtS5v7Q5zVnOPYVH8OidriB/6KlN+8ag/H+uGXNYr7nO1V 2fEFmtpx/Gy434BIQpbVReyxZbjtIg1E7TOZuKzMcIIhLzhXC42693wMsUayewTYM0pl It9XhGT7zFjWtCq1dDhUsv7q0RW8VUTCgqrwmmyES7FVWMjUuqW3GBY+4H4CneZ/tu/C S5kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c07e5/LSFi4qo8tGTS5JLNXr3xBds4Onc4VXcs4bjKw=; b=ZD3xOhzokZvZ97FAkCC7a8aj77ghUfD/BbMCO56CeP4D65G/YoA69+wOetYMQZ9XUt savHulZjMbQsdHLwXNBwIirWzR5MhCDD7dtB+9WlN5a8pRXgKcL+LvYDZC/B/17s7c0p Puoicozyxzr61HFXs8Ds1OUoSQoPK6yENIXRVHm7dJL6BHuSu36YBW2JqW8D1rKBjW0H 4BHnH6e/u7DTa8MyhGZW86gcUx6JJbSQ8gDUIKL0PxFybIrrsHMbjXwfNDOmf4BybKe+ cdy98NWp0yWLh5E5wTRF2Gs4gBxyr/90sJmyph1LF0ag6VL0vacaXe2h7b+CbuB0sEce chIQ== X-Gm-Message-State: AOAM5307IDVaSm2LsxrMsfUV/MQe0dI7YTWQNpbnJikQ9PXUIPdJcM0T tIp4DUxzEtNSOGZVhEbRvS7pz2v0jtLuPA== X-Google-Smtp-Source: ABdhPJz5BfhUAdOUPP3JcTAi8IAIH0EQnAITpuv0nuW+MFDtnVuMvwL6k/LxHqEFf10UnKQKHVwLHA== X-Received: by 2002:a05:600c:214c:b0:39c:43b9:9d5f with SMTP id v12-20020a05600c214c00b0039c43b99d5fmr6080677wml.56.1654826523857; Thu, 09 Jun 2022 19:02:03 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.02.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:02:03 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 18/20] git-submodule.sh: simplify parsing loop Date: Fri, 10 Jun 2022 04:01:30 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Simplify the parsing loop so that we don't try to find out the "$command" when looping over arguments initially, we'll only look for the --quiet and --cached options. Then if we have no more arguments we default to "status", otherwise we emit our usage info. Most importantly we don't need to give --cache to only "status" and "summary", instead we trust that "submodule--helper" is checking those arguments, if some subcommands don't them they can emit their own errors. Signed-off-by: Ævar Arnfjörð Bjarmason --- git-submodule.sh | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index cad9948c047..0274b253297 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -29,50 +29,40 @@ cd_to_toplevel GIT_PROTOCOL_FROM_USER=0 export GIT_PROTOCOL_FROM_USER -command= quiet= cached= -while test $# != 0 && test -z "$command" +while test $# != 0 do case "$1" in - add | foreach | init | deinit | update | set-branch | set-url | status | summary | sync | absorbgitdirs) - command=$1 - ;; -q|--quiet) - quiet=1 + quiet=1 && + shift ;; --cached) - cached=1 - ;; - --) - break - ;; - -*) - usage + cached=1 && + shift ;; *) break ;; esac - shift done # No command word defaults to "status" -if test -z "$command" +command= +if test $# = 0 then - if test $# = 0 - then command=status - else - usage - fi -fi - -# "--cached" is accepted only by "status" and "summary" -if test -n "$cached" && test "$command" != status && test "$command" != summary -then - usage +else + case "$1" in + add | foreach | init | deinit | update | set-branch | set-url | status | summary | sync | absorbgitdirs) + command=$1 && + shift + ;; + *) + usage + esac fi case "$command" in @@ -83,7 +73,7 @@ update) git ${wt_prefix:+-C "$wt_prefix"} submodule--helper "$command" \ ${quiet:+--quiet} ${wt_prefix:+--prefix "$wt_prefix"} "$@" ;; -add | foreach | init | deinit | set-branch | set-url | status | summary | sync) +*) git ${wt_prefix:+-C "$wt_prefix"} submodule--helper "$command" \ ${quiet:+--quiet} ${cached:+--cached} "$@" ;; From patchwork Fri Jun 10 02:01:31 2022 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: 12876300 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9D38C433EF for ; Fri, 10 Jun 2022 02:02:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345998AbiFJCC5 (ORCPT ); Thu, 9 Jun 2022 22:02:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345960AbiFJCCS (ORCPT ); Thu, 9 Jun 2022 22:02:18 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB457BDA3A for ; Thu, 9 Jun 2022 19:02:06 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id p10so34633101wrg.12 for ; Thu, 09 Jun 2022 19:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2bJNiKchi+yd4bLr8Hs8/H73KcvPvRXcjPn6HIppkwg=; b=I0p6/ZzN+7eRVtOSi/Cqk/pEaT7tOcSFMlQ3EGUGCdXTR639CTy0FZdU2Xwjt28X+k 3x2iTNVfGlwwtv4bFF1qKbz9yLL5re2BMAUwhK7Q//qUxnGbHj8FmxZDh63e3cMmWTVz 6LYsHgSxIOIX9pgPkbYfbMgnPxCi6QM3xNG9tH6JEHIl2KB+O/xU34gn+LmifEgNPt9+ 6nc7O0Jw6SpujH0x7xw0UxaTMqF1M+T0X/dWrasDh11+2i+pY/IEgOpnwAfUwBmvC6Wi iwJd3h4kplqZ7uHZQ4FauCj/avSW0MNmG61BqtapF2A+YN6bIH5OXYx1ufKTOTig6A6s Rn2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2bJNiKchi+yd4bLr8Hs8/H73KcvPvRXcjPn6HIppkwg=; b=x8/GEALh/YiRFA9cK6izHodwvB+GkGc2k7QhAdjMW2X4DWNhFQx8FAY7BDvQ5jb9gf DFUhUb1pw9OqBRRZg7hIAwe0N9y2XLJ0QXGo5DGknrk0Bg2eThLrrXRQSMEpAFkmvK8E Bmg/rovCCIqgWU5QZoUuXpvxTkGr6bNm+TcZOajVqxnfRb48P2nayt/7IVG4tJNvfvAX 2Lj9BYMnR9wn4r5AXPPWpTh4yMYAA3oU9Ip7RkBepfzXFiGqnlt4qzi9QaR3YSReoMeL Ky1g+kY/BR1G+lK0SKCU4soYjE8NGJncMfr3AouAvTJa1QkGt64zTpukfAm5OWBg+tD2 IjRQ== X-Gm-Message-State: AOAM533akJ1iLpS9YrXV5SxmlMI1pp1aOD1jdczOqN9rGgjOmHBMmL0U Qbq/de/geE53ipnN96sBdqhp30wNPzkRZw== X-Google-Smtp-Source: ABdhPJzaCBwCzJYqEpAWqt6I/sKJTDZwWeUN/moO+bdSQUErzMzgj7CzLPG0M7xNZFQdLW85/OyzjA== X-Received: by 2002:adf:f3ce:0:b0:211:55a:a604 with SMTP id g14-20020adff3ce000000b00211055aa604mr40986065wrp.213.1654826524634; Thu, 09 Jun 2022 19:02:04 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.02.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:02:04 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 19/20] submodule: make it a built-in, remove git-submodule.sh Date: Fri, 10 Jun 2022 04:01:31 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Replace the now-trivial git-submodule.sh script with a built-in builtin/submodule.c. For now this new command is only a dumb dispatcher that uses run-command.c to invoke "git submodule--helper", just as "git-submodule.sh" used to do. This is obviously not ideal, and we should follow-up and merge the builtin/submodule--helper.c code into builtin/submodule.c, but doing it this way makes it easy to review that this new C implementation isn't doing anything more clever than the old shellscript implementation. The "define BUILTIN_" macros will help with that, i.e. the usage information we emit can be merged with what builtin/submodule--helper.c is now emitting. See 8757b35d443 (commit-graph: define common usage with a macro, 2021-08-23) and 1e91d3faf6c (reflog: move "usage" variables and use macros, 2022-03-17) for prior art using this pattern. The "(argc < 2 || !strcmp(argv[1], "-h"))" path at the top of cmd_submodule__helper() could now be a "(argc < 2)" if not for t0012-help.sh (which invokes all built-ins manually with "-h"). Let's leave it for now, eventually we'll consolidate the two. Signed-off-by: Ævar Arnfjörð Bjarmason --- Makefile | 2 +- builtin.h | 1 + builtin/submodule.c | 138 ++++++++++++++++++++++++++++++++++++++++++++ git-submodule.sh | 80 ------------------------- git.c | 1 + 5 files changed, 141 insertions(+), 81 deletions(-) create mode 100644 builtin/submodule.c delete mode 100755 git-submodule.sh diff --git a/Makefile b/Makefile index 790382bd1e3..635ab791a8a 100644 --- a/Makefile +++ b/Makefile @@ -622,7 +622,6 @@ SCRIPT_SH += git-merge-resolve.sh SCRIPT_SH += git-mergetool.sh SCRIPT_SH += git-quiltimport.sh SCRIPT_SH += git-request-pull.sh -SCRIPT_SH += git-submodule.sh SCRIPT_SH += git-web--browse.sh SCRIPT_LIB += git-mergetool--lib @@ -1213,6 +1212,7 @@ BUILTIN_OBJS += builtin/show-ref.o BUILTIN_OBJS += builtin/sparse-checkout.o BUILTIN_OBJS += builtin/stash.o BUILTIN_OBJS += builtin/stripspace.o +BUILTIN_OBJS += builtin/submodule.o BUILTIN_OBJS += builtin/submodule--helper.o BUILTIN_OBJS += builtin/symbolic-ref.o BUILTIN_OBJS += builtin/tag.o diff --git a/builtin.h b/builtin.h index 40e9ecc8485..c8cf4a2ae3b 100644 --- a/builtin.h +++ b/builtin.h @@ -223,6 +223,7 @@ int cmd_sparse_checkout(int argc, const char **argv, const char *prefix); int cmd_status(int argc, const char **argv, const char *prefix); int cmd_stash(int argc, const char **argv, const char *prefix); int cmd_stripspace(int argc, const char **argv, const char *prefix); +int cmd_submodule(int argc, const char **argv, const char *prefix); int cmd_submodule__helper(int argc, const char **argv, const char *prefix); int cmd_switch(int argc, const char **argv, const char *prefix); int cmd_symbolic_ref(int argc, const char **argv, const char *prefix); diff --git a/builtin/submodule.c b/builtin/submodule.c new file mode 100644 index 00000000000..b777787169e --- /dev/null +++ b/builtin/submodule.c @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2007-2022 Lars Hjemli & others + * Copyright(c) 2022 Ævar Arnfjörð Bjarmason + */ +#include "builtin.h" +#include "parse-options.h" +#include "run-command.h" +#include "strvec.h" + +#define BUILTIN_SUBMODULE_USAGE \ + "git submodule [--quiet] [--cached]" + +#define BUILTIN_SUBMODULE_ADD_USAGE \ + N_("git submodule [--quiet] add [-b ] [-f | --force] [--name ]\n" \ + " [--reference ] [--] []") + +#define BUILTIN_SUBMODULE_STATUS_USAGE \ + N_("git submodule [--quiet] status [--cached] [--recursive] [--] [...]") + +#define BUILTIN_SUBMODULE_INIT_USAGE \ + N_("git submodule [--quiet] init [--] [...]") + +#define BUILTIN_SUBMODULE_DEINIT_USAGE \ + N_("git submodule [--quiet] deinit [-f | --force] (--all | [--] ...)") + +#define BUILTIN_SUBMODULE_UPDATE_USAGE \ + N_("git submodule [--quiet] update [-v] [--init [--filter=]]\n" \ + " [--remote] [-N | --no-fetch] [-f | --force] [--checkout |--merge | --rebase]\n" \ + " [--[no-]recommend-shallow] [--reference ] [--recursive]\n" \ + " [--[no-]single-branch] [--] [...]") + +#define BUILTIN_SUBMODULE_SET_BRANCH_USAGE \ + N_("git submodule [--quiet] set-branch (--default | --branch ) [--] ") + +#define BUILTIN_SUBMODULE_SET_URL_USAGE \ + N_("git submodule [--quiet] set-url [--] ") + +#define BUILTIN_SUBMODULE_SUMMARY_USAGE \ + N_("git submodule [--quiet] summary [--cached | --files] [--summary-limit ]\n" \ + " [commit] [--] [...]") +#define BUILTIN_SUBMODULE_FOREACH_USAGE \ + N_("git submodule [--quiet] foreach [--recursive] ") + +#define BUILTIN_SUBMODULE_SYNC_USAGE \ + N_("git submodule [--quiet] sync [--recursive] [--] [...]") + +#define BUILTIN_SUBMODULE_ABSORBGITDIRS_USAGE \ + N_("git submodule [--quiet] absorbgitdirs [--] [...]") + +static const char * const git_submodule_usage[] = { + BUILTIN_SUBMODULE_USAGE, + BUILTIN_SUBMODULE_ADD_USAGE, + BUILTIN_SUBMODULE_STATUS_USAGE, + BUILTIN_SUBMODULE_INIT_USAGE, + BUILTIN_SUBMODULE_DEINIT_USAGE, + BUILTIN_SUBMODULE_UPDATE_USAGE, + BUILTIN_SUBMODULE_SET_BRANCH_USAGE, + BUILTIN_SUBMODULE_SET_URL_USAGE, + BUILTIN_SUBMODULE_SUMMARY_USAGE, + BUILTIN_SUBMODULE_FOREACH_USAGE, + BUILTIN_SUBMODULE_SYNC_USAGE, + BUILTIN_SUBMODULE_ABSORBGITDIRS_USAGE, + NULL, +}; + +static void setup_helper_args(int argc, const char **argv, const char *prefix, + int quiet, int cached, struct strvec *args) +{ + const char *cmd; + int do_quiet_cache = 1; + int do_prefix = 1; + + strvec_push(args, "submodule--helper"); + + /* No command word defaults to "status" */ + if (!argc) { + strvec_push(args, "status"); + return; + } + + /* Either a valid command, or submodule--helper will barf! */ + cmd = argv[0]; + strvec_push(args, cmd); + argv++; + argc--; + + /* Options that need to go before user-supplied options */ + if (!strcmp(cmd, "absorbgitdirs")) + do_quiet_cache = 0; + else if (!strcmp(cmd, "update")) + ; + else + do_prefix = 0; + if (do_quiet_cache) { + if (quiet) + strvec_push(args, "--quiet"); + if (cached) + strvec_push(args, "--cached"); + + if (prefix && do_prefix) + strvec_pushl(args, "--prefix", prefix, NULL); + } + + /* All commands get argv, including a "--", if any */ + strvec_pushv(args, argv); +} + +int cmd_submodule(int argc, const char **argv, const char *prefix) +{ + int opt_quiet = 0; + int opt_cached = 0; + struct child_process cp = CHILD_PROCESS_INIT; + struct option options[] = { + OPT__QUIET(&opt_quiet, N_("be quiet")), + OPT_BOOL(0, "cached", &opt_cached, + N_("print the OID of submodules")), + OPT_END() + }; + int ret; + + argc = parse_options(argc, argv, prefix, options, git_submodule_usage, + PARSE_OPT_STOP_AT_NON_OPTION); + + /* + * Tell the rest of git that any URLs we get don't come + * directly from the user, so it can apply policy as appropriate. + */ + strvec_push(&cp.env_array, "GIT_PROTOCOL_FROM_USER=0"); + setup_helper_args(argc, argv, prefix, opt_quiet, opt_cached, + &cp.args); + + cp.git_cmd = 1; + cp.no_stdin = 0; /* for git submodule foreach */ + cp.dir = startup_info->original_cwd; + ret = run_command(&cp); + + return ret; +} diff --git a/git-submodule.sh b/git-submodule.sh deleted file mode 100755 index 0274b253297..00000000000 --- a/git-submodule.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -# -# git-submodule.sh: add, init, update or list git submodules -# -# Copyright (c) 2007 Lars Hjemli - -dashless=$(basename "$0" | sed -e 's/-/ /') -USAGE="[--quiet] [--cached] - or: $dashless [--quiet] add [-b ] [-f|--force] [--name ] [--reference ] [--] [] - or: $dashless [--quiet] status [--cached] [--recursive] [--] [...] - or: $dashless [--quiet] init [--] [...] - or: $dashless [--quiet] deinit [-f|--force] (--all| [--] ...) - or: $dashless [--quiet] update [-v] [--init [--filter=]] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference ] [--recursive] [--[no-]single-branch] [--] [...] - or: $dashless [--quiet] set-branch (--default|--branch ) [--] - or: $dashless [--quiet] set-url [--] - or: $dashless [--quiet] summary [--cached|--files] [--summary-limit ] [commit] [--] [...] - or: $dashless [--quiet] foreach [--recursive] - or: $dashless [--quiet] sync [--recursive] [--] [...] - or: $dashless [--quiet] absorbgitdirs [--] [...]" -OPTIONS_SPEC= -SUBDIRECTORY_OK=Yes -. git-sh-setup -require_work_tree -wt_prefix=$(git rev-parse --show-prefix) -cd_to_toplevel - -# Tell the rest of git that any URLs we get don't come -# directly from the user, so it can apply policy as appropriate. -GIT_PROTOCOL_FROM_USER=0 -export GIT_PROTOCOL_FROM_USER - -quiet= -cached= - -while test $# != 0 -do - case "$1" in - -q|--quiet) - quiet=1 && - shift - ;; - --cached) - cached=1 && - shift - ;; - *) - break - ;; - esac -done - -# No command word defaults to "status" -command= -if test $# = 0 -then - command=status -else - case "$1" in - add | foreach | init | deinit | update | set-branch | set-url | status | summary | sync | absorbgitdirs) - command=$1 && - shift - ;; - *) - usage - esac -fi - -case "$command" in -absorbgitdirs) - git submodule--helper "$command" --prefix "$wt_prefix" "$@" - ;; -update) - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper "$command" \ - ${quiet:+--quiet} ${wt_prefix:+--prefix "$wt_prefix"} "$@" - ;; -*) - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper "$command" \ - ${quiet:+--quiet} ${cached:+--cached} "$@" - ;; -esac diff --git a/git.c b/git.c index 5ff4f3e25b7..047fc262cd2 100644 --- a/git.c +++ b/git.c @@ -609,6 +609,7 @@ static struct cmd_struct commands[] = { { "stash", cmd_stash, RUN_SETUP | NEED_WORK_TREE }, { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE }, { "stripspace", cmd_stripspace }, + { "submodule", cmd_submodule, RUN_SETUP | NEED_WORK_TREE }, { "submodule--helper", cmd_submodule__helper, RUN_SETUP | SUPPORT_SUPER_PREFIX | NO_PARSEOPT }, { "switch", cmd_switch, RUN_SETUP | NEED_WORK_TREE }, { "symbolic-ref", cmd_symbolic_ref, RUN_SETUP }, From patchwork Fri Jun 10 02:01:32 2022 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: 12876299 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68EF5C433EF for ; Fri, 10 Jun 2022 02:02:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346014AbiFJCCk (ORCPT ); Thu, 9 Jun 2022 22:02:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345944AbiFJCCR (ORCPT ); Thu, 9 Jun 2022 22:02:17 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB2F8BDA1C for ; Thu, 9 Jun 2022 19:02:06 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id k16so34649771wrg.7 for ; Thu, 09 Jun 2022 19:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NCR02URZY64Y9Y3s8i3sU/yXPz1Mnc40xeeiSkiJHKw=; b=Z+TyVpxgYBocPn3XEo7i6j5r65clDO3hWkVoIdbXwOkbGaaPNayYNmWWFnbIBoKe4x Ep0MLGUrjEvOvoc/yiZrcysc2o2rKrqd+LXo7ol43J+oQ/W0W5+iiinuiNJ4v72z9Pfk CDUg39He1+ugijqJ86bvgfESZk4CxMZP9ij/1tZh4jsg1d1FAB26oc+yf2U3XTyAH04s gCNyFugnUFwvnpPpiZQ9gjWvszPzQDi8ixLJAAiGvxIbtE595ZJLdGNbVVNx5TTxaeHT xz6mXpmD1ozmZe4TXU3DIMjDyQwBm4NzDNi4TnEmTKEQncbEZAL70zCze+/vYUKQ/Cp+ Rjlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NCR02URZY64Y9Y3s8i3sU/yXPz1Mnc40xeeiSkiJHKw=; b=h+RwcSDZmYLMo7vq8WoQ96EQw06nzY9IMbmg8iVyoJga0qewB0ILXA9uUe877oRsK/ iHud/pD4m8Y2YW8PhyXAf+cRkATrYOLYfqPVKtgmG5Jor+4eGNHUOnlH0Z12Of3G2QCP BYcB6EwC23vSlr5ik/1sTJitIDcaNM6YKulggXXxtQWJa5D2PEHtjvNUuZ61HPSR6jtu zA7d86Z21KQ8lElHjXr8xc4zhxOmisqcV2t1zKHBn5DfKXpb6VzXnDxUduGEvO74vvCB hdgniTlHDh9wa/zEQz7+PrEegbsAGvUBvCefJQ0UDEkMPT2qgSpU3axS0OBZ2J8wIOGg gQ3A== X-Gm-Message-State: AOAM530vv4A1gyFnf5BqJilAqOZeK3ShsNdlvYjJjlNdkPtNeiygA0QS 5sdjC2RQzH8+1NopRgqtZEbNBxfThI65+Q== X-Google-Smtp-Source: ABdhPJzMyFiBSyYPLE3uqsuEUeJu327G2aSHWYjZ2z5rLy4VWpK6NmmrHHumTl7RrW1pT0so9iQuFQ== X-Received: by 2002:adf:e54e:0:b0:218:3fee:b8eb with SMTP id z14-20020adfe54e000000b002183feeb8ebmr23182365wrm.253.1654826525700; Thu, 09 Jun 2022 19:02:05 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m5-20020adffe45000000b00219e8d28fb1sm122547wrs.57.2022.06.09.19.02.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 19:02:04 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Glen Choo , Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [RFC PATCH 20/20] submodule: add a subprocess-less submodule.useBuiltin setting Date: Fri, 10 Jun 2022 04:01:32 +0200 Message-Id: X-Mailer: git-send-email 2.36.1.1178.gb5b1747c546 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add an experimental setting to avoid the subprocess invocation of "git submodule--helper", instead we'll call cmd_submodule__helper() directly. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/config/submodule.txt | 4 ++++ builtin/submodule.c | 35 ++++++++++++++++++++++++++++-- ci/run-build-and-tests.sh | 1 + t/README | 4 ++++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Documentation/config/submodule.txt b/Documentation/config/submodule.txt index 6490527b45b..aa761f331c9 100644 --- a/Documentation/config/submodule.txt +++ b/Documentation/config/submodule.txt @@ -79,6 +79,10 @@ setting. * `branch` is supported only if `submodule.propagateBranches` is enabled +submodule.useBuiltin:: + Set to `true` to use a faster but possibly less stable subprocess-less + implementation of linkgit:git-submodule[1]. Is `false` by default. + submodule.propagateBranches:: [EXPERIMENTAL] A boolean that enables branching support when using `--recurse-submodules` or `submodule.recurse=true`. diff --git a/builtin/submodule.c b/builtin/submodule.c index b777787169e..9bb731ce87a 100644 --- a/builtin/submodule.c +++ b/builtin/submodule.c @@ -6,6 +6,7 @@ #include "parse-options.h" #include "run-command.h" #include "strvec.h" +#include "config.h" #define BUILTIN_SUBMODULE_USAGE \ "git submodule [--quiet] [--cached]" @@ -105,17 +106,33 @@ static void setup_helper_args(int argc, const char **argv, const char *prefix, strvec_pushv(args, argv); } +static int get_use_builtin(void) +{ + int v; + + if (git_env_bool("GIT_TEST_SUBMODULE_USE_BUILTIN", 0)) + v = 1; + else if (!git_config_get_bool("submodule.usebuiltin", &v)) + ; + else if (!git_config_get_bool("feature.experimental", &v)) + ; + + return v; +} + int cmd_submodule(int argc, const char **argv, const char *prefix) { int opt_quiet = 0; int opt_cached = 0; struct child_process cp = CHILD_PROCESS_INIT; + struct strvec args = STRVEC_INIT; struct option options[] = { OPT__QUIET(&opt_quiet, N_("be quiet")), OPT_BOOL(0, "cached", &opt_cached, N_("print the OID of submodules")), OPT_END() }; + const int use_builtin = get_use_builtin(); int ret; argc = parse_options(argc, argv, prefix, options, git_submodule_usage, @@ -125,14 +142,28 @@ int cmd_submodule(int argc, const char **argv, const char *prefix) * Tell the rest of git that any URLs we get don't come * directly from the user, so it can apply policy as appropriate. */ - strvec_push(&cp.env_array, "GIT_PROTOCOL_FROM_USER=0"); + if (use_builtin) + xsetenv("GIT_PROTOCOL_FROM_USER", "0", 1); + else + strvec_push(&cp.env_array, "GIT_PROTOCOL_FROM_USER=0"); + setup_helper_args(argc, argv, prefix, opt_quiet, opt_cached, - &cp.args); + use_builtin ? &args : &cp.args); + + if (use_builtin) { + ret = cmd_submodule__helper(args.nr, args.v, prefix); + goto cleanup; + } cp.git_cmd = 1; cp.no_stdin = 0; /* for git submodule foreach */ cp.dir = startup_info->original_cwd; ret = run_command(&cp); +cleanup: + if (!use_builtin) + /* TODO: Double free? */ + strvec_clear(&args); + return ret; } diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh index 8ebff425967..06d40fc94aa 100755 --- a/ci/run-build-and-tests.sh +++ b/ci/run-build-and-tests.sh @@ -27,6 +27,7 @@ linux-TEST-vars) export GIT_TEST_MULTI_PACK_INDEX=1 export GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=1 export GIT_TEST_ADD_I_USE_BUILTIN=0 + export GIT_TEST_SUBMODULE_USE_BUILTIN=1 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master export GIT_TEST_WRITE_REV_INDEX=1 export GIT_TEST_CHECKOUT_WORKERS=2 diff --git a/t/README b/t/README index 309a31133c6..20c2e74723d 100644 --- a/t/README +++ b/t/README @@ -423,6 +423,10 @@ GIT_TEST_ADD_I_USE_BUILTIN=, when false, disables the built-in version of git add -i. See 'add.interactive.useBuiltin' in git-config(1). +GIT_TEST_SUBMODULE_USE_BUILTIN=, when true, enables the +built-in subprocess-less invocation of "git submodule--helper". +See 'submodule.useBuiltin' in git-config(1). + GIT_TEST_INDEX_THREADS= enables exercising the multi-threaded loading of the index for the whole test suite by bypassing the default number of cache entries and thread minimums. Setting this to 1 will make the