git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Glen Choo" <chooglen@google.com>,
	"Jonas Bernoulli" <jonas@bernoul.li>, "Jeff King" <peff@peff.net>,
	"Emily Shaffer" <emilyshaffer@google.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH 08/10] submodule: support "--" with no other arguments
Date: Mon, 17 Oct 2022 14:09:23 +0200	[thread overview]
Message-ID: <patch-08.10-8dbb81e2fa5-20221017T115544Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-00.10-00000000000-20221017T115544Z-avarab@gmail.com>

Address an edge case that "git-submodule.sh" has had all along, but
which became painfully obvious in the *.sh to *.c migration in the
preceding commit.

We didn't support the "--" delimiter in the argument-less
invocation. Let's not bend over backwards to behave unusually in this
scenario, simply accepting "--" is harmless.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 Documentation/git-submodule.txt |  2 +-
 builtin/submodule.c             | 12 ++----------
 t/t7400-submodule-basic.sh      |  4 ++--
 3 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index 4d3ab6b9f92..345ebcafb9c 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -9,7 +9,7 @@ git-submodule - Initialize, update or inspect submodules
 SYNOPSIS
 --------
 [verse]
-'git submodule' [--quiet] [--cached]
+'git submodule' [--quiet] [--cached] [--]
 'git submodule' [--quiet] add [<options>] [--] <repository> [<path>]
 'git submodule' [--quiet] status [--cached] [--recursive] [--] [<path>...]
 'git submodule' [--quiet] init [--] [<path>...]
diff --git a/builtin/submodule.c b/builtin/submodule.c
index 7e3499f3376..1d77f2d0964 100644
--- a/builtin/submodule.c
+++ b/builtin/submodule.c
@@ -8,7 +8,7 @@
 #include "strvec.h"
 
 #define BUILTIN_SUBMODULE_USAGE \
-	"git submodule [--quiet] [--cached]"
+	"git submodule [--quiet] [--cached] [--]"
 
 #define BUILTIN_SUBMODULE_ADD_USAGE \
 	N_("git submodule [--quiet] add [-b <branch>] [-f | --force] [--name <name>]\n" \
@@ -91,14 +91,6 @@ static void setup_helper_args(int argc, const char **argv, const char *prefix,
 	argv++;
 	argc--;
 
-	/*
-	  * This is stupid, but don't support "[--]" to
-	 * subcommand-less "git-submodule" for now.
-	 */
-	if (!strcmp(cmd, "--") || !strcmp(cmd, "--end-of-options"))
-		usage_msg_optf(_("need explicit sub-command name to delimit with '%s'"),
-			       git_submodule_usage, options, cmd);
-
 	/* Options that need to go before user-supplied options */
 	if (!strcmp(cmd, "absorbgitdirs"))
 		do_quiet_cache = 0;
@@ -133,7 +125,7 @@ int cmd_submodule(int argc, const char **argv, const char *prefix)
 	};
 
 	argc = parse_options(argc, argv, prefix, options, git_submodule_usage,
-			     PARSE_OPT_STOP_AT_NON_OPTION | PARSE_OPT_KEEP_DASHDASH);
+			     PARSE_OPT_STOP_AT_NON_OPTION);
 
 	/*
 	 * Tell the rest of git that any URLs we get don't come
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 19df3407ef1..c524398e805 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -25,8 +25,8 @@ test_expect_success 'submodule usage: --recursive' '
 '
 
 test_expect_success 'submodule usage: status --' '
-	test_expect_code 129 git submodule -- &&
-	test_expect_code 129 git submodule --end-of-options
+	git submodule -- &&
+	git submodule --end-of-options
 '
 
 for opt in '--quiet'
-- 
2.38.0.1091.gf9d18265e59


  parent reply	other threads:[~2022-10-17 12:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-17 12:09 [PATCH 00/10] submodule: make it a built-in, remove git-submodule.sh Ævar Arnfjörð Bjarmason
2022-10-17 12:09 ` [PATCH 01/10] git-submodule.sh: create a "case" dispatch statement Ævar Arnfjörð Bjarmason
2022-10-17 12:09 ` [PATCH 02/10] git-submodule.sh: dispatch "sync" to helper Ævar Arnfjörð Bjarmason
2022-10-20 20:42   ` Glen Choo
2022-10-17 12:09 ` [PATCH 03/10] git-submodule.sh: dispatch directly " Ævar Arnfjörð Bjarmason
2022-10-17 12:09 ` [PATCH 04/10] git-submodule.sh: dispatch "foreach" " Ævar Arnfjörð Bjarmason
2022-10-20 21:14   ` Glen Choo
2022-10-17 12:09 ` [PATCH 05/10] git-submodule.sh: dispatch "update" " Ævar Arnfjörð Bjarmason
2022-10-20 21:50   ` Glen Choo
2022-10-17 12:09 ` [PATCH 06/10] git-submodule.sh: don't support top-level "--cached" Ævar Arnfjörð Bjarmason
2022-10-20 22:14   ` Glen Choo
2022-10-17 12:09 ` [PATCH 07/10] submodule: make it a built-in, remove git-submodule.sh Ævar Arnfjörð Bjarmason
2022-10-20 22:49   ` Glen Choo
2022-10-17 12:09 ` Ævar Arnfjörð Bjarmason [this message]
2022-10-17 12:09 ` [PATCH 09/10] submodule: support sub-command-less "--recursive" option Ævar Arnfjörð Bjarmason
2022-10-20 23:05   ` Glen Choo
2022-10-17 12:09 ` [PATCH 10/10] submodule: don't use a subprocess to invoke "submodule--helper" Ævar Arnfjörð Bjarmason
2022-10-20 23:18   ` Glen Choo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=patch-08.10-8dbb81e2fa5-20221017T115544Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=chooglen@google.com \
    --cc=emilyshaffer@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jonas@bernoul.li \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).