read-cache.c: replace `git_config()` with `git_config_get_*()` family
Use `git_config_get_*()` family instead of `git_config()` to take advantage of the config-set API which provides a cleaner control flow. Use an intermediate value, as `version` can not be used directly in git_config_get_int() due to incompatible type. 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
b27a5720996172fbb2cc809f88f4eea09b5bbc42
1 file changed
+3
-11
read-cache.c
+3
-11
@@ -1238,24 +1238,16 @@ static struct cache_entry *refresh_cache_entry(struct cache_entry *ce,
1238
1239
#define INDEX_FORMAT_DEFAULT 3
1240
1241
-static int index_format_config(const char *var, const char *value, void *cb)
1242
-{
1243
- unsigned int *version = cb;
1244
- if (!strcmp(var, "index.version")) {
1245
- *version = git_config_int(var, value);
1246
- return 0;
1247
- }
1248
- return 1;
1249
-}
1250
-
1241
static unsigned int get_index_format_default(void)
1242
{
1243
char *envversion = getenv("GIT_INDEX_VERSION");
1244
char *endp;
1245
+ int value;
1246
unsigned int version = INDEX_FORMAT_DEFAULT;
1247
1248
if (!envversion) {
1258
- git_config(index_format_config, &version);
1249
+ if (!git_config_get_int("index.version", &value))
1250
+ version = value;
1251
if (version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < version) {
1252
warning(_("index.version set, but the value is invalid.\n"
1253
"Using version %i"), INDEX_FORMAT_DEFAULT);