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.