From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH 2/4] git_config: don't peek at global config_parameters
Date: Tue, 24 May 2011 18:49:45 -0400 [thread overview]
Message-ID: <20110524224945.GB24527@sigill.intra.peff.net> (raw)
In-Reply-To: <20110524224903.GA16265@sigill.intra.peff.net>
The config_parameters list in config.c is an implementation
detail of git_config_from_parameters; instead, that function
should tell us whether it found anything.
Signed-off-by: Jeff King <peff@peff.net>
---
config.c | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/config.c b/config.c
index 46aeb9c..fb88839 100644
--- a/config.c
+++ b/config.c
@@ -850,7 +850,7 @@ int git_config_from_parameters(config_fn_t fn, void *data)
for (ct = config_parameters; ct; ct = ct->next)
if (fn(ct->name, ct->value, data) < 0)
return -1;
- return 0;
+ return config_parameters != NULL;
}
int git_config_early(config_fn_t fn, void *data, const char *repo_config)
@@ -882,9 +882,16 @@ int git_config_early(config_fn_t fn, void *data, const char *repo_config)
found += 1;
}
- ret += git_config_from_parameters(fn, data);
- if (config_parameters)
- found += 1;
+ switch (git_config_from_parameters(fn, data)) {
+ case -1: /* error */
+ ret--;
+ break;
+ case 0: /* found nothing */
+ break;
+ default: /* found at least one item */
+ found++;
+ break;
+ }
return ret == 0 ? found : ret;
}
--
1.7.4.5.7.g2e01
next prev parent reply other threads:[~2011-05-24 22:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-24 21:15 [PATCH] handle_options(): do not miscount how many arguments were used Junio C Hamano
2011-05-24 21:18 ` [PATCH] Allow built-ins to also use -c var=val via alias Junio C Hamano
2011-05-24 21:46 ` Jeff King
2011-05-24 21:52 ` Jeff King
2011-05-24 21:57 ` Jeff King
2011-05-24 22:49 ` Jeff King
2011-05-24 22:49 ` [PATCH 1/4] config: make environment parsing routines static Jeff King
2011-05-24 22:49 ` Jeff King [this message]
2011-05-24 22:49 ` [PATCH 3/4] config: always parse GIT_CONFIG_PARAMETERS during git_config Jeff King
2011-05-24 22:50 ` [PATCH 4/4] handle_options(): do not miscount how many arguments were used Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110524224945.GB24527@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).