git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/RFC] config: Give error message when not changing a multivar
@ 2011-05-17 11:34 Michael J Gruber
  2011-05-17 12:38 ` Jeff King
  0 siblings, 1 reply; 11+ messages in thread
From: Michael J Gruber @ 2011-05-17 11:34 UTC (permalink / raw)
  To: git

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: 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>
---
 builtin/config.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/builtin/config.c b/builtin/config.c
index 3e3c528..c438ef4 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -436,9 +436,13 @@ 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 == 5)
+			error("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);
-- 
1.7.5.1.514.gd181fb

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-05-18 18:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-17 11:34 [PATCH/RFC] config: Give error message when not changing a multivar Michael J Gruber
2011-05-17 12:38 ` Jeff King
2011-05-17 14:03   ` Michael J Gruber
2011-05-17 14:07     ` Jeff King
2011-05-17 15:38       ` [PATCH 1/2] config: define and document exit codes Michael J Gruber
2011-05-17 15:38         ` [PATCH 2/2] config: Give error message when not changing a multivar Michael J Gruber
2011-05-17 15:46         ` [PATCH 1/2] config: define and document exit codes Thiago Farina
2011-05-17 15:49           ` Michael J Gruber
2011-05-18  8:21         ` Jeff King
2011-05-18 15:41         ` Junio C Hamano
2011-05-18 18:49           ` Michael J Gruber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).