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

[PATCH] config: --replace-all with one argument exits properly with a better message.

From
CRCarlos Rica <jasampler@gmail.com>
Date
Mar 14, 2009, 02:42 UTC
Message-ID
<1236998552.9952.2.camel@luis-desktop>

'config --replace-all ONE_ARG' was being treated as 'config NAME VALUE', showing the error "key does not contain a section: --replace-all".

Now it exits before with an error message asking for the missing value. Documentation is updated and a new test is added to ensure that configuration remains the same when no value is provided.

Signed-off-by: Carlos Rica <jasampler@gmail.com>
---
 Documentation/git-config.txt |    2 +-
 builtin-config.c             |    2 ++
 t/t1300-repo-config.sh       |    9 ++++++++-
 3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
index 82ce89e..7131ee3 100644
--- a/Documentation/git-config.txt
+++ b/Documentation/git-config.txt
@@ -11,7 +11,7 @@ SYNOPSIS
 [verse]
 'git config' [<file-option>] [type] [-z|--null] name [value [value_regex]]
 'git config' [<file-option>] [type] --add name value
-'git config' [<file-option>] [type] --replace-all name [value [value_regex]]
+'git config' [<file-option>] [type] --replace-all name value [value_regex]
 'git config' [<file-option>] [type] [-z|--null] --get name [value_regex]
 'git config' [<file-option>] [type] [-z|--null] --get-all name [value_regex]
 'git config' [<file-option>] [type] [-z|--null] --get-regexp name_regex [value_regex]
diff --git a/builtin-config.c b/builtin-config.c
index d52a057..005b6ea 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -386,6 +386,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
 			return git_config_set_multivar(argv[2], NULL, NULL, 1);
 		else if (!strcmp(argv[1], "--get"))
 			return get_value(argv[2], NULL);
+		else if (!strcmp(argv[1], "--replace-all"))
+			return error("missing value for --replace-all");
 		else if (!strcmp(argv[1], "--get-all")) {
 			do_all = 1;
 			return get_value(argv[2], NULL);
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 3c06842..9c81e04 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -118,7 +118,14 @@ EOF
 
 test_expect_success 'multiple unset is correct' 'cmp .git/config expect'
 
-mv .git/config2 .git/config
+cp .git/config2 .git/config
+
+test_expect_success '--replace-all missing value' '
+	test_must_fail git config --replace-all beta.haha &&
+	test_cmp .git/config2 .git/config
+'
+
+rm .git/config2
 
 test_expect_success '--replace-all' \
 	'git config --replace-all beta.haha gamma'
-- 
1.5.4.3
Next: Junio C Hamano
Message 1 of 7 in “config: --replace-all with one argument exits properly with a better message.”
  1. config: --replace-all with one argument exits properly with a better message.Carlos Rica, Mar 14, 2009
  2. Junio C HamanoMar 14, 2009
  3. Felipe ContrerasMar 14, 2009
  4. Junio C HamanoMar 15, 2009
  5. Felipe ContrerasMar 15, 2009
  6. Carlos RicaMar 16, 2009
  7. Felipe ContrerasMar 16, 2009

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.