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

Re: Alternative approach to the git config NULL value checking patches..

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Feb 10, 2008, 23:50 UTC
Message-ID
<alpine.LFD.1.00.0802101541380.2920@woody.linux-foundation.org>
In-Reply-To
<20080210232920.GH5129@artemis.madism.org>
On Mon, 11 Feb 2008, Pierre Habouzit wrote:
Show 9 quoted lines
>
> > Having said all that, it might be an option to change your patch
> > slightly to say:
> > 
> > 	const char config_true[] = "true";
> 
> I was about to suggest the same, and testing against "config_true" just
> becomes an optimization, but isn't required. Seems an appropriate hack
> to me.

Well, I had the thing actually written that way, but it breaks some of the test-suite. Whether the test-suite actually *should* test for what it tests for is obviously debatable, but it does. It does test that when you do

	git config --get novalue.variable

you are expected to get an empty result. Is that good? Probably not. But it's what you get traditionally, and it's what the tests actually test for (t/t1300-repo-config.sh in case you care).

But yes, I actually think it might be an improvement and have that thing return "true" (which is what happens if you make the 'config_true' array contain that string). And that allows removal of one test from the "git_config_bool()" function, but on the other hand, it does result in some strange stuff too..

In particular, *if* somebody just takes a string blindly and uses
	result = xstrdup(value);

then with my patch it would then use an empty string for whatever it happened to pick. So having something like

	[user]
		name

will mean that your name is empty (which will actually trigger an error if you try to commit).

In contrast, if you do that 'config_true[] = "true"' thing, then that config file entry will make your name be the string "true", which is just _odd_.

So I think an empty config_true actually has a nicer and more easily explainable failure case. It causes empty strings when mis-used, not arbitrary and strange "true" strings.

Whatever. 
		Linus
Previous: Pierre HabouzitNext: Linus Torvalds
Message 7 of 13 in “Alternative approach to the git config NULL value checking patches..”
  1. Linus TorvaldsFeb 10, 2008
  2. Junio C HamanoFeb 10, 2008
  3. Linus TorvaldsFeb 10, 2008
  4. Junio C HamanoFeb 10, 2008
  5. Junio C HamanoFeb 10, 2008
  6. Pierre HabouzitFeb 10, 2008
  7. Linus TorvaldsFeb 10, 2008
  8. Linus TorvaldsFeb 10, 2008
  9. Linus TorvaldsFeb 10, 2008
  10. Junio C HamanoFeb 11, 2008
  11. Christian CouderFeb 11, 2008
  12. Junio C HamanoFeb 11, 2008
  13. Daniel BarkalowFeb 11, 2008

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.