From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh5-smtp.messagingengine.com (fhigh5-smtp.messagingengine.com [103.168.172.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42AB758AA8 for ; Mon, 11 Mar 2024 23:21:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710199297; cv=none; b=W+WUkF8rDt4rpuAkCMOvHvTLx+v/2umstSTFMg99IsY82vkRD0O053jx4k4bIeRTbKenGdcwxalpPAuWZ8sLT2HzgFoIq1x4AMT1/ThgNqcMgQci90kj0ApK1L2mKaiXNvsYLaz0VCbHRmqKpsiXbfN4ZWyb2l35x03k61SHKqw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710199297; c=relaxed/simple; bh=6J1K8xXI8ccHkvlTLr+tCA8Q8kT+xx6hiKZmwO6Olxw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Dkm3x7kDbT8GpJxYDhMQduyYwEWcGO6tySuReX1l1XWdJCq0ezyPDI1b4R/mSVoxNK/wAdcAox7/62F9aNETchXlutmkTSLJ4IJYwrLHcvuEd3Z9ZSbpXxa5ZwqAzcT/HjyEkv/3mTnfiL+FpOkeai8lDpx1nUI549g0H2e75xM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=PySJuAma; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=kDrK7/Ln; arc=none smtp.client-ip=103.168.172.156 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="PySJuAma"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="kDrK7/Ln" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 62D561140116; Mon, 11 Mar 2024 19:21:34 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 11 Mar 2024 19:21:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1710199294; x=1710285694; bh=yidyIQu8aB uGJteqj5ezEJRX2iM8Xv24E85voiVG8OY=; b=PySJuAmaG0YZr/+aeCZvqBvd8p KCDeWTezlLw9z8bpBidwQK2efwJevZZCPNZpuSSZsCu08tZbRl0moxJ0mVQkfGAe HY2bX2OJa+0VbZYNYmvu1uhJAqRA5oDBRRduk5aWP3ORutD4dpHBkOumf+Ajha5+ 9eXlDeGZGprRliP41z/nolGg3T3mijySov0HgMBaS5kyYm6MGLrsb0SVettSkMeA 8CU+tB1fLx0IQccyIxyv9jMziALj3tvsLQTYYIbvRlnKJ9JTSCqLyXl+riaYrrrs fwWoZMSR67YjiewJkEo9sJ60UpzzHa+cHwgA9oXHxEQeZmXH3fK/09bE+/LA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1710199294; x=1710285694; bh=yidyIQu8aBuGJteqj5ezEJRX2iM8 Xv24E85voiVG8OY=; b=kDrK7/LnCUDsB91SmlXgwHJMwvE7cJvAqwoO+Mk0SqC/ 09j0pI6vKIVbUd1yOd533Mf4XrOa+oxi+c9qivGNYq94UPxBKkOvW1WvdedHR896 1YNN3WC/UYmF9FqHaIMrsG5wdfdaJhTBzhQZsRNiR+TPjip8I+ElzeWqFod5nV2n LE8WlNaQOSv9xaWG/wsxMq98koyVtcj2DGwOvYj5JtJZxqodXRihn5+wmlEl7KVW hlTof4c9RqVL3IixaKoYzaF8riaRKGKcVg6VGN6H19XnEsqKppJGKO242VV0uaz0 6oB8rFxsH+gCFL3A1dvZUp5KKU14kL4J66Vc1ds/ZQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrjedvgddutdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefrrghtrhhi tghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrh hnpeeukedtvedtffevleejtefgheehieegkeeluddvfeefgeehgfeltddtheejleffteen ucevlhhushhtvghrufhiiigvpeegnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesph hkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 11 Mar 2024 19:21:32 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 82d447ed (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 11 Mar 2024 23:16:53 +0000 (UTC) Date: Tue, 12 Mar 2024 00:21:25 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Kristoffer Haugsbakk , Taylor Blau , =?iso-8859-1?Q?Jean-No=EBl?= AVILA , Eric Sunshine , Junio C Hamano Subject: [PATCH v2 11/13] builtin/config: introduce "remove-section" subcommand Message-ID: <6314d51cec67d35b5d3e168d67e9d98790367cf0.1710198711.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="+WmKNIH+4sS+4Ryk" Content-Disposition: inline In-Reply-To: --+WmKNIH+4sS+4Ryk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Introduce a new "remove-section" subcommand to git-config(1). Please refer to preceding commits regarding the motivation behind this change. Signed-off-by: Patrick Steinhardt --- Documentation/git-config.txt | 11 +++++++---- builtin/config.c | 32 ++++++++++++++++++++++++++++++++ t/t1300-config.sh | 4 ++-- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt index ebde360c1e..615ed44350 100644 --- a/Documentation/git-config.txt +++ b/Documentation/git-config.txt @@ -14,7 +14,7 @@ SYNOPSIS 'git config set' [] [--type=3D] [--all] [--value=3D] [--fixed-value] 'git config unset' [] [--all] [--value=3D] [--fixed-va= lue] 'git config rename-section' [] -'git config' [] --remove-section +'git config remove-section' [] 'git config' [] --get-colorbool [] 'git config' [] -e | --edit =20 @@ -95,6 +95,9 @@ unset:: rename-section:: Rename the given section to a new name. =20 +remove-section:: + Remove the given section from the configuration file. + [[OPTIONS]] OPTIONS ------- @@ -180,9 +183,6 @@ See also <>. section in linkgit:gitrevisions[7] for a more complete list of ways to spell blob names. =20 ---remove-section:: - Remove the given section from the configuration file. - --fixed-value:: When used with the `value-pattern` argument, treat `value-pattern` as an exact string instead of a regular expression. This will restrict @@ -320,6 +320,9 @@ recommended to migrate to the new syntax. --rename-section :: Replaced by `git config rename-section `. =20 +--remove-section :: + Replaced by `git config remove-section `. + CONFIGURATION ------------- `pager.config` is only respected when listing configuration, i.e., when diff --git a/builtin/config.c b/builtin/config.c index 09e8f47b8e..d3aa5bc298 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -21,6 +21,7 @@ static const char *const builtin_config_usage[] =3D { N_("git config set [] [--type=3D] [--all] [--value=3D<= value>] [--fixed-value] "), N_("git config unset [] [--all] [--value=3D] [--fixed= -value] "), N_("git config rename-section [] "), + N_("git config remove-section [] "), NULL }; =20 @@ -49,6 +50,11 @@ static const char *const builtin_config_rename_section_u= sage[] =3D { NULL }; =20 +static const char *const builtin_config_remove_section_usage[] =3D { + N_("git config remove-section [] "), + NULL +}; + static char *key; static regex_t *key_regexp; static const char *value_pattern; @@ -971,12 +977,38 @@ static int cmd_config_rename_section(int argc, const = char **argv, const char *pr return 0; } =20 +static int cmd_config_remove_section(int argc, const char **argv, const ch= ar *prefix) +{ + struct option opts[] =3D { + CONFIG_LOCATION_OPTIONS, + OPT_END(), + }; + int ret; + + argc =3D parse_options(argc, argv, prefix, opts, builtin_config_remove_se= ction_usage, + PARSE_OPT_STOP_AT_NON_OPTION); + check_write(); + check_argc(argc, 1, 1); + + handle_config_location(prefix); + + ret =3D git_config_rename_section_in_file(given_config_source.file, + argv[0], NULL); + if (ret < 0) + return ret; + else if (!ret) + die(_("no such section: %s"), argv[0]); + + return 0; +} + static struct option builtin_subcommand_options[] =3D { OPT_SUBCOMMAND("list", &subcommand, cmd_config_list), OPT_SUBCOMMAND("get", &subcommand, cmd_config_get), OPT_SUBCOMMAND("set", &subcommand, cmd_config_set), OPT_SUBCOMMAND("unset", &subcommand, cmd_config_unset), OPT_SUBCOMMAND("rename-section", &subcommand, cmd_config_rename_section), + OPT_SUBCOMMAND("remove-section", &subcommand, cmd_config_remove_section), OPT_END(), }; =20 diff --git a/t/t1300-config.sh b/t/t1300-config.sh index 0020296df6..eafecf84a4 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -704,7 +704,7 @@ cat >> .git/config << EOF EOF =20 test_expect_success 'remove section' ' - git config --remove-section branch.zwei + git config ${mode_prefix}remove-section branch.zwei ' =20 cat > expect << EOF @@ -2477,7 +2477,7 @@ test_expect_success 'refuse --fixed-value for incompa= tible actions' ' test_must_fail git config --file=3Dconfig --fixed-value --get-urlmatch de= v.null bogus && test_must_fail git config --file=3Dconfig --fixed-value --get-urlmatch de= v.null bogus && test_must_fail git config ${mode_prefix}rename-section --file=3Dconfig --= fixed-value dev null && - test_must_fail git config --file=3Dconfig --fixed-value --remove-section = dev && + test_must_fail git config ${mode_prefix}remove-section --file=3Dconfig --= fixed-value dev && test_must_fail git config ${mode_prefix}list --file=3Dconfig --fixed-valu= e && test_must_fail git config --file=3Dconfig --fixed-value --get-color dev.n= ull && test_must_fail git config --file=3Dconfig --fixed-value --get-colorbool d= ev.null && --=20 2.44.0 --+WmKNIH+4sS+4Ryk Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEF9hrgiFbCdvenl/rVbJhu7ckPpQFAmXvkfUACgkQVbJhu7ck PpRQ/BAAqA+Uv3sanMo8tAk0z4kc79mYZ9gUEDeWA2r5N6ckqYa/zVDf69CZ7EoG SRJZsDiQXZSoocjH93o45I5ETQCd56O9LdH3w2rXmrDWCZTZVuBDChK6pHPKwgoX vmva9ByvI9SHBn/Lg05VLsMnx2qLarQIqT066w1VL7jfUKT3CotlSfBX+9LCfv/P 9fhYJghwc0XFcCYxk16P3tCtUJ2F8b3tUg4sIp+pkPk3Knd9Csfwr7Zv9FhtmKYG 5TQEoMcO721ewyQHXwMnzy1keWC3d8109w4jRDGXB4S4ZrzXhwCqwCmAeuTL6m/b bIxdohHFTEraTLsXXjRAtwas2gxtEGcGuIeXVmRRDTc6esGmiipP13vlqFKz2b2g r1Lf5g7xIhRAP2JOS9I69ELV3GA7u9KEnKyEv2f7+GL3u1lqDryFRPuIm4PoZAWq Wnj499huAaDC+JRoeA8dD2tJU1H0WWKeDSK8BRQO4oX1S9Z/C4jFjIoZUtiA5EOW LdjiYgrhVrRCwhoM+/naMW4N4hFGvawQwUVsaGFOYH1bPspLcwItud+Yf4Xi/sVQ zMuFIb8l9USIqZyvKc/rR5Fhy3RUW+g5CDuyFDpGhf7XHBI69L80RiOJ+l6AWQq4 KJYfLJnUGkl2PPy3O40Hl+Mc/mY8NuhazPWV/BdWgrVJDTED8+8= =hnyH -----END PGP SIGNATURE----- --+WmKNIH+4sS+4Ryk--