git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH/RFC] config: Give error message when not changing a multivar
Date: Tue, 17 May 2011 16:03:00 +0200	[thread overview]
Message-ID: <4DD28014.4090505@drmicha.warpmail.net> (raw)
In-Reply-To: <20110517123840.GB13176@sigill.intra.peff.net>

Jeff King venit, vidit, dixit 17.05.2011 14:38:
> On Tue, May 17, 2011 at 01:34:58PM +0200, Michael J Gruber wrote:
> 
>> 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.
> 
> Makes sense, and I think trying to change the "warning" text is not
> worth the effort.
> 
>>  	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;
>>  	}
> 
> What the heck is this 5? In fact, what in the world is going on with the
> return values from git_config_set_multivar? It looks like we can return
> 3, 4, 5, or 6 to return various errors, but they're not documented
> anywhere. Or we can return 2, propagated from parse_key. Or we can
> return -1 (negative!) if the lock doesn't work.
> 
> I think the last one is a straight-out error. For the other ones, we
> should probably document them in git-config(1). And it would be nice to
> at least have some symbolic constants in the code.
> 
> None of these problems is introduced by your patch, of course. But it
> might be nice to at least do the symbolic constants while we're looking
> at this so that your patch can use them.

OK, makes sense, I just wanted to request for comments early enough -
someone might think we should remove the warning from the present site
and make all callers deal with the return codes. But I don't think it's
worth it, and we have other places where we warn first, then error out.

Michael

  reply	other threads:[~2011-05-17 14:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=4DD28014.4090505@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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 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).