From: Carlos Rica <jasampler@gmail.com>
To: git@vger.kernel.org, johannes.schindelin@gmx.de, gitster@pobox.com
Subject: [PATCH] config: --replace-all with one argument exits properly with a better message.
Date: Sat, 14 Mar 2009 03:42:32 +0100 [thread overview]
Message-ID: <1236998552.9952.2.camel@luis-desktop> (raw)
'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 reply other threads:[~2009-03-14 2:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-14 2:42 Carlos Rica [this message]
2009-03-14 20:53 ` [PATCH] config: --replace-all with one argument exits properly with a better message Junio C Hamano
2009-03-14 21:34 ` Felipe Contreras
2009-03-15 1:53 ` Junio C Hamano
2009-03-15 10:26 ` Felipe Contreras
2009-03-16 14:41 ` Carlos Rica
2009-03-16 15:25 ` Felipe Contreras
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=1236998552.9952.2.camel@luis-desktop \
--to=jasampler@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.