From patchwork Thu Jun 30 21:19: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: 12902227 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 BEFA9C43334 for ; Thu, 30 Jun 2022 21:19:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237438AbiF3VTr (ORCPT ); Thu, 30 Jun 2022 17:19:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237380AbiF3VTo (ORCPT ); Thu, 30 Jun 2022 17:19:44 -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 60A0B45785 for ; Thu, 30 Jun 2022 14:19:43 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id h14-20020a1ccc0e000000b0039eff745c53so354055wmb.5 for ; Thu, 30 Jun 2022 14:19:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=LMV5iBRuQpxuSPV5ejxnm51NvHv5s4keL7wq/0RwQ5I=; b=TCpLHbmcboFc3wUup5UmoasA/PfOiyGZXCXiCmyiXvbBu2Yw7Xnz9wILuNv1SFgZ/Z PU/YDvlScDtn+a5r7IR7FIWjaDDZ+K6uWP9YxRCNRxzeRcD05WibyRDQZjcmB0jfMo16 j1fmtO7AVKnU8OuhP7fXeBbGqRvPAhZ41YlBytcm5wrfskyyMMOUR716xN2Nw6ZZTNua 6iZtlmdCZlDarOhqjBdwisuGyUL2+akFY833LgizXxmQLeYk+UxWW9CxUEgyueYR0fEt +94Fmh1SMyaQ5oYp6zyMlmtCkmz0nGD4L+Ddqj+AJ/nQO53vzB3Fqrzj4uok1PYKwPj7 4fyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=LMV5iBRuQpxuSPV5ejxnm51NvHv5s4keL7wq/0RwQ5I=; b=7iesbuydmDRO5Ow8bmNRp4PdGfu1K893a2b+1yk1VaemKrgcSwtousL7ChjmrDX4JK gvdKv5WRLWULJvih43S815HU+GmfkbGeut6IV5Vh43OXlqR4Vz5tJk+7GMTrvp57DmU3 XhkgdHFuJS/Gzge41LInyK2/IpfwFk33q/9+Z4YcP514GSFFAq8a4dgC3zzvnZvfp38N oN/r4e1DMYZg8S/5n/VWmEiIhwoQW8iZUhDlh3NOdlVKtLwncVmMjVyTY6UkhoAY1zKG Kx2bN2Ya1heJULWayrR5gjGnbcT6LdSJDq6QW7Z1gpS/uy8zmDVBusEgRks/PSd29HeO 55BQ== X-Gm-Message-State: AJIora/pSsggBeArrEzYOoOBVU5Iplkf4BxaeB4DLLgzH3smidWEUlub VHcIugxZ3ZdJEZCnHcTcIDVAgUxVxx8= X-Google-Smtp-Source: AGRyM1vFmyWBL4br6olRQgzIgkIr5GAzFagi5n0Iy12vu/WLO86XdmCQPAFx0bql/K6M4AJ335PMzQ== X-Received: by 2002:a05:600c:4ecc:b0:3a1:68bf:d17a with SMTP id g12-20020a05600c4ecc00b003a168bfd17amr12069361wmq.154.1656623981652; Thu, 30 Jun 2022 14:19:41 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id q13-20020adfdfcd000000b0021b8cd8a068sm20217777wrn.49.2022.06.30.14.19.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:19:40 -0700 (PDT) Message-Id: <85775255f18e0a6a6b2e65394bc18ec440dba99d.1656623978.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:21 +0000 Subject: [PATCH v2 01/18] git-submodule.sh: remove unused sanitize_submodule_env() MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= The sanitize_submodule_env() function was last used before 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 Signed-off-by: Junio C Hamano --- 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 Thu Jun 30 21:19: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: 12902228 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 633CFC43334 for ; Thu, 30 Jun 2022 21:19:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237453AbiF3VTw (ORCPT ); Thu, 30 Jun 2022 17:19:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237423AbiF3VTp (ORCPT ); Thu, 30 Jun 2022 17:19:45 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 952E245784 for ; Thu, 30 Jun 2022 14:19:44 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id k7so346224wrc.12 for ; Thu, 30 Jun 2022 14:19:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=OwbA3auC3v3lvlwF9ecupzl1jyyozPLn60e/JUGVZJc=; b=bZ8bV9Z8J5WKE0ie2xvthHKWg+SRilxFm1cKaFAEKMrjIPqLSqM9Qy1y9TjljhKrgb BMIP6+JYSL4IXckIRyz2B0b7izJMZYsGRNyt+TtszAk24z0RmTwH9d+tisKQfB/FvcUf 3ggQGQk2grMm/kq1umdOXuUtkXG5cuv/S65tFLsFHE7ukgJ5ZcAyuU3rqLFvisKAEHyl Q7b0CVmwzOgDOFROig1Qq738NKRbyKkR/xkbnpvlE82MY8Ci/+U4P75ac7xAq7yt5oFN 07DuSwQuAkxeAo07RqnBladyNv/A4SAf/3iKNP9ZK4VFUbXMmlCd3z3zKF2G1SWbK/H0 T0Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=OwbA3auC3v3lvlwF9ecupzl1jyyozPLn60e/JUGVZJc=; b=KnQzoMX0JyvVT2c4UFgwBrZLf77TmVyeOxN61NQ5Ndxmw7CdlKF9s7srxUW+8eADcI Cwv6hkIhrl601DZG5MDO4iQwyuWYXZMhEryavL3CCExP40vuoC4z2ROQ7jz63nb3er6C LoXoVlZUa6IrY9bV8MTPbW7EUG01M4tIEFYTXihWYM/1jYeFMSgv2YDLMdejJrFVNKLh 2PL/Gs0VYnhMaLJGFsQUBlngoyGG5GwDoGQFY4fpXICSV9Z5o+vN6LHWtjK6DrdICZEk oWdAkN5vbBcoZ5kygLQGLqzbc/i47rNks79QdVZvL/lNuQbmAMc/IeSxC7N3mUbYwjH+ gpfg== X-Gm-Message-State: AJIora8rU/XbspVB/t9ePiMvqkyRps7PuML9LvzCK7X8h1xxfWcyJw1d +GaOKmh/Uh919mGi0QUNzygWTE//sbg= X-Google-Smtp-Source: AGRyM1uhOjkMgWYZj2OLiaUy5NcxLMX7/O6A6mP549GLEuBv92JhUnAqgtvI+Ja/svO7KGgzyg/csg== X-Received: by 2002:a5d:4d02:0:b0:21d:31c5:ed18 with SMTP id z2-20020a5d4d02000000b0021d31c5ed18mr7840538wrt.673.1656623982803; Thu, 30 Jun 2022 14:19:42 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k1-20020a5d6281000000b0021b9e360523sm20862123wru.8.2022.06.30.14.19.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:19:42 -0700 (PDT) Message-Id: <960fad98e8a8d4c123bb5040f616f856cb9925ea.1656623978.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:22 +0000 Subject: [PATCH v2 02/18] git-submodule.sh: remove unused $prefix variable MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Remove the $prefix variable which isn't used anymore, and hasn't been since b3c5f5cb048 (submodule: move core cmd_update() logic to C, 2022-03-15). Before that we'd use it to invoke "git submodule--helper" with the "--recursive-prefix" option, but since b3c5f5cb048 that "git submodule--helper" option is only used when it invokes itself. So the "--recursive-prefix" option is still in use, but at this point only when the helper invokes itself during submodule recursion. See the "--recursive-prefix" option added in c51f8f94e5b (submodule--helper: run update procedures from C, 2021-08-24). Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- 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 Thu Jun 30 21:19: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: 12902229 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 C267DC433EF for ; Thu, 30 Jun 2022 21:19:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233355AbiF3VTx (ORCPT ); Thu, 30 Jun 2022 17:19:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237255AbiF3VTr (ORCPT ); Thu, 30 Jun 2022 17:19:47 -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 8F9A345787 for ; Thu, 30 Jun 2022 14:19:45 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id e28so451743wra.0 for ; Thu, 30 Jun 2022 14:19:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=W1ePcHzxfgzuz+gX0A5j68PuxD+g5ZNhol7Gw34IJ2s=; b=WIGscM7n95sfSudLGloQnZz/bEsqHPEm+Bq4Sy85O87GUAYAOV8j9n7f4tvNfiuhh2 g9UOrfuMmL5dDakPVL3GLuuk7iyPcNLdk5ir0ofktcKHU6SeqwgmjYyJhHpJ82nU4kOt INmVk6JDbGWbA1oS2u/RWls0mtbfJ1sdyBCrW10hQ+8U82nDf7CGOspmWL+ziZMhYCec pOF+qyDSIcFAKQboJrdZzogM/Me56nXm/0r996thDDcatxf2OIdnxLyfjBYl5fKpnliQ sXF/D4Wl8pnS/Mu0cwy2/1DE8ZWnroy0dYlKWCgtLTKfPkwIMvri+o+6WRLtzsOSwB+F m9/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=W1ePcHzxfgzuz+gX0A5j68PuxD+g5ZNhol7Gw34IJ2s=; b=HjtCKFwqPZ3pLmS79otYst0tiw5+20R18r2PV4d75QVxaYIe+fgDE2SUeLMGof5QxO IsIqNi1I1A9eNo91nzPrrGamAcUp/lmGHyONqD8xthDxjoc2j/8tQHVxHUUA9flE/zFy rumyDQ1G+kdpBvTNZMVSFeyfjIQ/UCq5sLpyVLOHJyMbqbV0i7kHUqfOT2KvgJZMrn9P EsOEEWFZ3R7xiqvmhYDblzxBr0co+H6qewfFJuBj15vISs1J+yKFPr7UKSZV5R0kRFqr dA9oBFvksu6/54MXmJEImR7c8ysXQTYM64fRAevE2bk8cq/Xm73hlna6GjIxxLkF0X+O U8kA== X-Gm-Message-State: AJIora8Q6y7YcqNJ4gGD+CQT5GeStnRu2wLLwaM7+xS5f01AxoY0W8kF QNabE7gFk1fGXE0KBbvenLhJii1j5cM= X-Google-Smtp-Source: AGRyM1sjth4rZMnO43gemmhREWasRIGQ1OsfOVSi58hEYfol1Nxp0z8LGNZSgxl5dru9shyLbC4VKg== X-Received: by 2002:adf:f751:0:b0:21a:3ab8:1991 with SMTP id z17-20020adff751000000b0021a3ab81991mr10616926wrp.711.1656623983897; Thu, 30 Jun 2022 14:19:43 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id i8-20020a1c3b08000000b00397402ae674sm4095439wma.11.2022.06.30.14.19.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:19:43 -0700 (PDT) Message-Id: <757d0927976cf9d59a050f8f9ce1fe54d4dff653.1656623978.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:23 +0000 Subject: [PATCH v2 03/18] git-submodule.sh: make the "$cached" variable a boolean MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= 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, not save the "--cached" string for later use. In 28f9af5d25e (git-submodule summary: code framework, 2008-03-11) "$1" was assigned to it, but since there was no reason to do so let's stop doing it. This trivial change will make it easier to reason about an eventual change that'll remove the cmd_summary() function in favor of dispatching to "git submodule--helper summary" directly. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- git-submodule.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index 53847bbf6e2..b99a00d9f84 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" @@ -583,7 +583,7 @@ do branch="$2"; shift ;; --cached) - cached="$1" + cached=1 ;; --) break From patchwork Thu Jun 30 21:19: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: 12902230 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 E48B3C43334 for ; Thu, 30 Jun 2022 21:19:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237445AbiF3VTz (ORCPT ); Thu, 30 Jun 2022 17:19:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237442AbiF3VTr (ORCPT ); Thu, 30 Jun 2022 17:19:47 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AC144578A for ; Thu, 30 Jun 2022 14:19:46 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id s1so363315wra.9 for ; Thu, 30 Jun 2022 14:19:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=IxXdnnILFC293cKAlC+v8xsq2xhaWnv83MwgPd/7bsI=; b=Mj7+lt/njNNiM0eA9FsITiCf+W3uzbOR/hs9+R51DJem2PcFrhYFTkfGzIySQ798DK cm4kQmmSjhsh97AEaKqvyGC1mekXjdhLT0Bu5o24Lm1Jwumcsxf5Iy3+XzdLPBsmmQwS A0uQNK6OxLrUn5B8HOiiLZ/LxaghstM2xpGO+heQuCHmuLaXuW3ppxmc7KX/gwIcsTk9 HOJuSDLUQXVB8XzfEeZojEbYe9UtFpuqI/KcvPhbJZnG8+eQqZ469DHFQ4IWx9Rpd5O0 NW+tdWwgHwAIZ4U/6Bd59jxcW8Fy0q0Ho89eOczDa9+CfLdR91qxOL1GbESAKa+84F03 FXNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=IxXdnnILFC293cKAlC+v8xsq2xhaWnv83MwgPd/7bsI=; b=fesrakUoa4t2XCa0nmqcO6qZVJtFt1X0vNzpSj102kPPwwLBx67QaxzTdaVof3kH57 ZbvOzcUQp1fN5Dj/kKrxkxLqKHN/G5F5xFGax+9Pj9dtca7d2P1BBdeAAiD6AenXx+0b v+QkGw5r+u7j3cGUH1aYRV5eTresKuAcQaMun4Oy7arnu3yfC8r+OJXfOb34LZalXf9R RlitmapdfY08XTx3oa8x6SNby1CMoeGFHCcX3+Wt+K/AxyI3IICWZjivMuBPgTcTIXTo xCQOrvDRz7eDylXoz2h0hvESDmniYQWuqIMppZFHkKOsYdv9i545MdzbSC8MHO6yuvET B3QQ== X-Gm-Message-State: AJIora+CNt6RtJaH/znGSPd2OP3wAEeqCVKdIXuNQ9cVMLxSdt5J6Exd mZeMRmEwI/Usk9QH/80NOs7U8N6/gCU= X-Google-Smtp-Source: AGRyM1uzNizanAX35vrLvYAmHIIZQkHgBULH+cSv7VidSubq5psXg8uqJuE0AlFe84iQjPlxt4jtaA== X-Received: by 2002:a5d:69d2:0:b0:21b:8e3f:8557 with SMTP id s18-20020a5d69d2000000b0021b8e3f8557mr10339597wrw.422.1656623984856; Thu, 30 Jun 2022 14:19:44 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o6-20020adfcf06000000b0021a34023ca3sm20001029wrj.62.2022.06.30.14.19.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:19:44 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:24 +0000 Subject: [PATCH v2 04/18] git-submodule.sh: remove unused top-level "--branch" argument MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= 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, which at a glance 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". So in addition to never having documented this form, it hasn't worked since b57e8119e6e was released with v2.22.0. So it's safe to remove this code. I.e. we don't want to support the form noted above, but only: git submodule (add | set-branch) --branch [] Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- git-submodule.sh | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index b99a00d9f84..20fc1b620fa 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 Thu Jun 30 21:19: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: 12902231 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 C9BCAC433EF for ; Thu, 30 Jun 2022 21:19:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237458AbiF3VT4 (ORCPT ); Thu, 30 Jun 2022 17:19:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237380AbiF3VTt (ORCPT ); Thu, 30 Jun 2022 17:19:49 -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 BD3004D157 for ; Thu, 30 Jun 2022 14:19:47 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id m6-20020a05600c3b0600b003a0489f412cso2787436wms.1 for ; Thu, 30 Jun 2022 14:19:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=B/d9zfDBGBH2WfhA15IekN+oYjG+N/9fpuUdJfBvscY=; b=ee9tNqYIpXpOZlGq2eTxaf80QmHVeo/OWKontjoeYpJGuPjQ3iDlC5fQTV0UKwTXHG HTFL7mnc9fYW7lrJ6foXjnGeiIMgRDss+WNogVxrWRVbRAmshJ0IopTQ6fptC1z2qP1W LSeGpLJ4M4ucfxBt5v4oKP1JxWuRllTjwQu6+lHnWWzrCSvD9SZvh322BblmIQtdEPRO n5DK9WJCJcWQJCHyi/l4HNcTH+sjB2kYCWbn/VbR9gB2+e6Mbe+HZxuKoUWPG4K8JGmH bvargQK1upPWZvGxZmDYaf22OF0/Y+kks9Mg/Jb60T5SoUOKHfMzrXVGG7bH5lovCl3q UX9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=B/d9zfDBGBH2WfhA15IekN+oYjG+N/9fpuUdJfBvscY=; b=wN9qiuTLPcCVk2/sivGzHihi7ARa3/FSFFTDqABzXzVKjam2gdEt0s3X4oQd6CInwQ KJQd6GPiEIsun5zZcNn+JcNqM915Xm0e4B9Mm3toab1Nie9YFINJ4c7F6qnG/r5dtpYJ YxfVoEsjxRumngjgUaazqlfXBInVYfcUhO4teHUExBOsJXF4DEHqWp5FQm0tPbVkPn6T CSKa3PIrcpK6BLMMX8nF357LjnBxp/mk03ioecDf+8E7s8fnyCFobt4+kYw8hjcQ9qNb BxIo5JmV02zcbuDVr7ZktpwGBMCvO8gLwtgwxTmx8ZZUYTuFIcxgNqljcW9p68hqXKgt x+/A== X-Gm-Message-State: AJIora+q99YQenPp+Ksq6E4uHo6uX3W/qHKav9IQoawgVFrjP85ciDIZ yLr65Xl2ZObBVmJ1G4GUZYCHNPudVmw= X-Google-Smtp-Source: AGRyM1sxSE9mQiGqdSz1oXo41432CAteo1OlLZ/aZptHo+CxzNqPHnwWZtK1siXcNdp71cQPE7J9Ow== X-Received: by 2002:a7b:c01a:0:b0:3a1:7ab1:e5dc with SMTP id c26-20020a7bc01a000000b003a17ab1e5dcmr7523731wmb.128.1656623986089; Thu, 30 Jun 2022 14:19:46 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z5-20020adfe545000000b0021b81855c1csm24780322wrm.27.2022.06.30.14.19.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:19:45 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:25 +0000 Subject: [PATCH v2 05/18] submodule--helper: have --require-init imply --init MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= 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. This change doesn't make any difference now, but eliminates another special-case where "git submodule--helper update"'s behavior was different from "git submodule update". This will make it easier to eventually replace the cmd_update() function in git-submodule.sh. We'll still need to keep the distinction between "--init" and "--require-init" in git-submodule.sh. Once cmd_update() gets re-implemented in C we'll be able to change variables and other code related to that, but not yet. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- 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 5c77dfcffee..f0702d0cfa2 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2618,7 +2618,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), @@ -2642,6 +2642,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 20fc1b620fa..5b9683bf766 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -251,7 +251,6 @@ cmd_update() init=1 ;; --require-init) - init=1 require_init=1 ;; --remote) From patchwork Thu Jun 30 21:19: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: 12902232 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 2E1D0C433EF for ; Thu, 30 Jun 2022 21:19:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237266AbiF3VT5 (ORCPT ); Thu, 30 Jun 2022 17:19:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237447AbiF3VTv (ORCPT ); Thu, 30 Jun 2022 17:19:51 -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 D72614D163 for ; Thu, 30 Jun 2022 14:19:48 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id bi22-20020a05600c3d9600b003a04de22ab6so374709wmb.1 for ; Thu, 30 Jun 2022 14:19:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=MmzucdxnE+bxcFGBDoEmUZB3oC12u7RlBA3TNrXoRR4=; b=Ze27xuz7hzmTcvUW1ca3jYXSKeECIvUl386sLovDu0h1qBsRWfLoJTmpR9DTiKH9XP tM/pDU69G2ooCBaPr/Y0tTnqNRHWsgQ1vfkwpWXHPIh+6H27/FpIKhUbdWyPu31mb+0D 5n+xOzs1nmLMpqvtYWvPm+no2e0pJr/TQTKSe7CGQdEwnyQnBREl3MP5omC7+sBTB8v2 PDyBDyREILA9YjgNqOkZEfwr1pQeTy0oZpaC1AeSBPIcOXAp+qLHy8VJjhqaV2/Ggg1t r9OOOldkMoEiYRm/fr5PXFaW61Ahnh35aFoaYvnD0ykBZgosSiIwBsT27hoOYIIvcDQ9 P/2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=MmzucdxnE+bxcFGBDoEmUZB3oC12u7RlBA3TNrXoRR4=; b=Jdwv1ZvAds93s2cp9h5vsClH9oZImYwPVtero9KwloQJ4ypPVGhQyNZkaDmB4K2Mwf xjozvbzNj8DupCTXu7c4uqCmvWlgUtw/FS2dAKM/CEZk3cP7S59/9AeBnw0YnJdFiygq RD7i0TwELuu+CkEiDQ5086tISEZDY6fUVwlfqDb22oXqSfFL+PYOSycTC/DSTEd2doXA MTpZYA5PLz3Gg9y+nFKr43IRQoWJ3EwVwgkOpQjror96kOW1fRGU6cpL/LYJjFqC3bRl FwAamaaRx8+cUYySoq7miS9V57rFsx4g0T/KXIGR00Bb0D75DZFBzc9xQ6eZoeVM+MMw PPBg== X-Gm-Message-State: AJIora+9DNCOHBX57RUho3cs+adukcP4cZcTABYB6oH0uK6BiISvoRGs LJnyXqWhPaBd6kVI5Cn9h921tRZtXYY= X-Google-Smtp-Source: AGRyM1s6H24xhTzbQsI0BC3gsnUkm3EWkHL0FncEq/Ht0Vctw2JClFnzC8awWFEVavcZ9ns3sIkx1w== X-Received: by 2002:a05:600c:3b1c:b0:3a1:729a:387a with SMTP id m28-20020a05600c3b1c00b003a1729a387amr10184670wms.183.1656623987102; Thu, 30 Jun 2022 14:19:47 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g14-20020a05600c4ece00b0039c99f61e5bsm4391037wmq.5.2022.06.30.14.19.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:19:46 -0700 (PDT) Message-Id: <0d68ee723e54330138450f29e358e5ebe1a47aa0.1656623978.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:26 +0000 Subject: [PATCH v2 06/18] submodule update: remove "-v" option MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= 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", but the option was never documented. The only in-tree user has been this test added in 3ad0401e9e6 (submodule update: silence underlying merge/rebase with "--quiet", 2020-09-30), it wasn't per-se testing --quiet, but fixing a bug in e84c3cf3dc3: It used to set "GIT_QUIET=0" instead of unsetting it on "-v", and thus we'd end up passing "--quiet" to "git submodule--helper" on "-v", since the "--quiet" option was passed using the ${parameter:+word} construct. Furthermore, even if someone had used the "-v" option they'd only be getting the default output. Our default in both git-submodule.sh and "git submodule--helper" has been to be "verbose", so the only way this option could have matter is if it were used as e.g.: git submodule --quiet update -v [...] I.e. to undo the effect of a previous "--quiet" on the command-line. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- git-submodule.sh | 3 --- t/t7406-submodule-update.sh | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index 5b9683bf766..0df6b0fc974 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -241,9 +241,6 @@ cmd_update() -q|--quiet) GIT_QUIET=1 ;; - -v) - unset GIT_QUIET - ;; --progress) progress=1 ;; diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index 43f779d751c..06d804e2131 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -1074,7 +1074,7 @@ test_expect_success 'submodule update --quiet passes quietness to merge/rebase' git submodule update --rebase --quiet >out 2>err && test_must_be_empty out && test_must_be_empty err && - git submodule update --rebase -v >out 2>err && + git submodule update --rebase >out 2>err && test_file_not_empty out && test_must_be_empty err ) From patchwork Thu Jun 30 21:19: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: 12902233 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 6C7DEC433EF for ; Thu, 30 Jun 2022 21:20:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237463AbiF3VT7 (ORCPT ); Thu, 30 Jun 2022 17:19:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237449AbiF3VTv (ORCPT ); Thu, 30 Jun 2022 17:19:51 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 051B54D16E for ; Thu, 30 Jun 2022 14:19:49 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id s1so363482wra.9 for ; Thu, 30 Jun 2022 14:19:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=QXTVh5Qm6iit5ZJEERJ5pQzNNyNVLQZG3E5ppXvFz7A=; b=GAKgSrdP0qK9sAh10WT2fIZPSbsazXuLfzqwxDxDiRLe29r9DuUZallmayhSt6MEsw IIqoAv2FSdsOPypCX69N9XrISFBjjkA5cs88Cs9WxtoQ4O4CJmP+IOsTlqok1d0w0MgF fi88avNj9SYrzMtNZQjLWSMBybN+x6L/4/gUpYYM1o0fmNJUuBeq3Qi6oscn1sG06/JC PMzHsnT8RAxLlnC5/TQCjGQ4OzE1kuitIt1sRi+r+DjRJxm00ogqkZ/0MzmuTDCdRdaK EdI6e3xN0p4CzztPDqqtBF7EJsxVdbGRuUtco67kxlRbKueLF2zjP5EwDlPUtdSxFmze 4o1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=QXTVh5Qm6iit5ZJEERJ5pQzNNyNVLQZG3E5ppXvFz7A=; b=q7DHeVqAV7iUW6A4+Te3qUkZuoAVJryD6wBcgF0n2e/zNMX9hHfmgM14VpXDrhXnmA TWj8WxXydfa40LfIm0Nx3BdoZACjaGBufVtIJM1H1N2tOMt7gIa04xKuu6g5u5VJidZV eOu6FMeVHDhPPSEKWwtLfCpTxvfpAwIPqHJuMjNDM0KSyo/1P00MzUXeDVpsGV6ynpei 208b4bw9hHLp0mtS/CzmIxoHBBho01qiO4BngEnH3iw0j1Kl9SHfvbHpTpIonex18Gr2 vO9UXFNE9mHPEA2zb2A72Rgv5CX5NYq1/wK8Bc6cGsoshKESRb8HoE8xx7MjrP03BE+9 in5A== X-Gm-Message-State: AJIora9wQk3rsBmNJAN7BxDDoNqKVcv7L8v0Z0vs/y+wQPROc2g2qkFQ t7TdHOLeBg286qPXwMJ8Vn4fyWP1Nkw= X-Google-Smtp-Source: AGRyM1vjCofnf5n8LWsl5hjrpBffj4nObWrMxJRRZnvtOFUIFlgJqqMo+qWhk3Hm3QReYorNI66dPg== X-Received: by 2002:adf:ed05:0:b0:21b:947c:c97b with SMTP id a5-20020adfed05000000b0021b947cc97bmr10218165wro.509.1656623988315; Thu, 30 Jun 2022 14:19:48 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j8-20020a05600c190800b0039c5642e430sm8727745wmq.20.2022.06.30.14.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:19:47 -0700 (PDT) Message-Id: <6e556c412e9283cfa9f9be4bfe4e9c813a53bf52.1656623978.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:27 +0000 Subject: [PATCH v2 07/18] submodule--helper: rename "absorb-git-dirs" to "absorbgitdirs" MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= 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 eventually dispatch "git submodule--helper" directly, as we'd need to retain this name mapping. So let's get rid of this needless inconsistency. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- 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 f0702d0cfa2..1a84ae8efd2 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2787,7 +2787,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 }; @@ -3389,7 +3389,7 @@ static struct cmd_struct commands[] = { {"deinit", module_deinit, 0}, {"summary", module_summary, SUPPORT_SUPER_PREFIX}, {"push-check", push_check, 0}, - {"absorb-git-dirs", absorb_git_dirs, SUPPORT_SUPER_PREFIX}, + {"absorbgitdirs", absorb_git_dirs, SUPPORT_SUPER_PREFIX}, {"is-active", is_active, 0}, {"check-name", check_name, 0}, {"config", module_config, 0}, diff --git a/git-submodule.sh b/git-submodule.sh index 0df6b0fc974..1c1dc320922 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -552,7 +552,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 4e299f578f9..2af16c647d5 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); if (run_command(&cp)) die(_("could not recurse into submodule '%s'"), path); From patchwork Thu Jun 30 21:19: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: 12902234 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 6363CC433EF for ; Thu, 30 Jun 2022 21:20:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237465AbiF3VUC (ORCPT ); Thu, 30 Jun 2022 17:20:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237454AbiF3VTw (ORCPT ); Thu, 30 Jun 2022 17:19:52 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09F244D4ED for ; Thu, 30 Jun 2022 14:19:51 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id v9so377474wrp.7 for ; Thu, 30 Jun 2022 14:19:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=QL4WIYymIluuBa3/EVgzUsNuZp6cgjTPXWiR0Ih1KWQ=; b=bI+qj4MV+x0IIUbaEqYyLxoijo202ox9iX5prJU0l3m7YODuUpFlmCa9/niFAvLuTf qQD9bjrJ6trUgcgU7IXFKs2hO6DhFylfb84Nkosln64luqx8O7FUnppdm+6MtVUre6Ee k2kX/q5PQ4sDDWe+bZaqiouW1f/I6WE4Y6y6TjhdUj11VrH5yQLehpeiIkJrC8cUdpbL vCB1UGwsVZrRDvY1YNVG2hwYLAKdsozCeeI6mf0tDeHuVTCwEKC0cPIjTzdWfhiQ0IfJ 1RRBsr51yGYBZrGtdJ4Ppl/w5XXXqG4cScY6nhXMNVPEENpNtLzX0yb+rdDcSoNwV2GI RVNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=QL4WIYymIluuBa3/EVgzUsNuZp6cgjTPXWiR0Ih1KWQ=; b=6VUlsl7j6eABMoKIZ5ojuWnN+kkAFXUQ9J0t8cE6P1LDW0sa/gXBQ9/nigS78M8yT3 FW2sJvZDmAZde0giolBpOhs/JxAdlDE0SbQoPn/U1RHBj0NPuvjTZskY78es1v6Axrr8 Hj/vzSI2YCpWDDkZuXtV39G1Yq2CQa8aOEYxzsx4Moe5g/nG/1VZFKiQPkKi5UmMRjtT B0puPbE8spQ3vUI9NKPdT9+R4ncj0xx+7ZYIyQmVJBqLl6ezbcA6jxOcBzp74l5oC9dr aMxN/HgPkxzoH/mr7kFXCqKwb8d+kWQMzCtmOUZ9UHwXA2r4PN7WEOqj+g5lMgXRDpc0 maEA== X-Gm-Message-State: AJIora8xVy85OCyVC3n7nqperZb8Wu0JApU03jh5yFElITFsjYqixPUU 0+kikNQtuM4uZODEmYTeXfDz8no0A7Y= X-Google-Smtp-Source: AGRyM1t04s0UyPMu0+GKaM34Y7SNJs6tpdgi63eqq3ib0XQoeSxDQI9kLw7KkXyUfZdNk1Ro7NHO+w== X-Received: by 2002:a05:6000:1a89:b0:21b:83a9:aa6f with SMTP id f9-20020a0560001a8900b0021b83a9aa6fmr10638370wry.33.1656623989294; Thu, 30 Jun 2022 14:19:49 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id i8-20020a05600c354800b0039c4e2ff7cfsm4268681wmq.43.2022.06.30.14.19.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:19:48 -0700 (PDT) Message-Id: <36d45163b6de05886c2c6feb2e626ce423b96b3b.1656623978.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:28 +0000 Subject: [PATCH v2 08/18] submodule--helper: report "submodule" as our name in some "-h" output MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Change the user-facing "git submodule--helper" commands so that they'll report their name as being "git submodule". To a user these commands are internal implementation details, and it doesn't make sense to emit usage about an internal helper when "git submodule" is invoked with invalid options. Before this we'd emit e.g.: $ git submodule absorbgitdirs --blah error: unknown option `blah' usage: git submodule--helper absorbgitdirs [] [...] [...] And: $ git submodule set-url -- -- usage: git submodule--helper set-url [--quiet] [...] Now we'll start with "usage: git submodule [...]" in both of those cases. This change does not alter the "list", "name", "clone", "config" and "create-branch" commands, those are internal-only (as an aside; their usage info should probably invoke BUG(...)). This only changes the user-facing commands. The "status", "deinit" and "update" commands are not included in this change, because their usage information already used "submodule" rather than "submodule--helper". I don't think it's currently possible to emit some of this usage information in practice, as git-submodule.sh will catch unknown options, and e.g. it doesn't seem to be possible to get "add" to emit its usage information from "submodule--helper". Though that change may be superfluous now, it's also harmless, and will allow us to eventually dispatch further into "git submodule--helper" from git-submodule.sh, while emitting the correct usage output. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 1a84ae8efd2..04d2620fce8 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -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 }; @@ -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 }; @@ -2787,7 +2787,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 }; @@ -2892,7 +2892,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 }; @@ -2931,8 +2931,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 }; @@ -3276,7 +3276,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 Thu Jun 30 21:19: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: 12902235 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 6AB55C433EF for ; Thu, 30 Jun 2022 21:20:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237449AbiF3VUE (ORCPT ); Thu, 30 Jun 2022 17:20:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237446AbiF3VTx (ORCPT ); Thu, 30 Jun 2022 17:19:53 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FE3E45784 for ; Thu, 30 Jun 2022 14:19:52 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id r20so411300wra.1 for ; Thu, 30 Jun 2022 14:19:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=rMOar5gUpSfWxVPjUBSxJ53KbguCezU3u+8n/3UUIWM=; b=d2FKLrYk726htGHiGAHnhX+qhAw8iW8nB49dqLDHZG21O07nzdKVCjrnY6y8ynz5YZ l/OcU6EgLXcKeESTUvfryxAOI6D0RvHfaA1VTMIDQyWqHLOsogSjss3HqrcnLkUk31N6 ejTX+XZN7woxqFSdTNhNyhhCeJ7eXbnmuO0tvU6kpDj7yc9W9MvEzVgVVcsJ2qOqzf7w +s31Qw6GyE9Z34tsT8OI+Q6MyL77B8jSomDS5lQhzbn/bPaRaVbMNPIl910FgemJ1JJr eseoFL5e0xyIg+gFPmonvfs2bdpCXS/CEu+0o3XNLEuVoJzU83p9O/zJKGfIKw97Wq1j UDzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=rMOar5gUpSfWxVPjUBSxJ53KbguCezU3u+8n/3UUIWM=; b=pvVQGy/HMR/niX3sT3ZTHjGWYdugfxzGHw2f2o+GzwATifhjDge9ZlQptxV2o2rjFb DhR87ge6sCcHrlFye4nw6PU/VKd/3Eevb52n8gaYDnyoi1qYlg3TtKIvUJLseogjdyGN 6Oj8/aQQwyCHPqXCPYusqTfvjCGfKfU1acs/HZQbX84+ZfaXpDfr45YYFq4AVbQXGqQh yvHYUch2VsGk9LzD3z69KFkWuLNJHGANH1wat9sXVmYUXo2fzNUXSh04YlDr3q8bXTfL wKb/VwrOvqDjHaRDc0wFYl1bgHAEWYow3CN1+ZgfP4Id7IEglHOTsM7OjfQz9VSmya/d /h/w== X-Gm-Message-State: AJIora9cUoA85aHocBZXbkzHMysf9NqA3XCmc6EJujo4nWj9INlfkOna Zvn0TfewOSf/tUj4igawJSf7Bd9+KTc= X-Google-Smtp-Source: AGRyM1smKIRMTh12G8BpyaVRu7sKO6zJDF8/sqRrFnENFJ7KuBKTF3P+6lLj3CEE65CsumK5ALwXSg== X-Received: by 2002:a05:6000:1148:b0:21b:a4b2:ccd3 with SMTP id d8-20020a056000114800b0021ba4b2ccd3mr10459126wrx.193.1656623990418; Thu, 30 Jun 2022 14:19:50 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id i8-20020a05600c354800b0039c4e2ff7cfsm4268730wmq.43.2022.06.30.14.19.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:19:49 -0700 (PDT) Message-Id: <8f12108c2951cdfa181d6be66b6def28cd007bdd.1656623978.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:29 +0000 Subject: [PATCH v2 09/18] submodule--helper: understand --checkout, --merge and --rebase synonyms MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= 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 Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 30 ++++++++++++++++++++++++++++++ git-submodule.sh | 14 +++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 04d2620fce8..53179472d85 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2404,6 +2404,23 @@ static void ensure_core_worktree(const char *path) } } +static const char *submodule_update_type_to_label(enum submodule_update_type type) +{ + switch (type) { + case SM_UPDATE_CHECKOUT: + return "checkout"; + case SM_UPDATE_MERGE: + return "merge"; + case SM_UPDATE_REBASE: + return "rebase"; + case SM_UPDATE_UNSPECIFIED: + case SM_UPDATE_NONE: + case SM_UPDATE_COMMAND: + break; + } + BUG("unreachable with type %d", type); +} + static void update_data_to_args(struct update_data *update_data, struct strvec *args) { strvec_pushl(args, "submodule--helper", "update", "--recursive", NULL); @@ -2582,6 +2599,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), @@ -2603,6 +2621,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_REBASE), OPT_STRING_LIST(0, "reference", &opt.references, N_("repo"), N_("reference repository")), OPT_BOOL(0, "dissociate", &opt.dissociate, @@ -2652,6 +2679,9 @@ static int module_update(int argc, const char **argv, const char *prefix) opt.filter_options = &filter_options; + if (update_type != SM_UPDATE_UNSPECIFIED) + opt.update_default = submodule_update_type_to_label(update_type); + 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 1c1dc320922..7fc7119fb21 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -40,7 +40,9 @@ require_init= files= remote= nofetch= -update= +rebase= +merge= +checkout= custom_name= depth= progress= @@ -260,7 +262,7 @@ cmd_update() force=$1 ;; -r|--rebase) - update="rebase" + rebase=1 ;; --reference) case "$2" in '') usage ;; esac @@ -274,13 +276,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" @@ -341,7 +343,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 Thu Jun 30 21:19:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12902236 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 04602C43334 for ; Thu, 30 Jun 2022 21:20:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237482AbiF3VUF (ORCPT ); Thu, 30 Jun 2022 17:20:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237084AbiF3VTy (ORCPT ); Thu, 30 Jun 2022 17:19:54 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8542E45787 for ; Thu, 30 Jun 2022 14:19:53 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id o4so398232wrh.3 for ; Thu, 30 Jun 2022 14:19:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=U2SMOt3D2+JQiXyq7ZJfVCLmmaGmBPTWPAtt01OokPw=; b=jO24bCaLlXEfDU6AO6cnw44xIi7WSsVHcJthJrdNfhGJ+MSx5HxTteU/rvxjlPdym1 nKXSnvMgiYeoyGZEzJGx7A/Qn/9SlCjU2pz3DjumweqsisPk1NWymQiMmKhpPC5bKTPp N9Z5kLG7IcIfIGRhxJ4hLV5/m2L/T6a3GOQ1ODfHQPQRXJPX9NEcN5Qr6sFuap9TnZGK fDJGBW3LF3mnZipXgyho/zNvVEJhswDUaLyT+fdGEj/kYnhI2xGcDLEjpxlnJY/eH7iy NE2UkmekHN+pnCuWFDaQA7JIhmqJVac1GdVjcw+fkM3MTfTRY0u2dEnMYCCEZdhKzhEQ BiBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=U2SMOt3D2+JQiXyq7ZJfVCLmmaGmBPTWPAtt01OokPw=; b=OEXuGYiwo+d4TM+Lq6CaO6IIv0ZwWXI6ymytYIZhUEQKmNflEFOJQADH3k0hGEWPTX IboIMOk2hHEaXhx02gqXETItPdAhsBT/GIIPdRG36Mtcx9WJyU2f1N9OmHtgst8GCnG4 jupYHE5m/Tlg0Zekq8viDo2RslSB1ByKf+hrJb64rHWXkzHqyuO6cMl2gEbZ7xCOfxES ZVtaz7BLBi8ik6RMLIljJ37blw1mhwErbsT+z/l9HD3dM0UEVLLfpkjkepTSpWIqM5rA RV7YR9002ErUyOYpiah7VfA1zCSTcVIvJAZN1fmVKw0j0mceYQQUQP+pFoxyeJfepDkD vo4A== X-Gm-Message-State: AJIora95KKE0UR0Oyhq8AO/Yq61Uu9vXKYcnCbnaAmi3HYOwQKrDBGfu XDLAmJvVVqchDEKLiHtGI28L7KzgC1A= X-Google-Smtp-Source: AGRyM1uvP9sSOs69URl1n5G1ZnKD8/stT7Cg3piyxyex8k9MtOwM5sUNUflKZV6gFEnmYH8nyJRO+A== X-Received: by 2002:a05:6000:1ac8:b0:21b:9239:8f28 with SMTP id i8-20020a0560001ac800b0021b92398f28mr10493142wry.517.1656623991722; Thu, 30 Jun 2022 14:19:51 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m12-20020adffe4c000000b0020d106c0386sm19874379wrs.89.2022.06.30.14.19.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:19:51 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:30 +0000 Subject: [PATCH v2 10/18] submodule--helper: eliminate internal "--update" option MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , Glen Choo Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Glen Choo From: Glen Choo Follow-up on the preceding commit which taught "git submodule--helper update" to understand "--merge", "--checkout" and "--rebase" and use those options instead of "--update=(rebase|merge|checkout|none)" when the command invokes itself. Unlike the preceding change this isn't strictly necessary to eventually change "git-submodule.sh" so that it invokes "git submodule--helper update" directly, but let's remove this inconsistency in the command-line interface. We shouldn't need to carry special synonyms for existing options in "git submodule--helper" when that command can use the primary documented names instead. But, as seen in the post-image this makes the control flow within "builtin/submodule--helper.c" simpler, we can now write directly to the "update_default" member of "struct update_data" when parsing the options in "module_update()". Signed-off-by: Glen Choo Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 53179472d85..389b900602f 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1818,7 +1818,7 @@ static int module_clone(int argc, const char **argv, const char *prefix) static void determine_submodule_update_strategy(struct repository *r, int just_cloned, const char *path, - const char *update, + enum submodule_update_type update, struct submodule_update_strategy *out) { const struct submodule *sub = submodule_from_path(r, null_oid(), path); @@ -1828,9 +1828,7 @@ static void determine_submodule_update_strategy(struct repository *r, key = xstrfmt("submodule.%s.update", sub->name); if (update) { - if (parse_submodule_update_strategy(update, out) < 0) - die(_("Invalid update mode '%s' for submodule path '%s'"), - update, path); + out->type = update; } else if (!repo_config_get_string_tmp(r, key, &val)) { if (parse_submodule_update_strategy(val, out) < 0) die(_("Invalid update mode '%s' configured for submodule path '%s'"), @@ -1882,7 +1880,7 @@ struct update_data { const char *prefix; const char *recursive_prefix; const char *displaypath; - const char *update_default; + enum submodule_update_type update_default; struct object_id suboid; struct string_list references; struct submodule_update_strategy update_strategy; @@ -2423,6 +2421,8 @@ static const char *submodule_update_type_to_label(enum submodule_update_type typ static void update_data_to_args(struct update_data *update_data, struct strvec *args) { + enum submodule_update_type update_type = update_data->update_default; + strvec_pushl(args, "submodule--helper", "update", "--recursive", NULL); strvec_pushf(args, "--jobs=%d", update_data->max_jobs); if (update_data->recursive_prefix) @@ -2446,8 +2446,10 @@ static void update_data_to_args(struct update_data *update_data, struct strvec * strvec_push(args, "--require-init"); if (update_data->depth) strvec_pushf(args, "--depth=%d", update_data->depth); - if (update_data->update_default) - strvec_pushl(args, "--update", update_data->update_default, NULL); + if (update_type != SM_UPDATE_UNSPECIFIED) + strvec_pushf(args, "--%s", + submodule_update_type_to_label(update_type)); + if (update_data->references.nr) { struct string_list_item *item; for_each_string_list_item(item, &update_data->references) @@ -2599,7 +2601,6 @@ 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), @@ -2618,16 +2619,13 @@ static int module_update(int argc, const char **argv, const char *prefix) N_("path"), N_("path into the working tree, across nested " "submodule boundaries")), - OPT_STRING(0, "update", &opt.update_default, - N_("string"), - N_("rebase, merge, checkout or none")), - OPT_SET_INT(0, "checkout", &update_type, + OPT_SET_INT(0, "checkout", &opt.update_default, N_("use the 'checkout' update strategy (default)"), SM_UPDATE_CHECKOUT), - OPT_SET_INT('m', "merge", &update_type, + OPT_SET_INT('m', "merge", &opt.update_default, N_("use the 'merge' update strategy"), SM_UPDATE_MERGE), - OPT_SET_INT('r', "rebase", &update_type, + OPT_SET_INT('r', "rebase", &opt.update_default, N_("use the 'rebase' update strategy"), SM_UPDATE_REBASE), OPT_STRING_LIST(0, "reference", &opt.references, N_("repo"), @@ -2679,13 +2677,8 @@ static int module_update(int argc, const char **argv, const char *prefix) opt.filter_options = &filter_options; - if (update_type != SM_UPDATE_UNSPECIFIED) - opt.update_default = submodule_update_type_to_label(update_type); - if (opt.update_default) - if (parse_submodule_update_strategy(opt.update_default, - &opt.update_strategy) < 0) - die(_("bad value for update parameter")); + opt.update_strategy.type = opt.update_default; if (module_list_compute(argc, argv, prefix, &pathspec, &opt.list) < 0) { list_objects_filter_release(&filter_options); From patchwork Thu Jun 30 21:19: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: 12902237 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 848F3CCA473 for ; Thu, 30 Jun 2022 21:20:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230503AbiF3VUH (ORCPT ); Thu, 30 Jun 2022 17:20:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237457AbiF3VT4 (ORCPT ); Thu, 30 Jun 2022 17:19:56 -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 919064D157 for ; Thu, 30 Jun 2022 14:19:54 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id q9so372294wrd.8 for ; Thu, 30 Jun 2022 14:19:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=cIBLDD+97wzDPREu6ywXDSA3a5ZiX5cnBt6UTCqgpi0=; b=nvrzzHwAu56vtAw7gKWm3Zl6tg8St5ATmaWEG2phrOhybqGOuLcCOJiqgHrQmX+O0/ FwpXKYYmcsXzllH6a5yIIVJKyfbQyXTcGJ71KhF1SvhzPcDNfgKFDlNXk4/RkE+iW43Z mwdB0PDIj8++KYHAc6S11jAlDc4crwnnzbupUL7mnmlu+ikwBpB+AV3WDSjkCyun2CmD MSvRocnrCeb35UUIBmzABuU2lMkqnVelycKLlKJPVLOVdi5W5EhgB0nqfU0IwFygHxdh 00RMRGV4CR+25ZwLViV0hHbtxXRosWs/INXDK5fEmp2gsk60ciShDCUPWJU2MMcJGFAU qZnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=cIBLDD+97wzDPREu6ywXDSA3a5ZiX5cnBt6UTCqgpi0=; b=t9tH//Cg2P8J0v4MUtUY3hO0wgEZYnIgtc54tZ/TartRZQzCG3PS9MLWciOxOl9ycU hJn71xlyktWvSpliQOobd6FWZvYjHaQjAh8fD+AEFCkrf5VQynPfMUrO+0knbTeg0r+/ dpIN/eb6nqKdmQkfTcSG1aVOndmXS4iK3pLczomIGg1mwGLKG0BU9sLq1MAV8FIdCYnq 3iiC1lrp5/YxvF+GlQjia9cjWA3nHfBEaHll9exm4IBhndeUoaZmEpZ7EZmq8YftMS97 5IrYBMTu64vyz07EkNRsiTjQGRonqenqxIR7zuvkmSDmX7QrKqoNszVksP+H03ImS1tH bqwA== X-Gm-Message-State: AJIora9fGx3A7G544ppIlZYuX7mdx+s1SyzsejQhP9KpjUBQA3TJyiRE 1lYLPNxcZ+6v7AoVNPaeZhQuE/NISnk= X-Google-Smtp-Source: AGRyM1vFTk+wYgVyWDrpSxpLKJQ0ytf/6kzlJgVsV6HnfUHCEwB2M5tiKLH8YCitHy0u1dAXC9KyWg== X-Received: by 2002:a5d:500a:0:b0:21b:8274:9ddc with SMTP id e10-20020a5d500a000000b0021b82749ddcmr10193313wrt.251.1656623992800; Thu, 30 Jun 2022 14:19:52 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h6-20020a05600c350600b0039c5ab7167dsm3967889wmq.48.2022.06.30.14.19.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:19:52 -0700 (PDT) Message-Id: <2eec463739745d2110aa5462ba9547fa8d255ebb.1656623978.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:31 +0000 Subject: [PATCH v2 11/18] git-submodule.sh: use "$quiet", not "$GIT_QUIET" MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= 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. Now it's obvious that we only care about passing "--quiet" to "git submodule--helper", and not to change the output of any "say" invocation. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- git-submodule.sh | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index 7fc7119fb21..5e5d21c010f 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= branch= force= reference= @@ -80,7 +81,7 @@ cmd_add() force=$1 ;; -q|--quiet) - GIT_QUIET=1 + quiet=1 ;; --progress) progress=1 @@ -128,7 +129,7 @@ cmd_add() 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"} -- "$@" + git ${wt_prefix:+-C "$wt_prefix"} submodule--helper add ${quiet:+--quiet} ${force:+--force} ${progress:+"--progress"} ${branch:+--branch "$branch"} ${reference_path:+--reference "$reference_path"} ${dissociate:+--dissociate} ${custom_name:+--name "$custom_name"} ${depth:+"$depth"} -- "$@" } # @@ -144,7 +145,7 @@ cmd_foreach() do case "$1" in -q|--quiet) - GIT_QUIET=1 + quiet=1 ;; --recursive) recursive=1 @@ -159,7 +160,7 @@ cmd_foreach() shift done - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper foreach ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- "$@" + git ${wt_prefix:+-C "$wt_prefix"} submodule--helper foreach ${quiet:+--quiet} ${recursive:+--recursive} -- "$@" } # @@ -174,7 +175,7 @@ cmd_init() do case "$1" in -q|--quiet) - GIT_QUIET=1 + quiet=1 ;; --) shift @@ -190,7 +191,7 @@ cmd_init() shift done - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper init ${GIT_QUIET:+--quiet} -- "$@" + git ${wt_prefix:+-C "$wt_prefix"} submodule--helper init ${quiet:+--quiet} -- "$@" } # @@ -207,7 +208,7 @@ cmd_deinit() force=$1 ;; -q|--quiet) - GIT_QUIET=1 + quiet=1 ;; --all) deinit_all=t @@ -226,7 +227,7 @@ cmd_deinit() shift done - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper deinit ${GIT_QUIET:+--quiet} ${force:+--force} ${deinit_all:+--all} -- "$@" + git ${wt_prefix:+-C "$wt_prefix"} submodule--helper deinit ${quiet:+--quiet} ${force:+--force} ${deinit_all:+--all} -- "$@" } # @@ -241,7 +242,7 @@ cmd_update() do case "$1" in -q|--quiet) - GIT_QUIET=1 + quiet=1 ;; --progress) progress=1 @@ -335,7 +336,7 @@ cmd_update() done git ${wt_prefix:+-C "$wt_prefix"} submodule--helper update \ - ${GIT_QUIET:+--quiet} \ + ${quiet:+--quiet} \ ${force:+--force} \ ${progress:+"--progress"} \ ${remote:+--remote} \ @@ -396,7 +397,7 @@ cmd_set_branch() { shift done - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper set-branch ${GIT_QUIET:+--quiet} ${branch:+--branch "$branch"} ${default:+--default} -- "$@" + git ${wt_prefix:+-C "$wt_prefix"} submodule--helper set-branch ${quiet:+--quiet} ${branch:+--branch "$branch"} ${default:+--default} -- "$@" } # @@ -409,7 +410,7 @@ cmd_set_url() { do case "$1" in -q|--quiet) - GIT_QUIET=1 + quiet=1 ;; --) shift @@ -425,7 +426,7 @@ cmd_set_url() { shift done - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper set-url ${GIT_QUIET:+--quiet} -- "$@" + git ${wt_prefix:+-C "$wt_prefix"} submodule--helper set-url ${quiet:+--quiet} -- "$@" } # @@ -496,7 +497,7 @@ cmd_status() do case "$1" in -q|--quiet) - GIT_QUIET=1 + quiet=1 ;; --cached) cached=1 @@ -518,7 +519,7 @@ cmd_status() shift done - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper status ${GIT_QUIET:+--quiet} ${cached:+--cached} ${recursive:+--recursive} -- "$@" + git ${wt_prefix:+-C "$wt_prefix"} submodule--helper status ${quiet:+--quiet} ${cached:+--cached} ${recursive:+--recursive} -- "$@" } # # Sync remote urls for submodules @@ -531,7 +532,7 @@ cmd_sync() do case "$1" in -q|--quiet) - GIT_QUIET=1 + quiet=1 shift ;; --recursive) @@ -551,7 +552,7 @@ cmd_sync() esac done - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper sync ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- "$@" + git ${wt_prefix:+-C "$wt_prefix"} submodule--helper sync ${quiet:+--quiet} ${recursive:+--recursive} -- "$@" } cmd_absorbgitdirs() @@ -572,7 +573,7 @@ do command=$1 ;; -q|--quiet) - GIT_QUIET=1 + quiet=1 ;; --cached) cached=1 From patchwork Thu Jun 30 21:19: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: 12902238 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 B4722C433EF for ; Thu, 30 Jun 2022 21:20:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237286AbiF3VUJ (ORCPT ); Thu, 30 Jun 2022 17:20:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237442AbiF3VT4 (ORCPT ); Thu, 30 Jun 2022 17:19:56 -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 A8B3545787 for ; Thu, 30 Jun 2022 14:19:55 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id n185so96389wmn.4 for ; Thu, 30 Jun 2022 14:19:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=VFNypiPxjcXEoUFC0YC83wnkx7VDqrMjOqNrl9aVH3c=; b=BRM1vh9VoznPXgLReSQGalVHR3szo+DQ1SrXAwq5RkdeE7TnRIMdWWW59Mib7m6Vd/ BKtoABHi0Qf3ph8vBgWtCHQV2lQ7Q3Vy3c5ofat+FAln2+YOt07yAeuho+sA8IaSBa0/ FTRUvcS99Aj6Ce0g5SzOnXPdzJn82+3PjVTL/TJX14j9XsYSxRrzXb54P+cc3E6aGkag v+F+sbwtOPTqQUjrISRopIa7Kai8NgQt+G1Mfv+ycb7K7sDZ2WpAKLUFJ5LVrBJ4HGs9 vN8Kde9+SPBruZVAUimTig+PmdyfG/RYT0NdbyGmDfJ96paevRR/hAeCLIigfUe5bA0y Yn1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=VFNypiPxjcXEoUFC0YC83wnkx7VDqrMjOqNrl9aVH3c=; b=lHElEYaSUvsMDImo7w/S6mleUNJwlkQSd2/xm0UvFky3NPc367nyn2r5x2i3TbTYPq LsuDxVlyjAJ2e9CxUMs0J3iyP6vdBb2KxPLVXzSn2IGj1P5DpKSgSKX1r4YNJWGdT+Wp H9yfb5UvDIDhnl7gg1jRqRX8FtG9ROm7UF6sMU8gsk9UDWUWvRGy1g/hAm/DI8o4cEoP OVHKFOr+PHTma1Djmo7NvJruVY01XkluiaQEHDhoJch5EacwkuWxt0ZN0xqDZJJsBOCn M2iraeqw2uw+IwqBeWu0c6y9rPz+dr8KYaKvZvDX0xTS0ZkBIQ5VOECfT0IF4aLs7FtJ A20Q== X-Gm-Message-State: AJIora8i7G/9XSGAnVuGEJhg3ctEX79HvUPxe6Ke6O+jWxHCUWPJoggv hCz7qXZnaz2bpOU5m1+IjUbKvzErRhE= X-Google-Smtp-Source: AGRyM1siKVCa3qMskfTp2ftQuMk/+yFYUub2u20bFnGt59OpsKAG/csM/PVlU7UuiiJm6tOOYOXcQg== X-Received: by 2002:a05:600c:34c4:b0:39c:9236:4e9e with SMTP id d4-20020a05600c34c400b0039c92364e9emr14146198wmq.67.1656623993888; Thu, 30 Jun 2022 14:19:53 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x1-20020a1c7c01000000b003a02b135747sm8016823wmc.46.2022.06.30.14.19.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:19:53 -0700 (PDT) Message-Id: <5b893f7d81eb7feb43662ed8663e2af76a76b4c8.1656623978.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:32 +0000 Subject: [PATCH v2 12/18] git-sh-setup.sh: remove "say" function, change last users MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Remove the "say" function, with various rewrites of the remaining git-*.sh code to C and the preceding change to have git-submodule.sh stop using the GIT_QUIET variable there were only four uses in git-subtree.sh. Let's have it use an "arg_quiet" variable instead, and move the "say" function over to it. The only other use was a trivial message in git-instaweb.sh, since it has never supported the --quiet option (or similar) that code added in 0b624b4ceee (instaweb: restart server if already running, 2009-11-22) can simply use "echo" instead. The remaining in-tree hits from "say" are all for the sibling function defined in t/test-lib.sh. It's safe to remove this function since it has never been documented in Documentation/git-sh-setup.txt. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- contrib/subtree/git-subtree.sh | 15 ++++++++++++--- git-instaweb.sh | 2 +- git-sh-setup.sh | 9 --------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh index 1af1d9653e9..7562a395c24 100755 --- a/contrib/subtree/git-subtree.sh +++ b/contrib/subtree/git-subtree.sh @@ -50,6 +50,14 @@ m,message= use the given message as the commit message for the merge commit indent=0 +# Usage: say [MSG...] +say () { + if test -z "$arg_quiet" + then + printf '%s\n' "$*" + fi +} + # Usage: debug [MSG...] debug () { if test -n "$arg_debug" @@ -60,7 +68,7 @@ debug () { # Usage: progress [MSG...] progress () { - if test -z "$GIT_QUIET" + if test -z "$arg_quiet" then if test -z "$arg_debug" then @@ -146,6 +154,7 @@ main () { eval "$set_args" # Begin "real" flag parsing. + arg_quiet= arg_debug= arg_prefix= arg_split_branch= @@ -161,7 +170,7 @@ main () { case "$opt" in -q) - GIT_QUIET=1 + arg_quiet=1 ;; -d) arg_debug=1 @@ -252,7 +261,7 @@ main () { dir="$(dirname "$arg_prefix/.")" debug "command: {$arg_command}" - debug "quiet: {$GIT_QUIET}" + debug "quiet: {$arg_quiet}" debug "dir: {$dir}" debug "opts: {$*}" debug diff --git a/git-instaweb.sh b/git-instaweb.sh index 4349566c891..c68f49454cd 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -102,7 +102,7 @@ resolve_full_httpd () { start_httpd () { if test -f "$fqgitdir/pid"; then - say "Instance already running. Restarting..." + echo "Instance already running. Restarting..." stop_httpd fi diff --git a/git-sh-setup.sh b/git-sh-setup.sh index ecb60d9e3cb..ce273fe0e48 100644 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -57,15 +57,6 @@ die_with_status () { exit "$status" } -GIT_QUIET= - -say () { - if test -z "$GIT_QUIET" - then - printf '%s\n' "$*" - fi -} - if test -n "$OPTIONS_SPEC"; then usage() { "$0" -h From patchwork Thu Jun 30 21:19:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12902239 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 4AF43C43334 for ; Thu, 30 Jun 2022 21:20:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237457AbiF3VUK (ORCPT ); Thu, 30 Jun 2022 17:20:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237461AbiF3VT6 (ORCPT ); Thu, 30 Jun 2022 17:19:58 -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 1A1964D4ED for ; Thu, 30 Jun 2022 14:19:57 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id t17-20020a1c7711000000b003a0434b0af7so394959wmi.0 for ; Thu, 30 Jun 2022 14:19:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=KW37HpirRMIvOEXY3NYMTI09bimle02oyoeYENKZT/M=; b=hd6+Zpe45wKDBQuMrGjCJ5IIntF4e65CiT4HxqCRIsjxltYmBP4vJIKkuIB0lV9ltw Eyv2cYsXncJGxisJGuIdNg/Ie/xyz6IhGtt5CpDt7MolOCkubEtF29MyST/Pf5DBdb3J qY9kD++K8oJ7fcy5amfjuiAJ545g9EzW8g2Ff7Isg43ruKarbm1d0zjV5/QdDWhkjVpy 4y4QYmhIOkSJDYbB8i3VS+IOYQkuUsuxT0T8Y+0cnZk4Xh7SIOJ4PrBY88qMgxkDeoWt kVCbHxojMweI0yIET8APBA7akgCEuWsmGaXICKnnfEKD8WP2UM9L4VDb3dKk4BuQ2ukD ZHyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=KW37HpirRMIvOEXY3NYMTI09bimle02oyoeYENKZT/M=; b=uF3ta9Q/y3OaloRfAr15WuYQO4ycf+xL2BQpQQgAKvQP+hPFvbUdQzoQ2zQmsw0+2r 5HZuwfQ+htSYLFJ8DmTzLYPkY+b/O6XbhuNKHw5krWCiHDrf/W+RENxho9qgF1mPguDD az6cti5D/D2sySUna8ieBaX4GlVxT1KR6hNVotBvC9H8Cc5xdXGRNqeHpzVqPRu8eUok zrmXfB1JdfSv0qlKT31LuMaMya/kTzWUTD32EW06nlOCJbPHfan8gEVhhY6GkaOl1g/e 8O+EoELvJZ/H+lDiHl7/KMjgzGMCDXAxCbhnlJE5rldvudsAxmzLpWUP1s/Qlqf0BQfC TbsQ== X-Gm-Message-State: AJIora+PW/wisYgvHwxBVs9DzsL/YG6OI6QbL6eI16/IxHkpzS+THi9F 2d7fLt/vhb0WKb0+0bc6MgYjMrghPhY= X-Google-Smtp-Source: AGRyM1top5qYPUYp3pdKZ6L0MjFJnoZh3I8YbmO680vjmtBXbDxUTHM5D9crzjCDtnrH7M6VO8zcKg== X-Received: by 2002:a05:600c:4e51:b0:3a0:4e8d:1e44 with SMTP id e17-20020a05600c4e5100b003a04e8d1e44mr12652625wmq.105.1656623995302; Thu, 30 Jun 2022 14:19:55 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c4f5500b003a0502c620dsm3875543wmq.44.2022.06.30.14.19.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:19:54 -0700 (PDT) Message-Id: <64c138df19670cc615c7bb6cda33f085c17ca837.1656623978.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:33 +0000 Subject: [PATCH v2 13/18] submodule--helper update: use display path helper Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , Glen Choo Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Glen Choo From: Glen Choo There are two locations in prepare_to_clone_next_submodule() that manually calculate the submodule display path, but should just use do_get_submodule_displaypath() for consistency. Do this replacement and reorder the code slightly to avoid computing the display path twice. This code was never tested, and adding tests shows that both these sites have been computing the display path incorrectly ever since they were introduced in 48308681b0 (git submodule update: have a dedicated helper for cloning, 2016-02-29) [1]: - The first hunk puts a "/" between recursive_prefix and ce->name, but recursive_prefix already ends with "/". - The second hunk calls relative_path() on recursive_prefix and ce->name, but relative_path() only makes sense when both paths share the same base directory. This is never the case here: - recursive_prefix is the path from the topmost superproject to the current submodule - ce->name is the path from the root of the current submodule to its submodule. so, e.g. recursive_prefix="super" and ce->name="submodule" produces displayname="../super" instead of "super/submodule". While we're fixing the display names, also fix inconsistent quoting of the submodule name. [1] I verified this by applying the tests to 48308681b0. Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 21 +++++--------- t/t7406-submodule-update.sh | 56 +++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 14 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 389b900602f..db2d5ab7998 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1947,30 +1947,23 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce, const char *update_string; enum submodule_update_type update_type; char *key; - struct strbuf displaypath_sb = STRBUF_INIT; struct strbuf sb = STRBUF_INIT; - const char *displaypath = NULL; + char *displaypath; int needs_cloning = 0; int need_free_url = 0; + displaypath = do_get_submodule_displaypath(ce->name, + suc->update_data->prefix, + suc->update_data->recursive_prefix); + if (ce_stage(ce)) { - if (suc->update_data->recursive_prefix) - strbuf_addf(&sb, "%s/%s", suc->update_data->recursive_prefix, ce->name); - else - strbuf_addstr(&sb, ce->name); - strbuf_addf(out, _("Skipping unmerged submodule %s"), sb.buf); + strbuf_addf(out, _("Skipping unmerged submodule %s"), displaypath); strbuf_addch(out, '\n'); goto cleanup; } sub = submodule_from_path(the_repository, null_oid(), ce->name); - if (suc->update_data->recursive_prefix) - displaypath = relative_path(suc->update_data->recursive_prefix, - ce->name, &displaypath_sb); - else - displaypath = ce->name; - if (!sub) { next_submodule_warn_missing(suc, out, displaypath); goto cleanup; @@ -2060,7 +2053,7 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce, "--no-single-branch"); cleanup: - strbuf_release(&displaypath_sb); + free(displaypath); strbuf_release(&sb); if (need_free_url) free((void*)url); diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index 06d804e2131..f0408c5cc4a 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -1116,4 +1116,60 @@ test_expect_success 'submodule update --filter sets partial clone settings' ' test_cmp_config -C super-filter/submodule blob:none remote.origin.partialclonefilter ' +# NEEDSWORK: Clean up the tests so that we can reuse the test setup. +# Don't reuse the existing repos because the earlier tests have +# intentionally disruptive configurations. +test_expect_success 'setup clean recursive superproject' ' + git init bottom && + test_commit -C bottom "bottom" && + git init middle && + git -C middle submodule add ../bottom bottom && + git -C middle commit -m "middle" && + git init top && + git -C top submodule add ../middle middle && + git -C top commit -m "top" && + git clone --recurse-submodules top top-clean +' + +test_expect_success 'submodule update should skip unmerged submodules' ' + test_when_finished "rm -fr top-cloned" && + cp -r top-clean top-cloned && + + # Create an upstream commit in each repo, starting with bottom + test_commit -C bottom upstream_commit && + # Create middle commit + git -C middle/bottom fetch && + git -C middle/bottom checkout -f FETCH_HEAD && + git -C middle add bottom && + git -C middle commit -m "upstream_commit" && + # Create top commit + git -C top/middle fetch && + git -C top/middle checkout -f FETCH_HEAD && + git -C top add middle && + git -C top commit -m "upstream_commit" && + + # Create a downstream conflict + test_commit -C top-cloned/middle/bottom downstream_commit && + git -C top-cloned/middle add bottom && + git -C top-cloned/middle commit -m "downstream_commit" && + git -C top-cloned/middle fetch --recurse-submodules origin && + test_must_fail git -C top-cloned/middle merge origin/main && + + # Make the update of "middle" a no-op, otherwise we error out + # because of its unmerged state + test_config -C top-cloned submodule.middle.update !true && + git -C top-cloned submodule update --recursive 2>actual.err && + grep -F "Skipping unmerged submodule middle/bottom" actual.err +' + +test_expect_success 'submodule update --recursive skip submodules with strategy=none' ' + test_when_finished "rm -fr top-cloned" && + cp -r top-clean top-cloned && + + test_commit -C top-cloned/middle/bottom downstream_commit && + git -C top-cloned/middle config submodule.bottom.update none && + git -C top-cloned submodule update --recursive 2>actual.err && + grep -F "Skipping submodule ${SQ}middle/bottom${SQ}" actual.err +' + test_done From patchwork Thu Jun 30 21:19:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12902240 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 2E947CCA473 for ; Thu, 30 Jun 2022 21:20:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234838AbiF3VUL (ORCPT ); Thu, 30 Jun 2022 17:20:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237464AbiF3VUB (ORCPT ); Thu, 30 Jun 2022 17:20:01 -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 34E3D4D4F2 for ; Thu, 30 Jun 2022 14:19:57 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id q9so372473wrd.8 for ; Thu, 30 Jun 2022 14:19:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=8cJMTkrSAU6h8A1nOqWo8c80MQ+n6b/lbpr+v1A9LUM=; b=DV6rItXLa1x32PQ3wio4ngMEuMG123UWCuNbmJU2KwS9WeSkDwMcHw8vG6SZVyc2Nb 0aoRHfDZmubO9OhbSpiGAkasoQSszV9ZuySDgZF0eilJzZ3X6zY7TQ6Gse9lwtd7KXja x7f1Gs8gKMt9+BEg5voDSncqUilGu11tlR2bpnrk4GlcquqOnparxQphQIbEiwcDZVrK 0JR+TW5fvP30DRcknwFA+DHDqQckgx4PeJLMxL+9WUN2f7CaXKmB0ZkhpOmMBEaXGZ9z BZCxIu3SisuaQQxIqV3lxzVHTTlKCnI7+DvnihwmYcgDoYbms04zwui+o+yAcZzshcEJ AFKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=8cJMTkrSAU6h8A1nOqWo8c80MQ+n6b/lbpr+v1A9LUM=; b=21ANm5zcDoGHkoKl4MriuZZ/ZMtVPwWWUqXBId8TfZQpgzqTz8F3GY/nYVgtShetHN 2StBWKdvRq+U20MfEmBoONftWFGXRW1R1nhnN6Segwplupg2OmCPaLjKxqOzQ7mb6p9t VOESfYsNWYK8XFMCOgAPt3fR3bRe3lZyCjPJ62UT1e2OSdu7kwBChn24Ttw96LvD+IVi QsEDp22UKVjsqJ7XQ6JeEv2wNQ9r75tcwPhA2D9MbaPgfyx0943uTrO+3twkNGgNcaTU t0dtrEChSKx9U9g9i8E8vwJOjnGIiEyrUwdDjc7VmHV1vFdXcbsRlotBHMq/MNU8zPgr GLUg== X-Gm-Message-State: AJIora9xTtsE8EUM284JkiNT/MvSCN3SBzdVhCgfX92YrrkSbIAnyFNs D+OT5mZPwgapPJhmgk792sZnmSvVw4g= X-Google-Smtp-Source: AGRyM1scWHuXDQZMMxgxKuLTW36xCGv97fYhMc8cMvsIsv2ZWRClNYpSIy82UbEiu8Byc0RZrgFk7w== X-Received: by 2002:a5d:428d:0:b0:21b:a1c1:2b04 with SMTP id k13-20020a5d428d000000b0021ba1c12b04mr10498361wrq.106.1656623996495; Thu, 30 Jun 2022 14:19:56 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v15-20020a5d43cf000000b0021badf3cb26sm24300803wrr.63.2022.06.30.14.19.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:19:55 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:34 +0000 Subject: [PATCH v2 14/18] submodule--helper: don't recreate recursive prefix Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , Glen Choo Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Glen Choo From: Glen Choo update_submodule() uses duplicated code to compute update_data->displaypath and next.recursive_prefix. The latter is just the former with "/" appended to it, and since update_data->displaypath not changed outside of this statement, we can just reuse the already computed result. We can go one step further and remove the reference to next.recursive_prefix altogether. Since it is only used in update_data_to_args() (to compute the "--recursive-prefix" flag for the recursive update child process) we can just use the already computed .displaypath value of there. Delete the duplicated code, and remove the unnecessary reference to next.recursive_prefix. As a bonus, this fixes a memory leak where prefixed_path was never freed (this leak was first reported in [1]). [1] https://lore.kernel.org/git/877a45867ae368bf9e053caedcb6cf421e02344d.1655336146.git.gitgitgadget@gmail.com Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index db2d5ab7998..c104b1a0236 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2418,9 +2418,9 @@ static void update_data_to_args(struct update_data *update_data, struct strvec * strvec_pushl(args, "submodule--helper", "update", "--recursive", NULL); strvec_pushf(args, "--jobs=%d", update_data->max_jobs); - if (update_data->recursive_prefix) - strvec_pushl(args, "--recursive-prefix", - update_data->recursive_prefix, NULL); + if (update_data->displaypath) + strvec_pushf(args, "--recursive-prefix=%s/", + update_data->displaypath); if (update_data->quiet) strvec_push(args, "--quiet"); if (update_data->force) @@ -2516,14 +2516,6 @@ static int update_submodule(struct update_data *update_data) struct update_data next = *update_data; int res; - if (update_data->recursive_prefix) - prefixed_path = xstrfmt("%s%s/", update_data->recursive_prefix, - update_data->sm_path); - else - prefixed_path = xstrfmt("%s/", update_data->sm_path); - - next.recursive_prefix = get_submodule_displaypath(prefixed_path, - update_data->prefix); next.prefix = NULL; oidcpy(&next.oid, null_oid()); oidcpy(&next.suboid, null_oid()); From patchwork Thu Jun 30 21:19:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12902241 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 B69F7C43334 for ; Thu, 30 Jun 2022 21:20:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237485AbiF3VUN (ORCPT ); Thu, 30 Jun 2022 17:20:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237467AbiF3VUC (ORCPT ); Thu, 30 Jun 2022 17:20:02 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 713A945784 for ; Thu, 30 Jun 2022 14:19:58 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id v9so377909wrp.7 for ; Thu, 30 Jun 2022 14:19:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=yBfuDF+rpBseJS48i5Zi60kskOodLK+8rhV3oAiV3lk=; b=Oo+m+dCLLoHC0rldXLrTKg7hTDqxVErKF9Uz9JJBko6NacK6RAE6EKISz4evbxMgGi q/MadDvq2gCXgHV/bfDDytojTQKoJcjRAhWWJFq5+HsNpbnUhwfeEvAc1kAV5kDcYVJg t6wMs5Y8FSSV8vD8C0dulLRCOJXGVz049JtSBM+6OMHnN4O7ymG3apd4R1T08PYrqDtK IhQd5Btl374cZFsgXkKDravk+P+atD9Ykhxzp1awExgpP+Ob2qLyI8acbXPz0Sq3Exv3 QpT1ZYjSBjMnJfhQDJYLkKBhXclit6J04svSxh9952vgLhCH3iTiUZXXfqH0QXF7ZrCl Ll9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=yBfuDF+rpBseJS48i5Zi60kskOodLK+8rhV3oAiV3lk=; b=Tx3q1hrVChHuo9AfyF9HJkVjD34bpnl0DhIiQSVziHly7wUWtyY7DdE2HCS0eoHTdb Csarld0htcvzsntOONEQSXJRyT4uwrH4Du4BTWBHqVp/3SRm8DogtkNhKLw5yy0n5pv9 UuJXHtfn56DPvv+Rp6OEDQvD689jtxRHcvBdEEmshN5NpEUy0HkE/HwzkjhbqlsiCYlJ g+2QebNZ1FKvNqIcC0Jgebv30427fMMmXCXMHo7RU5ciMsU5iehqQaeXglqjAjabi1UM S17dlpF7oxwSL5LmP6DQ1SKjXjWivNX7WnBxZNg8kBs6a3l8kbrRkp6eE6AXC9rWwffx jBxg== X-Gm-Message-State: AJIora+gfCoJjfjDjgFHlXw8qMlFCu6g4UkC9NCCx8VXnkPzX74Krfws FP/wD9udcVb/mvC9I8IxtbDGRfSQUqw= X-Google-Smtp-Source: AGRyM1tgRKGoSvXzc/4g42MbcHNEHTDUWk75EHBG6BysoTpiMCOYgAGaPtXURPZ4yU09ERIjLy8NtQ== X-Received: by 2002:a5d:614e:0:b0:21b:9736:736f with SMTP id y14-20020a5d614e000000b0021b9736736fmr10125725wrt.200.1656623997780; Thu, 30 Jun 2022 14:19:57 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u2-20020a5d5142000000b0021b966abc19sm20242968wrt.19.2022.06.30.14.19.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:19:57 -0700 (PDT) Message-Id: <1f7cf6ffaf1086321061d896c4270955d8ed136e.1656623978.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:35 +0000 Subject: [PATCH v2 15/18] submodule--helper: use correct display path helper Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , Glen Choo Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Glen Choo From: Glen Choo Replace a chunk of code in update_submodule() with an equivalent do_get_submodule_displaypath() invocation. This is already tested by t/t7406-submodule-update.sh:'submodule update --init --recursive from subdirectory', so no tests are added. The two are equivalent because: - Exactly one of recursive_prefix|prefix is non-NULL at a time; prefix is set at the superproject level, and recursive_prefix is set when recursing into submodules. There is also a BUG() statement in get_submodule_displaypath() that asserts that both cannot be non-NULL. - In get_submodule_displaypath(), get_super_prefix() always returns NULL because "--super-prefix" is never passed. Thus calling it is equivalent to calling do_get_submodule_displaypath() with super_prefix = NULL. Therefore: - When recursive_prefix is non-NULL, prefix is NULL, and thus get_submodule_displaypath() just returns prefixed_path. This is identical to calling do_get_submodule_displaypath() with super_prefix = recursive_prefix because the return value is still the concatenation of recursive_prefix + update_data->sm_path. - When prefix is non-NULL, prefixed_path = update_data->sm_path. Thus calling get_submodule_displaypath() with prefixed_path is equivalent to calling do_get_submodule_displaypath() with update_data->sm_path Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index c104b1a0236..aad431f898e 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2464,19 +2464,11 @@ static void update_data_to_args(struct update_data *update_data, struct strvec * static int update_submodule(struct update_data *update_data) { - char *prefixed_path; - ensure_core_worktree(update_data->sm_path); - if (update_data->recursive_prefix) - prefixed_path = xstrfmt("%s%s", update_data->recursive_prefix, - update_data->sm_path); - else - prefixed_path = xstrdup(update_data->sm_path); - - update_data->displaypath = get_submodule_displaypath(prefixed_path, - update_data->prefix); - free(prefixed_path); + update_data->displaypath = do_get_submodule_displaypath(update_data->sm_path, + update_data->prefix, + update_data->recursive_prefix); determine_submodule_update_strategy(the_repository, update_data->just_cloned, update_data->sm_path, update_data->update_default, From patchwork Thu Jun 30 21:19:36 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: 12902242 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 B05BBC43334 for ; Thu, 30 Jun 2022 21:20:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237490AbiF3VU2 (ORCPT ); Thu, 30 Jun 2022 17:20:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237468AbiF3VUC (ORCPT ); Thu, 30 Jun 2022 17:20:02 -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 7530B4F192 for ; Thu, 30 Jun 2022 14:20:00 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id i25so339616wrc.13 for ; Thu, 30 Jun 2022 14:20:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=SVX8g/qQwXmjyZ9syayLZhneY1k1gLJJ1yvEoBqxXMU=; b=fMRVlOBJ4H6pk6L4R4/Ar7IjtQerkh9zIHDzQAFjntOVyne/j9niL7Kb7potkpmqYO JaR3PnNwALd3s8SpChdmuXb1MIDDuDxN/0An2TKRrFnPhTCGniD7oysbTyeA8gBJgXIw /yGunpxm3murLtKu53DUSW2I1tmKAnxKq3KI1ZoETMI3MG2OEsd/sPDXtHuW7fWq9rk2 JzdpXiQfJkyurPxsNej7MhX+PSQTat28FvZWvj8gQeiNluSbxFgc1cEb6YGkm8ukZey4 ZiIoG28qjdCRanF+q75/7r+xAf+xE8Zy44mEAYdiihL75PI4Q/tTSMTFsyU7i9F7kpL6 5/Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=SVX8g/qQwXmjyZ9syayLZhneY1k1gLJJ1yvEoBqxXMU=; b=nm8P7Jt1WIQ+sqz8KqVQeOemLk4ejJNtGYmUxQKnIBDMt/gimnxtFfoy4muNus641T DKOk/eLuImwHWWB81iT7I6Gp6WRP5/jrMxpTQjQpw+OUUngJ4pkKv0twwNvZ6FBF2TJK 32IccmXoqA2sU2RNLtlriRenzICl8fDK2n+mD8LQQk+poKgZ3Dx/ZLbsYS23bjFmG3Ld PdFIi7/70DAqm4iRpA/+OnYJIwBNxHnEDiblM571B4FSLCytt/6XxBFfmDr5i9Vr/O6S Cwk/5Nv/pMhNi5cPpMrrGzFqvtgAMLZ0f3oRRSvIRmNYyCpbL5g+3Et2EjKW5YiBizqq xp0A== X-Gm-Message-State: AJIora++2xm7/bhbyF61jjFrR8O3VHMKTue3orQp53jwejpPKigxdA+z 4q6SOAfCj6vuMYvf8fhl7tHyIBY/Mp4= X-Google-Smtp-Source: AGRyM1vrBKwaK/89YFmN0gwBiU7ZebHzaPl5hbhUaVinebfQI3tj2N2l/Ax4v1mk6CTD20WWb9Azmw== X-Received: by 2002:a5d:6da8:0:b0:21d:2598:4e28 with SMTP id u8-20020a5d6da8000000b0021d25984e28mr10937487wrs.373.1656623998798; Thu, 30 Jun 2022 14:19:58 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bn24-20020a056000061800b0020fe35aec4bsm19533295wrb.70.2022.06.30.14.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:19:58 -0700 (PDT) Message-Id: <85e65f143b602be28c7551729c5e3357118a755b.1656623978.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:36 +0000 Subject: [PATCH v2 16/18] submodule--helper: remove unused SUPPORT_SUPER_PREFIX flags MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Remove the SUPPORT_SUPER_PREFIX flag from "add", "init" and "summary". For the "add" command it hasn't been used since [1], likewise for "init" and "summary" since [2] and [3], respectively. As implemented in 74866d75793 (git: make super-prefix option, 2016-10-07) the SUPPORT_SUPER_PREFIX flag in git.c applies for the entire command, but as implemented in 89c86265576 (submodule helper: support super prefix, 2016-12-08) we assert here in cmd_submodule__helper() that we're not getting the flag unexpectedly. 1. 8c8195e9c3e (submodule--helper: introduce add-clone subcommand, 2021-07-10) 2. 6e7c14e65c8 (submodule update --init: display correct path from submodule, 2017-01-06) 3. 1cf823d8f00 (submodule: remove unnecessary `prefix` based option logic, 2021-06-22) Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index aad431f898e..360309195fb 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -3379,15 +3379,15 @@ static struct cmd_struct commands[] = { {"list", module_list, 0}, {"name", module_name, 0}, {"clone", module_clone, 0}, - {"add", module_add, SUPPORT_SUPER_PREFIX}, + {"add", module_add, 0}, {"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}, + {"init", module_init, 0}, {"status", module_status, SUPPORT_SUPER_PREFIX}, {"sync", module_sync, SUPPORT_SUPER_PREFIX}, {"deinit", module_deinit, 0}, - {"summary", module_summary, SUPPORT_SUPER_PREFIX}, + {"summary", module_summary, 0}, {"push-check", push_check, 0}, {"absorbgitdirs", absorb_git_dirs, SUPPORT_SUPER_PREFIX}, {"is-active", is_active, 0}, From patchwork Thu Jun 30 21:19:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12902244 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 91A30C43334 for ; Thu, 30 Jun 2022 21:20:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237467AbiF3VUn (ORCPT ); Thu, 30 Jun 2022 17:20:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237326AbiF3VUD (ORCPT ); Thu, 30 Jun 2022 17:20:03 -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 CFD404F1A5 for ; Thu, 30 Jun 2022 14:20:01 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id i25so339694wrc.13 for ; Thu, 30 Jun 2022 14:20:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=D14P9bRSfzs4PGO2QYU5H2mNn9nUCxmip9duVa6DOTk=; b=UumH4QtgE/4biKHbxoKMCTsQNAyVXVLqG1UqCjt5UZWSvZVdsk2Ty+/B/5qdEZ5TcU Lb6N66gfkgKCFQCB7YWJFnM+BkdQWp7iWh1aCGGonQTisMUm3c+WjEc2ZYFGDFcKCEXz 55ye0iKE7hWp0Pkr2SH3rswwXdDnH2y7ThHthPURWAIiRgMzxu4QmghWWGlKw87F8LN7 7+Z8Cz1S7DGZz7AfdDk9CXU7Mby+IzL85YOsx2qZwTTZ7LlnKWnuI3NMs9oS46JXGDj+ wflaZh1e28Os76a9+orsfVnUqNZX5ekScAdt6EyzJBfHhNpV3oDtP2TP9YHzu/k3vv1B WyAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=D14P9bRSfzs4PGO2QYU5H2mNn9nUCxmip9duVa6DOTk=; b=HUcgQKHfZLWvhx9Y0NrgmAXTFZktJJtV/8W3yH7FQwlNCXzNW3fgXHQeLNln2Ohmwh erUoe09WCCYv1ELE7d0yljyHdsBkOdHNcPlOsw0uqYRzNW5NBwXn3xNn5o8oKBMk+kwl +Lv7ig0YRnE2mw0VYQRXJV6rPhPDKMMwv2swmDhGYLQxItM5ZonfvqJcMshyaEGIp0F+ uLbyPyTjrXUxzDTy7aKLKXgEmhUHON0Y34chUpVCf3v8m8haCPq0w3oejDcMGGWS3iS9 UQrOm4u3Emw9NfGvmVJrk0kZIldOVu1hsCXYn4LEhUKQ3bM/MRzkzWXT3a04rj1yUqfI 8mkw== X-Gm-Message-State: AJIora/pVOYLcJYi3ZPoGCZZ75WWUzV+EzctiSLx2WbxbuEUKfhfc01n QBiqIJiNwM01oa5volxQfKimq6bqzk0= X-Google-Smtp-Source: AGRyM1tkIZCgOY+RClz9AVdYq9AFqS/1zlI3IN02KJNzTS9hQtmgMPlXa3/UqaKoptKOmYWVc1Vb/A== X-Received: by 2002:a5d:5887:0:b0:21b:c5d0:fd4b with SMTP id n7-20020a5d5887000000b0021bc5d0fd4bmr10861556wrf.244.1656624000004; Thu, 30 Jun 2022 14:20:00 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x2-20020a7bc202000000b0039c18d3fe27sm7721621wmi.19.2022.06.30.14.19.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:19:59 -0700 (PDT) Message-Id: <1d8b6b244dca5908a10e952a7a1ec4f92103f144.1656623978.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:37 +0000 Subject: [PATCH v2 17/18] submodule--helper update: use --super-prefix Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , Glen Choo Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Glen Choo From: Glen Choo Unlike the other subcommands, "git submodule--helper update" uses the "--recursive-prefix" flag instead of "--super-prefix". The two flags are otherwise identical (they only serve to compute the 'display path' of a submodule), except that there is a dedicated helper function to get the value of "--super-prefix". This inconsistency exists because "git submodule update" used to pass "--recursive-prefix" between shell and C (introduced in [1]) before "--super-prefix" was introduced (in [2]), and for simplicity, we kept this name when "git submodule--helper update" was created. Remove "--recursive-prefix" and its associated code from "git submodule--helper update", replacing it with "--super-prefix". To use "--super-prefix", module_update is marked with SUPPORT_SUPER_PREFIX. Note that module_clone must also be marked with SUPPORT_SUPER_PREFIX, otherwise the "git submodule--helper clone" subprocess will fail check because "--super-prefix" is propagated via the environment. [1] 48308681b0 (git submodule update: have a dedicated helper for cloning, 2016-02-29) [2] 74866d7579 (git: make super-prefix option, 2016-10-07) Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 360309195fb..41177332dd8 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -477,22 +477,18 @@ static int starts_with_dot_dot_slash(const char *const path) struct init_cb { const char *prefix; - const char *superprefix; unsigned int flags; }; #define INIT_CB_INIT { 0 } static void init_submodule(const char *path, const char *prefix, - const char *superprefix, unsigned int flags) + unsigned int flags) { const struct submodule *sub; struct strbuf sb = STRBUF_INIT; char *upd = NULL, *url = NULL, *displaypath; - /* try superprefix from the environment, if it is not passed explicitly */ - if (!superprefix) - superprefix = get_super_prefix(); - displaypath = do_get_submodule_displaypath(path, prefix, superprefix); + displaypath = do_get_submodule_displaypath(path, prefix, get_super_prefix()); sub = submodule_from_path(the_repository, null_oid(), path); @@ -566,7 +562,7 @@ static void init_submodule(const char *path, const char *prefix, static void init_submodule_cb(const struct cache_entry *list_item, void *cb_data) { struct init_cb *info = cb_data; - init_submodule(list_item->name, info->prefix, info->superprefix, info->flags); + init_submodule(list_item->name, info->prefix, info->flags); } static int module_init(int argc, const char **argv, const char *prefix) @@ -1878,7 +1874,6 @@ struct submodule_update_clone { struct update_data { const char *prefix; - const char *recursive_prefix; const char *displaypath; enum submodule_update_type update_default; struct object_id suboid; @@ -1954,7 +1949,7 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce, displaypath = do_get_submodule_displaypath(ce->name, suc->update_data->prefix, - suc->update_data->recursive_prefix); + get_super_prefix()); if (ce_stage(ce)) { strbuf_addf(out, _("Skipping unmerged submodule %s"), displaypath); @@ -2416,11 +2411,11 @@ static void update_data_to_args(struct update_data *update_data, struct strvec * { enum submodule_update_type update_type = update_data->update_default; - strvec_pushl(args, "submodule--helper", "update", "--recursive", NULL); - strvec_pushf(args, "--jobs=%d", update_data->max_jobs); if (update_data->displaypath) - strvec_pushf(args, "--recursive-prefix=%s/", + strvec_pushf(args, "--super-prefix=%s/", update_data->displaypath); + strvec_pushl(args, "submodule--helper", "update", "--recursive", NULL); + strvec_pushf(args, "--jobs=%d", update_data->max_jobs); if (update_data->quiet) strvec_push(args, "--quiet"); if (update_data->force) @@ -2468,7 +2463,7 @@ static int update_submodule(struct update_data *update_data) update_data->displaypath = do_get_submodule_displaypath(update_data->sm_path, update_data->prefix, - update_data->recursive_prefix); + get_super_prefix()); determine_submodule_update_strategy(the_repository, update_data->just_cloned, update_data->sm_path, update_data->update_default, @@ -2592,10 +2587,6 @@ static int module_update(int argc, const char **argv, const char *prefix) OPT_STRING(0, "prefix", &opt.prefix, N_("path"), N_("path into the working tree")), - OPT_STRING(0, "recursive-prefix", &opt.recursive_prefix, - N_("path"), - N_("path into the working tree, across nested " - "submodule boundaries")), OPT_SET_INT(0, "checkout", &opt.update_default, N_("use the 'checkout' update strategy (default)"), SM_UPDATE_CHECKOUT), @@ -2681,7 +2672,6 @@ static int module_update(int argc, const char **argv, const char *prefix) module_list_active(&list); info.prefix = opt.prefix; - info.superprefix = opt.recursive_prefix; if (opt.quiet) info.flags |= OPT_QUIET; @@ -3378,9 +3368,9 @@ struct cmd_struct { static struct cmd_struct commands[] = { {"list", module_list, 0}, {"name", module_name, 0}, - {"clone", module_clone, 0}, + {"clone", module_clone, SUPPORT_SUPER_PREFIX}, {"add", module_add, 0}, - {"update", module_update, 0}, + {"update", module_update, SUPPORT_SUPER_PREFIX}, {"resolve-relative-url-test", resolve_relative_url_test, 0}, {"foreach", module_foreach, SUPPORT_SUPER_PREFIX}, {"init", module_init, 0}, From patchwork Thu Jun 30 21:19:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12902243 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 18A93C433EF for ; Thu, 30 Jun 2022 21:20:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236660AbiF3VUm (ORCPT ); Thu, 30 Jun 2022 17:20:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237475AbiF3VUD (ORCPT ); Thu, 30 Jun 2022 17:20:03 -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 CE3E24F1A1 for ; Thu, 30 Jun 2022 14:20:01 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id i25so339734wrc.13 for ; Thu, 30 Jun 2022 14:20:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=nV+nD5lvdlWAYtyGig91Rn2goXZhBQdddCWXXt2jrvo=; b=arc4HmgA9KGM+Zs4EaR6R8d347N71BJNd+hZhzGwcNJcTNfWOKAEn/w1OxQW4DcODd pxcmPvLso3omoJGJorZlQhweq7pph/JI+gvDO+5yLwm9qc6pTJGDTF+cq762xF53yecI 5c62THmhjBuUkoFFFap+HsPSwWjUJ/Af+FWVsk/L/nzJXVkzGIo9anEDcGqj2RCNhqkE TJygFMzm26VwEjI38Fbj+/4FLeEW9mQs4GkdJC6e4ds2es5E2K5kBj5wTXfswifT++EN IolAydhNhFPJAZVRYIZiQ2aoQC4wSfGwPeVOLo8653kc/b2gar90AqrnRLxVUDL6JqBs 5LsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=nV+nD5lvdlWAYtyGig91Rn2goXZhBQdddCWXXt2jrvo=; b=PHkv7nrDLVzlRYEEcCD6CztReVSXQlNqqhC/J2B+lflk19Vn2BrnVdD/mijHEL70Nr VcNxhteHGvZVwQLm7b2qT9sqOaie4QiNF2UhnAGPHb2GrODstNho6G9ABU0hSpcj4dk8 096UEmaptOYsSqnSlX1oSrEMAvd/qhVOnpRsA9x0djZ5JhLWWAi6qHJhVuRPq07WyASe UkFGPoJr6vg6FZKqpEwbykayyB0r57QIVIMhnWuBb5YqOR9qN4kxSeTYwWl/DxK3Ast6 +hZ6ZMRgaUrmaBCNg/n8XZHStTat7A7toEmkVuv1KTzeSxS8zjWSrKZciMMNsMJUCQ2X kiQw== X-Gm-Message-State: AJIora9V+553ThpjXN96dVB9/kG6oz19zAv3+L3qIJefxF9Q4BkFIzie MuvrfQDsqaK4en1LL5MIfVY3BtuF+iw= X-Google-Smtp-Source: AGRyM1t0gJrBqSqIX8W0/3XetfiBS2g0ktsLnES0Z6Yna6I0eTclGdalQaHNNpDpi+DNYc26hv9cBw== X-Received: by 2002:adf:dc09:0:b0:21b:9ec1:f4ab with SMTP id t9-20020adfdc09000000b0021b9ec1f4abmr10489853wri.558.1656624001124; Thu, 30 Jun 2022 14:20:01 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id e10-20020adffd0a000000b0021a3dd1c5d5sm20316457wrr.96.2022.06.30.14.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:20:00 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Thu, 30 Jun 2022 21:19:38 +0000 Subject: [PATCH v2 18/18] submodule--helper: remove display path helper Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Atharva Raykar , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7A=?= Bjarmason , Johannes Schindelin , Glen Choo , Glen Choo Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Glen Choo From: Glen Choo All invocations of do_get_submodule_displaypath() pass get_super_prefix() as the super_prefix arg, which is exactly the same as get_submodule_displaypath(). Replace all calls to do_get_submodule_displaypath() with get_submodule_displaypath(), and since it has no more callers, remove it. Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 41177332dd8..3e0ceb52589 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -118,10 +118,11 @@ static int resolve_relative_url_test(int argc, const char **argv, const char *pr return 0; } -static char *do_get_submodule_displaypath(const char *path, - const char *prefix, - const char *super_prefix) +/* the result should be freed by the caller. */ +static char *get_submodule_displaypath(const char *path, const char *prefix) { + const char *super_prefix = get_super_prefix(); + if (prefix && super_prefix) { BUG("cannot have prefix '%s' and superprefix '%s'", prefix, super_prefix); @@ -137,13 +138,6 @@ static char *do_get_submodule_displaypath(const char *path, } } -/* the result should be freed by the caller. */ -static char *get_submodule_displaypath(const char *path, const char *prefix) -{ - const char *super_prefix = get_super_prefix(); - return do_get_submodule_displaypath(path, prefix, super_prefix); -} - static char *compute_rev_name(const char *sub_path, const char* object_id) { struct strbuf sb = STRBUF_INIT; @@ -488,7 +482,7 @@ static void init_submodule(const char *path, const char *prefix, struct strbuf sb = STRBUF_INIT; char *upd = NULL, *url = NULL, *displaypath; - displaypath = do_get_submodule_displaypath(path, prefix, get_super_prefix()); + displaypath = get_submodule_displaypath(path, prefix); sub = submodule_from_path(the_repository, null_oid(), path); @@ -1947,9 +1941,8 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce, int needs_cloning = 0; int need_free_url = 0; - displaypath = do_get_submodule_displaypath(ce->name, - suc->update_data->prefix, - get_super_prefix()); + displaypath = + get_submodule_displaypath(ce->name, suc->update_data->prefix); if (ce_stage(ce)) { strbuf_addf(out, _("Skipping unmerged submodule %s"), displaypath); @@ -2461,9 +2454,8 @@ static int update_submodule(struct update_data *update_data) { ensure_core_worktree(update_data->sm_path); - update_data->displaypath = do_get_submodule_displaypath(update_data->sm_path, - update_data->prefix, - get_super_prefix()); + update_data->displaypath = get_submodule_displaypath( + update_data->sm_path, update_data->prefix); determine_submodule_update_strategy(the_repository, update_data->just_cloned, update_data->sm_path, update_data->update_default,