All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] fast-import.c: replace `git_config()` with `git_config_get_*()` family
@ 2014-08-13  8:21 Tanay Abhra
  2014-08-13  8:22 ` [PATCH 2/4] ll-merge.c: refactor `read_merge_config()` to use `git_config_string()` Tanay Abhra
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Tanay Abhra @ 2014-08-13  8:21 UTC (permalink / raw)
  To: git; +Cc: Tanay Abhra, Matthieu Moy, Ramkumar Ramachandra

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>
---
 fast-import.c | 42 +++++++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/fast-import.c b/fast-import.c
index d73f58c..eca5ed4 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -3274,36 +3274,32 @@ 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)
+			die("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;
+			die("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 +3352,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;
 
-- 
1.9.0.GIT

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2014-08-13 17:18 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-13  8:21 [PATCH 1/4] fast-import.c: replace `git_config()` with `git_config_get_*()` family Tanay Abhra
2014-08-13  8:22 ` [PATCH 2/4] ll-merge.c: refactor `read_merge_config()` to use `git_config_string()` Tanay Abhra
2014-08-13 11:32   ` Matthieu Moy
2014-08-13 12:43     ` [PATCH v2 " Tanay Abhra
2014-08-13 13:07       ` Matthieu Moy
2014-08-13 17:07       ` Junio C Hamano
2014-08-13  8:22 ` [PATCH 3/4] merge-recursive.c: replace `git_config()` with `git_config_get_int()` Tanay Abhra
2014-08-13 11:34   ` Matthieu Moy
2014-08-13  8:22 ` [PATCH 4/4] builtin/apply.c: replace `git_config()` with `git_config_get_string_const()` Tanay Abhra
2014-08-13 11:24 ` [PATCH 1/4] fast-import.c: replace `git_config()` with `git_config_get_*()` family Matthieu Moy
2014-08-13 12:11   ` Tanay Abhra
2014-08-13 12:22   ` [PATCH v2 1/5] " Tanay Abhra
2014-08-13 13:10     ` Matthieu Moy
2014-08-13 13:33       ` [PATCH/RFC v2 1/2] git_default_config() rewritten using the config-set API Tanay Abhra
2014-08-13 13:39         ` [PATCH/RFC v2 2/2] use the new git_default_config() Tanay Abhra
2014-08-13 16:00         ` [PATCH/RFC v2 1/2] git_default_config() rewritten using the config-set API Matthieu Moy
2014-08-13 17:18           ` Junio C Hamano
2014-08-13 16:16         ` Matthieu Moy
2014-08-13 17:14   ` [PATCH 1/4] fast-import.c: replace `git_config()` with `git_config_get_*()` family Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.