From patchwork Mon Apr 19 15:56:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 12212173 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93F0BC433B4 for ; Mon, 19 Apr 2021 15:55:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79B5A6128C for ; Mon, 19 Apr 2021 15:55:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241463AbhDSPz4 (ORCPT ); Mon, 19 Apr 2021 11:55:56 -0400 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:33955 "EHLO wout4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241383AbhDSPzy (ORCPT ); Mon, 19 Apr 2021 11:55:54 -0400 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id C05B3FCF; Mon, 19 Apr 2021 11:55:24 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Mon, 19 Apr 2021 11:55:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=RiNj+dlrUouRf9EQSaYZXlCudQy Ep3xGtXhRTaEhOVw=; b=PL/NmXS/nxy2wH6+1fWR0celRAcwoRro5QFf5u7lJ4g w9CIIX9rJOeyVsvGtzQzrNWekvCxj22yDcfWrWg+8VI4ueUZYsxMkXxOhw/maHks XBdrK/vvvCBongh6vLGC/3NMybYI+eM1OGoepImmMwQzSypbcO7fVKJR1S1cjamc XoTBZtX7Qfv0qiy/C3oaLOZU6KZcQ3ow9YsQWLI/gWLm6N4lXDeUAWjbxyx63IqV V0B8jkDIi2yoXPVCuMwNVAh8YPw+DFGYXF8GtZJBGu8y45KSh0fn/wS7LiwR+Cox Mu86cKPtapdu9kZfxX8EYmn8DF/Jhdn0VagOdzJBBPQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=RiNj+d lrUouRf9EQSaYZXlCudQyEp3xGtXhRTaEhOVw=; b=bHAU+7pKNM66O2XsZ2rbc+ FX9zmDdDVFJbt+HejTkEuWjZD8tJhJCCH90IqfwnnizYTOIMLJlkkveJcqSVq3ss 8C0foQLJetta8fAnlaiFd9eF80z0zR9OP35lmKox93N/HiVr8dDlzSiPPqy6T2ki ZyFZ5t4IAnZxZp3KAANtFtJHzJPwmDYYYrP0BhLE9kUheyGtDUJq5q9ZNNFSNprZ wIBpls83tq9cblYXygYqOp043G4aja0UIRPDYZlEcpsjIFNEIGEC1gKLF84fKL75 bbjLRN2qz1oxAcD8aayG2eXhBCSeS8inGqZVydNijxWd/hR7G3nc+CkYtAIHFq4A == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvddtgedgleehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtudenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnheptdffjeeiudduleehvdfgteeifeelheejte dvteduiedttedvtdffffefhfdvgffgnecukfhppeejjedrudeluddrieekrdektdenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesphhksh drihhm X-ME-Proxy: Received: from vm-mail.pks.im (x4dbf4450.dyn.telefonica.de [77.191.68.80]) by mail.messagingengine.com (Postfix) with ESMTPA id ABC1E24005C; Mon, 19 Apr 2021 11:55:23 -0400 (EDT) Received: from localhost (tanuki [10.192.0.23]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 86788e5f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 19 Apr 2021 15:55:22 +0000 (UTC) Date: Mon, 19 Apr 2021 17:56:50 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: =?iso-8859-1?q?=C6var_Arnfj=F6r=F0?= Bjarmason , Jeff King Subject: [PATCH 1/2] git.txt: fix synopsis of `--config-env` missing the equals sign Message-ID: <08049f3b1088a301ea87db9a69454a2516b9525b.1618847606.git.ps@pks.im> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When executing `git -h`, then the `--config-env` documentation rightly lists the option as requiring an equals between the option and its argument: this is the only currently supported format. But the git(1) manpage incorrectly lists the option as taking a space in between. Fix the issue by adding the missing space. Reported-by: Ævar Arnfjörð Bjarmason Signed-of-by: Patrick Steinhardt --- Documentation/git.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/git.txt b/Documentation/git.txt index 3a9c44987f..ba5c8e9d98 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -13,7 +13,7 @@ SYNOPSIS [--exec-path[=]] [--html-path] [--man-path] [--info-path] [-p|--paginate|-P|--no-pager] [--no-replace-objects] [--bare] [--git-dir=] [--work-tree=] [--namespace=] - [--super-prefix=] [--config-env =] + [--super-prefix=] [--config-env==] [] DESCRIPTION From patchwork Mon Apr 19 15:56:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 12212175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B49EC433ED for ; Mon, 19 Apr 2021 15:55:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E7F461285 for ; Mon, 19 Apr 2021 15:55:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241684AbhDSP4D (ORCPT ); Mon, 19 Apr 2021 11:56:03 -0400 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:43875 "EHLO wout4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241544AbhDSPz7 (ORCPT ); Mon, 19 Apr 2021 11:55:59 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 4F8B710D2; Mon, 19 Apr 2021 11:55:29 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 19 Apr 2021 11:55:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=UpXBPpEkROKfBi1usARRSuAMxTM SdZQMgMByA4PuPJE=; b=USWHz35q/tB/G9DgMGJJDrm62YtRDv20mjTK5a5vyNL VnZEeq/qw1SrjXH6EtvNBddcL2e5UqNnhwgIguZSd2/s61ekqCd/NHM+G3ztEFIA QPtLMIMue+6uP/flULzA+DyP+bBGWRLJf5CNE9zkbVkvTKPBlWfsSfjdvBAyZnis 4th5kCkXa3qedHE6lv3c0opZ2iHanJi66z9ztwveVSrPT6+mZkAme4qoKjVcg/lV o2VWfja3Qj3mmMKWyGx8Q94r9ID/pBWNyVDU5Wr1UcGawSh4SqpCMASHkPorN7eq nwdGNLdOxZhaDMcqfcWnN5VC/QzghSkAJiSQTScC0gA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=UpXBPp EkROKfBi1usARRSuAMxTMSdZQMgMByA4PuPJE=; b=AOORil2vp9VHQ6RWi0NWoH KhOyfcE5kkeAKDN9kbtl9ymaQccYGkky/RfSYm+wNBDCn8+C+bkTyBnFrGeIHEva nGHgoKiywaW5lHe75jgdMndQe1vKKVB0lF4WvMclbnU2buAV6GRYKsoGr/yoVnoN x04eLoFiJMLziKSM/CWh7tMbEEba4tieFXD6h6twYVHeX1VcPrgFaN1k5FvRMSqE 73lbi7XtxS+zfP6yUVNM1J5Gq6nznEz7QyRT0FeQqs9ff0ebNsT+tQwYAdqlF2Ar eXWPjTGZRDUdW0HwT9SOXMpVwlwUovHN+QwP+dB+Sbw5WxUzlrOo2eyLUivgNkQA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvddtgedgleeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecukfhppeejjedrudeluddrieekrdektdenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesphhksh drihhm X-ME-Proxy: Received: from vm-mail.pks.im (x4dbf4450.dyn.telefonica.de [77.191.68.80]) by mail.messagingengine.com (Postfix) with ESMTPA id 4F8A724005D; Mon, 19 Apr 2021 11:55:28 -0400 (EDT) Received: from localhost (tanuki [10.192.0.23]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id ae84bfd6 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 19 Apr 2021 15:55:27 +0000 (UTC) Date: Mon, 19 Apr 2021 17:56:55 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: =?iso-8859-1?q?=C6var_Arnfj=F6r=F0?= Bjarmason , Jeff King Subject: [PATCH 2/2] git: support separate arg for `--config-env`'s value Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org While not documented as such, many of the top-level options like `--git-dir` and `--work-tree` support two syntaxes: they accept both an equals sign between option and its value, and they do support option and value as two separate arguments. The recently added `--config-env` option only supports the syntax with an equals sign. Mitigate this inconsistency by accepting both syntaxes and add tests to verify both work. Signed-off-by: Patrick Steinhardt --- git.c | 8 ++++++++ t/t1300-config.sh | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/git.c b/git.c index b53e665671..ad365c05c7 100644 --- a/git.c +++ b/git.c @@ -255,6 +255,14 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) git_config_push_parameter((*argv)[1]); (*argv)++; (*argc)--; + } else if (!strcmp(cmd, "--config-env")) { + if (*argc < 2) { + fprintf(stderr, _("no config key given for --config-env\n" )); + usage(git_usage_string); + } + git_config_push_env((*argv)[1]); + (*argv)++; + (*argc)--; } else if (skip_prefix(cmd, "--config-env=", &cmd)) { git_config_push_env(cmd); } else if (!strcmp(cmd, "--literal-pathspecs")) { diff --git a/t/t1300-config.sh b/t/t1300-config.sh index e0dd5d65ce..18803f9953 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -1374,16 +1374,29 @@ test_expect_success 'git --config-env=key=envvar support' ' cat >expect <<-\EOF && value value + value + value + false false EOF { ENVVAR=value git --config-env=core.name=ENVVAR config core.name && + ENVVAR=value git --config-env core.name=ENVVAR config core.name && ENVVAR=value git --config-env=foo.CamelCase=ENVVAR config foo.camelcase && - ENVVAR= git --config-env=foo.flag=ENVVAR config --bool foo.flag + ENVVAR=value git --config-env foo.CamelCase=ENVVAR config foo.camelcase && + ENVVAR= git --config-env=foo.flag=ENVVAR config --bool foo.flag && + ENVVAR= git --config-env foo.flag=ENVVAR config --bool foo.flag } >actual && test_cmp expect actual ' +test_expect_success 'git --config-env with missing value' ' + test_must_fail env ENVVAR=value git --config-env 2>error && + test_i18ngrep "no config key given for --config-env" error && + test_must_fail env ENVVAR=value git --config-env config core.name 2>error && + test_i18ngrep "invalid config format: config" error +' + test_expect_success 'git --config-env fails with invalid parameters' ' test_must_fail git --config-env=foo.flag config --bool foo.flag 2>error && test_i18ngrep "invalid config format: foo.flag" error &&