From c331551ccf9a4c8922ff5d2987eed9e218479000 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 29 Apr 2021 14:55:34 +0200 Subject: git: support separate arg for `--config-env`'s value 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 Reviewed-by: Jeff King Signed-off-by: Junio C Hamano --- git.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'git.c') diff --git a/git.c b/git.c index 2f548821d6..dd8c6ca51a 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")) { -- cgit v1.2.3