Skip to content

Commit 5a2df36

Browse files
Michael J Grubergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7a39741 commit 5a2df36

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

builtin/config.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,14 @@ int cmd_config(int argc, const char **argv, const char *prefix)
436436
NULL, NULL);
437437
}
438438
else if (actions == ACTION_SET) {
439+
int ret;
439440
check_argc(argc, 2, 2);
440441
value = normalize_value(argv[0], argv[1]);
441-
return git_config_set(argv[0], value);
442+
ret = git_config_set(argv[0], value);
443+
if (ret == CONFIG_NOTHING_SET)
444+
error("cannot overwrite multiple values with a single value\n"
445+
" Use a regexp, --add or --set-all to change %s.", argv[0]);
446+
return ret;
442447
}
443448
else if (actions == ACTION_SET_ALL) {
444449
check_argc(argc, 2, 3);

0 commit comments

Comments
 (0)