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:41 UTC
Message-ID
<alpine.LFD.1.00.0802101538030.2920@woody.linux-foundation.org>
In-Reply-To
<alpine.LFD.1.00.0802101532070.2920@woody.linux-foundation.org>
On Sun, 10 Feb 2008, Linus Torvalds wrote:
Show 5 quoted lines
> 
> Yes, the 10% that actually *cares* will look exactly the same (the 
> difference being comparing against NULL or config_true), but all the stuff 
> that compares against a special string can just ignore the fact that the 
> special truth value will never ever match that string.

And here's an example of this kind of effect. I'm not actually suggesting you apply this patch, but tell me it isn't simpler done this way?

So this is where it *does* make a difference whether we use NULL or config_bool, and where config_bool is simply better: it allows a config routine to simply never care..

		Linus
---
 color.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/color.c b/color.c
index cb70340..e5fbf01 100644
--- a/color.c
+++ b/color.c
@@ -118,15 +118,12 @@ bad:
 
 int git_config_colorbool(const char *var, const char *value, int stdout_is_tty)
 {
-	if (value) {
-		if (!strcasecmp(value, "never"))
-			return 0;
-		if (!strcasecmp(value, "always"))
-			return 1;
-		if (!strcasecmp(value, "auto"))
-			goto auto_color;
-	}
-
+	if (!strcasecmp(value, "never"))
+		return 0;
+	if (!strcasecmp(value, "always"))
+		return 1;
+	if (!strcasecmp(value, "auto"))
+		goto auto_color;
 	/* Missing or explicit false to turn off colorization */
 	if (!git_config_bool(var, value))
 		return 0;
Previous: Linus TorvaldsNext: Junio C Hamano
Message 9 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.