git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] config: teach "git -c" to recognize an empty string

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 4, 2014, 22:25 UTC
Message-ID
<xmqq61i7riy4.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20140804215644.GA21510@peff.net>
Jeff King <peff@peff.net> writes:
> This is technically a backwards incompatibility, but I'd consider it a
> simple bugfix. The existing behavior was unintentional, made no sense,
> and was never documented.

Yeah, I tend to agree. I actually would not shed any tears if the breakage were that it was impossible to pass "NULL is true" boolean via "git -c" interface, but it is the other way around. It is much more grave a problem that we cannot pass an empty string as a value, and we should fix it.

Show 5 quoted lines
> Looking over strbuf_split's interface, I think it's rather
> counter-intuitive, and I was tempted to change it. But there are several
> other callers that rely on it, and the chance for introducing a subtle
> bug is high. This is the least invasive fix (and it really is not any
> less readable than what was already there :) ).
;-)
Show 10 quoted lines
> +# We just need a type-specifier here that cares about the
> +# distinction internally between a NULL boolean and a real
> +# string (because most of git's internal parsers do care).
> +# Using "--path" works, but we do not otherwise care about
> +# its semantics.
> +test_expect_success 'git -c can represent empty string' '
> +	echo >expect &&
> +	git -c foo.empty= config --path foo.empty >actual &&
> +	test_cmp expect actual
> +'

Another way may be "git config -l" and see if we see a = on the entry for foo.empty, but I think the way you did this is nicer.

>  test_expect_success 'key sanity-checking' '
>  	test_must_fail git config foo=bar &&
>  	test_must_fail git config foo=.bar &&
Previous: Jeff King
Message 8 of 8 in “pretty.c: make git_pretty_formats_config return -1 on git_config_string failure”
  1. pretty.c: make git_pretty_formats_config return -1 on git_config_string failureTanay Abhra, Aug 4, 2014
  2. Matthieu MoyAug 4, 2014
  3. Eric SunshineAug 4, 2014
  4. Matthieu MoyAug 4, 2014
  5. Jeff KingAug 4, 2014
  6. Matthieu MoyAug 4, 2014
  7. config: teach "git -c" to recognize an empty stringJeff King, Aug 4, 2014
  8. Junio C HamanoAug 4, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.