Commit a99264bff6bc4a16c335a09dab1b6c6c9a763a10

Carlos Martín Nieto 2011-04-19T16:34:22

config: allow uppercase number suffixes Signed-off-by: Carlos Martín Nieto <cmn@elego.de>

diff --git a/src/config.c b/src/config.c
index 9e62df0..ec350f8 100644
--- a/src/config.c
+++ b/src/config.c
@@ -394,12 +394,15 @@ int git_config_get_long(git_config *cfg, const char *name, long int *out)
 	case '\0':
 		break;
 	case 'k':
+	case 'K':
 		num *= 1024;
 		break;
 	case 'm':
+	case 'M':
 		num *= 1024 * 1024;
 		break;
 	case 'g':
+	case 'G':
 		num *= 1024 * 1024 * 1024;
 		break;
 	default:
diff --git a/tests/resources/config/config5 b/tests/resources/config/config5
index 645fe76..8ab60cc 100644
--- a/tests/resources/config/config5
+++ b/tests/resources/config/config5
@@ -2,5 +2,8 @@
 [number]
 		simple = 1
 		k = 1k
+		kk = 1K
 		m = 1m
+		mm = 1M
 		g = 1g
+		gg = 1G
diff --git a/tests/t15-config.c b/tests/t15-config.c
index 1cf4b41..8e0d321 100644
--- a/tests/t15-config.c
+++ b/tests/t15-config.c
@@ -142,12 +142,21 @@ BEGIN_TEST(config5, "test number suffixes")
 	must_pass(git_config_get_long(cfg, "number.k", &i));
 	must_be_true(i == 1 * 1024);
 
+	must_pass(git_config_get_long(cfg, "number.kk", &i));
+	must_be_true(i == 1 * 1024);
+
 	must_pass(git_config_get_long(cfg, "number.m", &i));
 	must_be_true(i == 1 * 1024 * 1024);
 
+	must_pass(git_config_get_long(cfg, "number.mm", &i));
+	must_be_true(i == 1 * 1024 * 1024);
+
 	must_pass(git_config_get_long(cfg, "number.g", &i));
 	must_be_true(i == 1 * 1024 * 1024 * 1024);
 
+	must_pass(git_config_get_long(cfg, "number.gg", &i));
+	must_be_true(i == 1 * 1024 * 1024 * 1024);
+
 	git_config_free(cfg);
 END_TEST