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

[PATCH v2 01/11] daemon.c: replace `git_config()` with `git_config_get_bool()` family

From
Tanay Abhra <tanayabh@gmail.com>
Date
Aug 7, 2014, 16:21 UTC
Message-ID
<1407428486-19049-2-git-send-email-tanayabh@gmail.com>
In-Reply-To
<1407428486-19049-1-git-send-email-tanayabh@gmail.com>

Use `git_config_get_bool()` family instead of `git_config()` to take advantage of the config-set API which provides a cleaner control flow.

Signed-off-by: Tanay Abhra <tanayabh@gmail.com>
---
 daemon.c | 26 ++++----------------------
 1 file changed, 4 insertions(+), 22 deletions(-)
diff --git a/daemon.c b/daemon.c
index e6b51ed..6f78b61 100644
--- a/daemon.c
+++ b/daemon.c
@@ -230,23 +230,6 @@ struct daemon_service {
 	int overridable;
 };
 
-static struct daemon_service *service_looking_at;
-static int service_enabled;
-
-static int git_daemon_config(const char *var, const char *value, void *cb)
-{
-	const char *service;
-
-	if (skip_prefix(var, "daemon.", &service) &&
-	    !strcmp(service, service_looking_at->config_name)) {
-		service_enabled = git_config_bool(var, value);
-		return 0;
-	}
-
-	/* we are not interested in parsing any other configuration here */
-	return 0;
-}
-
 static int daemon_error(const char *dir, const char *msg)
 {
 	if (!informative_errors)
@@ -324,6 +307,7 @@ static int run_service(const char *dir, struct daemon_service *service)
 {
 	const char *path;
 	int enabled = service->enabled;
+	struct strbuf var = STRBUF_INIT;
 
 	loginfo("Request %s for '%s'", service->name, dir);
 
@@ -354,11 +338,9 @@ static int run_service(const char *dir, struct daemon_service *service)
 	}
 
 	if (service->overridable) {
-		service_looking_at = service;
-		service_enabled = -1;
-		git_config(git_daemon_config, NULL);
-		if (0 <= service_enabled)
-			enabled = service_enabled;
+		strbuf_addf(&var, "daemon.%s", service->config_name);
+		git_config_get_bool(var.buf, &enabled);
+		strbuf_release(&var);
 	}
 	if (!enabled) {
 		logerror("'%s': service not enabled for '%s'",
-- 
1.9.0.GIT
Previous: Tanay AbhraNext: Tanay Abhra
Message 2 of 16 in “git_config callers rewritten with the new config-set API”
  1. 00/11 git_config callers rewritten with the new config-set APITanay Abhra, Aug 7, 2014
  2. 01/11 daemon.c: replace `git_config()` with `git_config_get_bool()` familyTanay Abhra, Aug 7, 2014
  3. 02/11 http-backend.c: replace `git_config()` with `git_config_get_bool()` familyTanay Abhra, Aug 7, 2014
  4. 03/11 read-cache.c: replace `git_config()` with `git_config_get_*()` familyTanay Abhra, Aug 7, 2014
  5. 04/11 archive.c: replace `git_config()` with `git_config_get_bool()` familyTanay Abhra, Aug 7, 2014
  6. 05/11 fetchpack.c: replace `git_config()` with `git_config_get_*()` familyTanay Abhra, Aug 7, 2014
  7. 06/11 rerere.c: replace `git_config()` with `git_config_get_*()` familyTanay Abhra, Aug 7, 2014
  8. 07/11 builtin/gc.c: replace `git_config()` with `git_config_get_*()` familyTanay Abhra, Aug 7, 2014
  9. 08/11 pager.c: replace `git_config()` with `git_config_get_value()`Tanay Abhra, Aug 7, 2014
  10. 09/11 imap-send.c: replace `git_config()` with `git_config_get_*()` familyTanay Abhra, Aug 7, 2014
  11. 10/11 alias.c: replace `git_config()` with `git_config_get_string()`Tanay Abhra, Aug 7, 2014
  12. 11/11 branch.c: replace `git_config()` with `git_config_get_string()Tanay Abhra, Aug 7, 2014
  13. Matthieu MoyAug 7, 2014
  14. 11/11 branch.c: replace `git_config()` with `git_config_get_string()Tanay Abhra, Aug 7, 2014
  15. Matthieu MoyAug 7, 2014
  16. Junio C HamanoAug 7, 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.