diff options
author | Tanay Abhra <tanayabh@gmail.com> | 2014-08-13 17:52:56 +0530 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-08-13 12:36:02 -0700 |
commit | 536900e5b24f8341bcaf2a26371fcd3ca417eef9 (patch) | |
tree | f50c8438c2387005a050301bf43b3ee09c859146 /fast-import.c | |
parent | 540b0f497701fca2749de86c58bc16f44fcb30b5 (diff) | |
download | git-536900e5b24f8341bcaf2a26371fcd3ca417eef9.tar.gz |
fast-import.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.
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>
Diffstat (limited to 'fast-import.c')
-rw-r--r-- | fast-import.c | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/fast-import.c b/fast-import.c index d73f58cbe3..34e780dcd0 100644 --- a/fast-import.c +++ b/fast-import.c @@ -3274,36 +3274,34 @@ static void parse_option(const char *option) die("This version of fast-import does not support option: %s", option); } -static int git_pack_config(const char *k, const char *v, void *cb) +static void git_pack_config(void) { - if (!strcmp(k, "pack.depth")) { - max_depth = git_config_int(k, v); + int indexversion_value; + unsigned long packsizelimit_value; + + if (!git_config_get_ulong("pack.depth", &max_depth)) { if (max_depth > MAX_DEPTH) max_depth = MAX_DEPTH; - return 0; } - if (!strcmp(k, "pack.compression")) { - int level = git_config_int(k, v); - if (level == -1) - level = Z_DEFAULT_COMPRESSION; - else if (level < 0 || level > Z_BEST_COMPRESSION) - die("bad pack compression level %d", level); - pack_compression_level = level; + if (!git_config_get_int("pack.compression", &pack_compression_level)) { + if (pack_compression_level == -1) + pack_compression_level = Z_DEFAULT_COMPRESSION; + else if (pack_compression_level < 0 || + pack_compression_level > Z_BEST_COMPRESSION) + git_die_config("pack.compression", + "bad pack compression level %d", pack_compression_level); pack_compression_seen = 1; - return 0; } - if (!strcmp(k, "pack.indexversion")) { - pack_idx_opts.version = git_config_int(k, v); + if (!git_config_get_int("pack.indexversion", &indexversion_value)) { + pack_idx_opts.version = indexversion_value; if (pack_idx_opts.version > 2) - die("bad pack.indexversion=%"PRIu32, - pack_idx_opts.version); - return 0; + git_die_config("pack.indexversion", + "bad pack.indexversion=%"PRIu32, pack_idx_opts.version); } - if (!strcmp(k, "pack.packsizelimit")) { - max_packsize = git_config_ulong(k, v); - return 0; - } - return git_default_config(k, v, cb); + if (!git_config_get_ulong("pack.packsizelimit", &packsizelimit_value)) + max_packsize = packsizelimit_value; + + git_config(git_default_config, NULL); } static const char fast_import_usage[] = @@ -3356,7 +3354,7 @@ int main(int argc, char **argv) setup_git_directory(); reset_pack_idx_option(&pack_idx_opts); - git_config(git_pack_config, NULL); + git_pack_config(); if (!pack_compression_seen && core_compression_seen) pack_compression_level = core_compression_level; |