diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2006-12-30 22:13:05 -0500 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-12-30 22:22:14 -0800 |
commit | d77a64d353cea0f72655b86dd04bcf9f86cbbea6 (patch) | |
tree | c22b7a32a3e49131834cf304c03cdc3ef823d0d3 /config.c | |
parent | 95d3c4f546c664c3571dd4a93f11ae2f54e55e6e (diff) | |
download | git-d77a64d353cea0f72655b86dd04bcf9f86cbbea6.tar.gz git-d77a64d353cea0f72655b86dd04bcf9f86cbbea6.tar.xz |
Teach Git how to parse standard power of 2 suffixes.
Sometimes its necessary to supply a value as a power of two in a
configuration parameter. In this case the user may want to use the
standard suffixes such as K, M, or G to indicate that the numerical
value should be multiplied by a constant base before being used.
Shell scripts/etc. can also benefit from this automatic option
parsing with `git repo-config --int`.
[jc: with a couple of test and a slight input tightening]
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -238,6 +238,12 @@ int git_config_int(const char *name, const char *value) int val = strtol(value, &end, 0); if (!*end) return val; + if (!strcasecmp(end, "k")) + return val * 1024; + if (!strcasecmp(end, "m")) + return val * 1024 * 1024; + if (!strcasecmp(end, "g")) + return val * 1024 * 1024 * 1024; } die("bad config value for '%s' in %s", name, config_file_name); } |