config: allow uppercase number suffixes

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
This commit is contained in:
Carlos Martín Nieto 2011-04-19 16:34:22 +02:00
parent 53345e1f1f
commit a99264bff6
3 changed files with 12 additions and 0 deletions

View File

@ -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:

Binary file not shown.

View File

@ -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