Re: [PATCH v4 1/3] builtin/config: introduce `--default`

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Apr 09, 2018 at 08:18:18AM +0900, Junio C Hamano wrote:
> Jeff King <peff@xxxxxxxx> writes:
>
> > On Wed, Apr 04, 2018 at 07:59:12PM -0700, Taylor Blau wrote:
> >
> >> @@ -286,6 +288,16 @@ static int get_value(const char *key_, const char *regex_)
> >>  	config_with_options(collect_config, &values,
> >>  			    &given_config_source, &config_options);
> >>
> >> +	if (!values.nr && default_value) {
> >> +		struct strbuf *item;
> >> +		ALLOC_GROW(values.items, values.nr + 1, values.alloc);
> >> +		item = &values.items[values.nr++];
> >> +		strbuf_init(item, 0);
> >> +		if (format_config(item, key_, default_value) < 0) {
> >> +			exit(1);
> >> +		}
> >> +	}
> > ...
> >
> > It's obvious in this toy example, but that config call may be buried
> > deep in a script. It'd probably be nicer for that exit(1) to be
> > something like:
> >
> >   die(_("failed to format default config value"));
>
> Together with key_ and default_value, you mean?
>
> >
> >> +test_expect_success 'does not allow --default without --get' '
> >> +	test_must_fail git config --default quux --unset a >output 2>&1 &&
> >> +	test_i18ngrep "\-\-default is only applicable to" output
> >> +'
> >
> > I think "a" here needs to be "a.section". I get:
> >
> >   error: key does not contain a section: a
>
> "section.var"?  That aside, even with a properly formatted key, I
> seem to get an empty output here, so this may need a bit more work.

This should be fixed in the latest re-roll, v6:

	expecting success:
					test_must_fail git config --default=quux --unset a.section >output 2>&1 &&
					test_i18ngrep "\-\-default is only applicable to" output

	error: --default is only applicable to --get
	ok 5 - does not allow --default without --get


Thanks,
Taylor



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux