Skip to content

Commit

Permalink
config: Give error message when not changing a multivar
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael J Gruber authored and Junio C Hamano committed May 18, 2011
1 parent 7a39741 commit 5a2df36
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion builtin/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5a2df36

Please sign in to comment.