git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] push: unset PARSE_OPT_OPTARG for --recurse-submodules

From
Denton Liu <liu.denton@gmail.com>
Date
Apr 27, 2020, 06:44 UTC
Message-ID
<c2b92691ca85029fde3bd6969252cc827ca697b5.1587969824.git.liu.denton@gmail.com>
In-Reply-To
<346FFB0C-7419-4E2D-B593-9F64F9403D11@audinatedante.onmicrosoft.com>

When the usage for `git push` is shown, it includes the following lines

	--recurse-submodules[=(check|on-demand|no)]
			      control recursive pushing of submodules

which seem to indicate that the argument for --recurse-submodules is optional. However, we cannot actually run that optiion without an argument:

	$ git push --recurse-submodules
	fatal: recurse-submodules missing parameter

Unset PARSE_OPT_OPTARG so that it is clear that this option requires an argument. Since the parse-options machinery guarantees that an argument is present now, assume that `arg` is set in the else of option_parse_recurse_submodules().

Reported-by: Andrew White <andrew.white@audinate.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 builtin/push.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/builtin/push.c b/builtin/push.c
index 6dbf0f0bb7..90f071fcf2 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -434,10 +434,8 @@ static int option_parse_recurse_submodules(const struct option *opt,
 
 	if (unset)
 		*recurse_submodules = RECURSE_SUBMODULES_OFF;
-	else if (arg)
-		*recurse_submodules = parse_push_recurse_submodules_arg(opt->long_name, arg);
 	else
-		die("%s missing parameter", opt->long_name);
+		*recurse_submodules = parse_push_recurse_submodules_arg(opt->long_name, arg);
 
 	return 0;
 }
@@ -554,7 +552,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 		  PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP, parseopt_push_cas_option },
 		{ OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules, "(check|on-demand|no)",
 			N_("control recursive pushing of submodules"),
-			PARSE_OPT_OPTARG, option_parse_recurse_submodules },
+			0, option_parse_recurse_submodules },
 		OPT_BOOL_F( 0 , "thin", &thin, N_("use thin pack"), PARSE_OPT_NOCOMPLETE),
 		OPT_STRING( 0 , "receive-pack", &receivepack, "receive-pack", N_("receive pack program")),
 		OPT_STRING( 0 , "exec", &receivepack, "receive-pack", N_("receive pack program")),
-- 
2.26.0.159.g23e2136ad0
Previous: Andrew WhiteNext: Jeff King
Message 2 of 9 in “Bug v2.23.0: command help for 'git push --recurse-submodules' is incorrect”
  1. Andrew WhiteApr 27, 2020
  2. push: unset PARSE_OPT_OPTARG for --recurse-submodulesDenton Liu, Apr 27, 2020
  3. Jeff KingApr 27, 2020
  4. Junio C HamanoApr 27, 2020
  5. Use OPT_CALLBACK and OPT_CALLBACK_FDenton Liu, Apr 28, 2020
  6. Jeff KingApr 28, 2020
  7. Junio C HamanoApr 28, 2020
  8. Junio C HamanoApr 28, 2020
  9. Denton LiuApr 28, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.