diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-01-21 15:29:58 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-01-22 11:44:01 -0800 |
commit | 81dd4fd384d24ad247a88d1d04778de241e1781a (patch) | |
tree | 5a31e1900133b68e24c3ca7d6623dec9228a1702 /builtin/pack-objects.c | |
parent | 35c141768c4c7c486017a2d0cc615b9384b4b672 (diff) | |
download | git-jc/parse-options-humint.tar.gz |
parse-options: refactor human-friendly-integer parser out of pack-objectsjc/parse-options-humint
We only had code to understand unit suffixes such as g/m/k (as in
2g/400m/8k) in the configuration parser but not in the command line
option parser. "git pack-objects" worked it around by having a
custom extension to the parse-options API; make it available to
other callers.
The new macro is not called OPT_ULONG() but OPT_HUM_ULONG(), as it
would be bizzarre to have ULONG that understands human friendly
units while INTEGER that does not. It is not named with a shorter
"OPT_HULONG", primarily to avoid having to name a future parallel
for parsing human friendly integer "OPT_HINT".
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/pack-objects.c')
-rw-r--r-- | builtin/pack-objects.c | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index f069462cb0..2fa8e1e258 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -2417,23 +2417,6 @@ static int option_parse_unpack_unreachable(const struct option *opt, return 0; } -static int option_parse_ulong(const struct option *opt, - const char *arg, int unset) -{ - if (unset) - die(_("option %s does not accept negative form"), - opt->long_name); - - if (!git_parse_ulong(arg, opt->value)) - die(_("unable to parse value '%s' for option %s"), - arg, opt->long_name); - return 0; -} - -#define OPT_ULONG(s, l, v, h) \ - { OPTION_CALLBACK, (s), (l), (v), "n", (h), \ - PARSE_OPT_NONEG, option_parse_ulong } - int cmd_pack_objects(int argc, const char **argv, const char *prefix) { int use_internal_rev_list = 0; @@ -2455,16 +2438,16 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) { OPTION_CALLBACK, 0, "index-version", NULL, N_("version[,offset]"), N_("write the pack index file in the specified idx format version"), 0, option_parse_index_version }, - OPT_ULONG(0, "max-pack-size", &pack_size_limit, - N_("maximum size of each output pack file")), + OPT_HUM_ULONG(0, "max-pack-size", &pack_size_limit, + N_("maximum size of each output pack file")), OPT_BOOL(0, "local", &local, N_("ignore borrowed objects from alternate object store")), OPT_BOOL(0, "incremental", &incremental, N_("ignore packed objects")), OPT_INTEGER(0, "window", &window, N_("limit pack window by objects")), - OPT_ULONG(0, "window-memory", &window_memory_limit, - N_("limit pack window by memory in addition to object limit")), + OPT_HUM_ULONG(0, "window-memory", &window_memory_limit, + N_("limit pack window by memory in addition to object limit")), OPT_INTEGER(0, "depth", &depth, N_("maximum length of delta chain allowed in the resulting pack")), OPT_BOOL(0, "reuse-delta", &reuse_delta, |