summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorMichael J Gruber <git@drmicha.warpmail.net>2011-05-17 15:38:53 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-05-18 04:01:29 (GMT)
commit5a2df368c26e4a993db9d09f221af1063d0fe9a8 (patch)
tree6cc663c9a4a1d8582a30f643915df09f7f8463c0 /builtin
parent7a39741999a5216257b1fbcc847cf0c62c114088 (diff)
downloadgit-5a2df368c26e4a993db9d09f221af1063d0fe9a8.zip
git-5a2df368c26e4a993db9d09f221af1063d0fe9a8.tar.gz
git-5a2df368c26e4a993db9d09f221af1063d0fe9a8.tar.bz2
config: Give error message when not changing a multivar
When trying to set a multivar with "git config var value", "git config" issues warning: remote.repoor.push has multiple values leaving the user under the impression that the operation succeeded, unless one checks the return value. Instead, make it warning: remote.repoor.push has multiple values error: cannot overwrite multiple values with a single value Use a regexp, --add or --set-all to change remote.repoor.push. to be clear and helpful. Note: The "warning" is raised through other code paths also so that it needs to remain a warning for these (which do not raise the error). Only the caller can determine how to go on from that. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/config.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/builtin/config.c b/builtin/config.c
index 3e3c528..211e118 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -436,9 +436,14 @@ int cmd_config(int argc, const char **argv, const char *prefix)
NULL, NULL);
}
else if (actions == ACTION_SET) {
+ int ret;
check_argc(argc, 2, 2);
value = normalize_value(argv[0], argv[1]);
- return git_config_set(argv[0], value);
+ ret = git_config_set(argv[0], value);
+ if (ret == CONFIG_NOTHING_SET)
+ error("cannot overwrite multiple values with a single value\n"
+ " Use a regexp, --add or --set-all to change %s.", argv[0]);
+ return ret;
}
else if (actions == ACTION_SET_ALL) {
check_argc(argc, 2, 3);