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

[PATCH 1/4] Split up default "core" config parsing into helper routine

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jun 18, 2008, 22:30 UTC
Message-ID
<alpine.LFD.1.10.0806181529570.2907@woody.linux-foundation.org>
In-Reply-To
<alpine.LFD.1.10.0806181524490.2907@woody.linux-foundation.org>
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Wed, 18 Jun 2008 14:37:18 -0700
Subject: [PATCH 1/4] Split up default "core" config parsing into helper routine

It makes the code a bit easier to read, and in theory a bit faster too (no need to compare all the different "core.*" strings against non-core config options).

The config system really should get something of a complete overhaul, but in the absense of that, this at least improves on it a tiny bit.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 config.c |   42 ++++++++++++++++++++++++++----------------
 1 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/config.c b/config.c
index c2f2bbb..c3597e0 100644
--- a/config.c
+++ b/config.c
@@ -332,7 +332,7 @@ int git_config_string(const char **dest, const char *var, const char *value)
 	return 0;
 }
 
-int git_default_config(const char *var, const char *value, void *dummy)
+static int git_default_core_config(const char *var, const char *value)
 {
 	/* This needs a better name */
 	if (!strcmp(var, "core.filemode")) {
@@ -444,6 +444,31 @@ int git_default_config(const char *var, const char *value, void *dummy)
 		return 0;
 	}
 
+	if (!strcmp(var, "core.pager"))
+		return git_config_string(&pager_program, var, value);
+
+	if (!strcmp(var, "core.editor"))
+		return git_config_string(&editor_program, var, value);
+
+	if (!strcmp(var, "core.excludesfile"))
+		return git_config_string(&excludes_file, var, value);
+
+	if (!strcmp(var, "core.whitespace")) {
+		if (!value)
+			return config_error_nonbool(var);
+		whitespace_rule_cfg = parse_whitespace_rule(value);
+		return 0;
+	}
+
+	/* Add other config variables here and to Documentation/config.txt. */
+	return 0;
+}
+
+int git_default_config(const char *var, const char *value, void *dummy)
+{
+	if (!prefixcmp(var, "core."))
+		return git_default_core_config(var, value);
+
 	if (!strcmp(var, "user.name")) {
 		if (!value)
 			return config_error_nonbool(var);
@@ -473,21 +498,6 @@ int git_default_config(const char *var, const char *value, void *dummy)
 		return 0;
 	}
 
-	if (!strcmp(var, "core.pager"))
-		return git_config_string(&pager_program, var, value);
-
-	if (!strcmp(var, "core.editor"))
-		return git_config_string(&editor_program, var, value);
-
-	if (!strcmp(var, "core.excludesfile"))
-		return git_config_string(&excludes_file, var, value);
-
-	if (!strcmp(var, "core.whitespace")) {
-		if (!value)
-			return config_error_nonbool(var);
-		whitespace_rule_cfg = parse_whitespace_rule(value);
-		return 0;
-	}
 	if (!strcmp(var, "branch.autosetupmerge")) {
 		if (value && !strcasecmp(value, "always")) {
 			git_branch_track = BRANCH_TRACK_ALWAYS;
-- 
1.5.6.rc3.7.g336d0.dirty
Previous: Linus TorvaldsNext: Linus Torvalds
Message 2 of 16 in “Add 'core.fsyncobjectfiles' config option”
  1. 0/4 Add 'core.fsyncobjectfiles' config optionLinus Torvalds, Jun 18, 2008
  2. 1/4 Split up default "core" config parsing into helper routineLinus Torvalds, Jun 18, 2008
  3. 2/4 Split up default "user" config parsing into helper routineLinus Torvalds, Jun 18, 2008
  4. 3/4 Split up default "i18n" and "branch" config parsing into helper routinesLinus Torvalds, Jun 18, 2008
  5. 4/4 Add config option to enable 'fsync()' of object filesLinus Torvalds, Jun 18, 2008
  6. Jeff KingJun 18, 2008
  7. Linus TorvaldsJun 18, 2008
  8. Jeff KingJun 18, 2008
  9. Linus TorvaldsJun 18, 2008
  10. Jeff KingJun 19, 2008
  11. Linus TorvaldsJun 19, 2008
  12. Linus TorvaldsJun 19, 2008
  13. Daniel BarkalowJun 19, 2008
  14. Junio C HamanoJun 19, 2008
  15. Jeff KingJun 19, 2008
  16. Eric RaibleJun 19, 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.