http-backend.c: replace `git_config()` with `git_config_get_bool()` family

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> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Tanay Abhra committed Aug 7, 2014 at 09:21 UTC 6881f0ccb4365d1beb1673f740952064d204bd50
1 file changed +12 -19
http-backend.c
+12 -19
@@ -219,29 +219,22 @@ static void get_idx_file(char *name)
219 send_local_file("application/x-git-packed-objects-toc", name);
220 }
221
222 -static int http_config(const char *var, const char *value, void *cb)
222 +static void http_config(void)
223 {
224 - const char *p;
224 + int i, value = 0;
225 + struct strbuf var = STRBUF_INIT;
226
226 - if (!strcmp(var, "http.getanyfile")) {
227 - getanyfile = git_config_bool(var, value);
228 - return 0;
229 - }
227 + git_config_get_bool("http.getanyfile", &getanyfile);
228
231 - if (skip_prefix(var, "http.", &p)) {
232 - int i;
233 -
234 - for (i = 0; i < ARRAY_SIZE(rpc_service); i++) {
235 - struct rpc_service *svc = &rpc_service[i];
236 - if (!strcmp(p, svc->config_name)) {
237 - svc->enabled = git_config_bool(var, value);
238 - return 0;
239 - }
240 - }
229 + for (i = 0; i < ARRAY_SIZE(rpc_service); i++) {
230 + struct rpc_service *svc = &rpc_service[i];
231 + strbuf_addf(&var, "http.%s", svc->config_name);
232 + if (!git_config_get_bool(var.buf, &value))
233 + svc->enabled = value;
234 + strbuf_reset(&var);
235 }
236
243 - /* we are not interested in parsing any other configuration here */
244 - return 0;
237 + strbuf_release(&var);
238 }
239
240 static struct rpc_service *select_service(const char *name)
@@ -627,7 +620,7 @@ int main(int argc, char **argv)
620 access("git-daemon-export-ok", F_OK) )
621 not_found("Repository not exported: '%s'", dir);
622
630 - git_config(http_config, NULL);
623 + http_config();
624 cmd->imp(cmd_arg);
625 return 0;
626 }