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
Daniel Barkalow <barkalow@iabervon.org>
Date
Feb 11, 2008, 17:27 UTC
Message-ID
<alpine.LNX.1.00.0802111133490.13593@iabervon.org>
In-Reply-To
<7vir0wfqrz.fsf@gitster.siamese.dyndns.org>
On Sun, 10 Feb 2008, Junio C Hamano wrote:
Show 37 quoted lines
> Linus Torvalds <torvalds@linux-foundation.org> writes:
> 
> > It may be a bit odd, but it automatically means that codepaths that simply 
> > don't want to care about the subtle difference between "true" and "empty" 
> > will just automatically work, because to them the two cases will look 
> > identical, because the strings will compare the same - they have the same 
> > data, just different addresses.
> 
> I should have mentioned the reason why I did not suggest doing
> it this way in my [Janitor] message.
> 
> It is not "suttle difference between true and empty".  Empty
> means false, and with this approach, it switches the meaning of
> valueless form of config to quite the opposite.
> 
> In addition to fixing existing breakages, a piece of code that
> knew NULL is true and empty is false and coded accordingly, i.e.
> 
> 	if (!value)
>         	Ah we have true;
> 	else if (!*value)
>         	Ok this is false;
> 	else if (!strcmp(value, "something special")
>         	Ok, this is not bool but special;
> 	else
>         	return git_config_bool(var, value);
> 
> will now need to be changed to:
> 
> 	if (value == config_true)
>         	Ah we have true;
> 	else if (!*value)
>         	Ok this is false;
> 	else if (!strcmp(value, "something special")
>         	Ok, this is not bool but special;
> 	else
>         	return git_config_bool(var, value);
Shouldn't it be simply:
	if (!strcmp(value, "something special"))
		Ok, this is not bool but special;
	else
		return git_config_bool(var, value);

That is, don't check for special true or special false at all, but have git_config_bool() sort them out? And Linus's code means that you can do the strcmp without worrying about getting a segfault on special true.

Show 19 quoted lines
> if you do this.  And the code that was already broken:
> 
> 	if (!strcmp(value, "somevalue")
> 		Ok let's use somevalue;
> 	else if (!strcmp(value, "someothervalue")
> 		Ok let's use someothervalue;
> 	else
>         	die("oops we do not understand '%s'", value);
> 
> still need to be fixed to:
> 
> 	if (value == config_true)
>         	die("oops '%s' is not a bool", var);
> 	else if (!strcmp(value, "somevalue")
> 		Ok let's use somevalue;
> 	else if (!strcmp(value, "someothervalue")
> 		Ok let's use someothervalue;
> 	else
>         	die("oops we do not understand '%s'", value);

If it isn't changed, you'd get the message "oops we do not understand ''" for either true or false empty values, which seems, if anything, better.

	-Daniel
*This .sig left intentionally blank*
Previous: Junio C Hamano
Message 13 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.