Commit a99264bf by Carlos Martín Nieto

config: allow uppercase number suffixes

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
parent 53345e1f
......@@ -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:
......
......@@ -2,5 +2,8 @@
[number]
simple = 1
k = 1k
kk = 1K
m = 1m
mm = 1M
g = 1g
gg = 1G
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment