scale the provided value by 1024, 1024^2 or 1024^3 respectively.
The scaled value is put into `int_var`.
-`OPT_MAGNITUDE(short, long, &unsigned_long_var, description)`::
- Introduce an option with a size argument. The argument must be a
+`OPT_UNSIGNED(short, long, &unsigned_long_var, description)`::
+ Introduce an option with an unsigned integer argument. The argument must be a
non-negative integer and may include a suffix of 'k', 'm' or 'g' to
scale the provided value by 1024, 1024^2 or 1024^3 respectively.
The scaled value is put into `unsigned_long_var`.
.defval = (intptr_t)prune_expire_arg,
},
OPT_BOOL(0, "cruft", &cfg.cruft_packs, N_("pack unreferenced objects separately")),
- OPT_MAGNITUDE(0, "max-cruft-size", &cfg.max_cruft_size,
- N_("with --cruft, limit the size of new cruft packs")),
+ OPT_UNSIGNED(0, "max-cruft-size", &cfg.max_cruft_size,
+ N_("with --cruft, limit the size of new cruft packs")),
OPT_BOOL(0, "aggressive", &aggressive, N_("be more thorough (increased runtime)")),
OPT_BOOL_F(0, "auto", &opts.auto_flag, N_("enable auto-gc mode"),
PARSE_OPT_NOCOMPLETE),
{
struct option *options;
static struct option builtin_multi_pack_index_repack_options[] = {
- OPT_MAGNITUDE(0, "batch-size", &opts.batch_size,
+ OPT_UNSIGNED(0, "batch-size", &opts.batch_size,
N_("during repack, collect pack-files of smaller size into a batch that is larger than this size")),
OPT_BIT(0, "progress", &opts.flags,
N_("force progress reporting"), MIDX_PROGRESS),
OPT_CALLBACK_F(0, "index-version", &pack_idx_opts, N_("<version>[,<offset>]"),
N_("write the pack index file in the specified idx format version"),
PARSE_OPT_NONEG, option_parse_index_version),
- OPT_MAGNITUDE(0, "max-pack-size", &pack_size_limit,
- N_("maximum size of each output pack file")),
+ OPT_UNSIGNED(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_MAGNITUDE(0, "window-memory", &window_memory_limit,
- N_("limit pack window by memory in addition to object limit")),
+ OPT_UNSIGNED(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,
PACK_CRUFT),
OPT_STRING(0, "cruft-expiration", &cruft_expiration, N_("approxidate"),
N_("with --cruft, expire objects older than this")),
- OPT_MAGNITUDE(0, "max-cruft-size", &cruft_po_args.max_pack_size,
- N_("with --cruft, limit the size of new cruft packs")),
+ OPT_UNSIGNED(0, "max-cruft-size", &cruft_po_args.max_pack_size,
+ N_("with --cruft, limit the size of new cruft packs")),
OPT_BOOL('d', NULL, &delete_redundant,
N_("remove redundant packs, and run git-prune-packed")),
OPT_BOOL('f', NULL, &po_args.no_reuse_delta,
N_("limits the maximum delta depth")),
OPT_STRING(0, "threads", &opt_threads, N_("n"),
N_("limits the maximum number of threads")),
- OPT_MAGNITUDE(0, "max-pack-size", &po_args.max_pack_size,
- N_("maximum size of each packfile")),
+ OPT_UNSIGNED(0, "max-pack-size", &po_args.max_pack_size,
+ N_("maximum size of each packfile")),
OPT_PARSE_LIST_OBJECTS_FILTER(&po_args.filter_options),
OPT_BOOL(0, "pack-kept-objects", &pack_kept_objects,
N_("repack objects in packs marked with .keep")),
optname(opt, flags));
return 0;
- case OPTION_MAGNITUDE:
+ case OPTION_UNSIGNED:
if (unset) {
*(unsigned long *)opt->value = 0;
return 0;
case OPTION_STRING:
case OPTION_FILENAME:
case OPTION_INTEGER:
- case OPTION_MAGNITUDE:
+ case OPTION_UNSIGNED:
case OPTION_CALLBACK:
case OPTION_BIT:
case OPTION_NEGBIT:
case OPTION_STRING:
case OPTION_FILENAME:
case OPTION_INTEGER:
- case OPTION_MAGNITUDE:
+ case OPTION_UNSIGNED:
case OPTION_CALLBACK:
if (opts->flags & PARSE_OPT_NOARG)
break;
/* options with arguments (usually) */
OPTION_STRING,
OPTION_INTEGER,
- OPTION_MAGNITUDE,
+ OPTION_UNSIGNED,
OPTION_CALLBACK,
OPTION_LOWLEVEL_CALLBACK,
OPTION_FILENAME
#define OPT_CMDMODE(s, l, v, h, i) OPT_CMDMODE_F(s, l, v, h, i, 0)
#define OPT_INTEGER(s, l, v, h) OPT_INTEGER_F(s, l, v, h, 0)
-#define OPT_MAGNITUDE(s, l, v, h) { \
- .type = OPTION_MAGNITUDE, \
+#define OPT_UNSIGNED(s, l, v, h) { \
+ .type = OPTION_UNSIGNED, \
.short_name = (s), \
.long_name = (l), \
.value = (v), \
static int boolean = 0;
static int integer = 0;
-static unsigned long magnitude = 0;
+static unsigned long unsigned_integer = 0;
static timestamp_t timestamp;
static int abbrev = 7;
static int verbose = -1; /* unspecified */
OPT_GROUP(""),
OPT_INTEGER('i', "integer", &integer, "get a integer"),
OPT_INTEGER('j', NULL, &integer, "get a integer, too"),
- OPT_MAGNITUDE('m', "magnitude", &magnitude, "get a magnitude"),
+ OPT_UNSIGNED('u', "unsigned", &unsigned_integer, "get an unsigned integer"),
OPT_SET_INT(0, "set23", &integer, "set integer to 23", 23),
OPT_CMDMODE(0, "mode1", &integer, "set integer to 1 (cmdmode option)", 1),
OPT_CMDMODE(0, "mode2", &integer, "set integer to 2 (cmdmode option)", 2),
}
show(&expect, &ret, "boolean: %d", boolean);
show(&expect, &ret, "integer: %d", integer);
- show(&expect, &ret, "magnitude: %lu", magnitude);
+ show(&expect, &ret, "unsigned: %lu", unsigned_integer);
show(&expect, &ret, "timestamp: %"PRItime, timestamp);
show(&expect, &ret, "string: %s", string ? string : "(not set)");
show(&expect, &ret, "abbrev: %d", abbrev);
-i, --[no-]integer <n>
get a integer
-j <n> get a integer, too
- -m, --magnitude <n> get a magnitude
+ -u, --unsigned <n> get an unsigned integer
--[no-]set23 set integer to 23
--mode1 set integer to 1 (cmdmode option)
--mode2 set integer to 2 (cmdmode option)
test_expect_success 'OPT_INTEGER() kilo' 'check integer: 239616 -i 234k'
test_expect_success 'OPT_INTEGER() negative kilo' 'check integer: -239616 -i -234k'
-test_expect_success 'OPT_MAGNITUDE() simple' '
- check magnitude: 2345678 -m 2345678
+test_expect_success 'OPT_UNSIGNED() simple' '
+ check unsigned: 2345678 -u 2345678
'
-test_expect_success 'OPT_MAGNITUDE() kilo' '
- check magnitude: 239616 -m 234k
+test_expect_success 'OPT_UNSIGNED() kilo' '
+ check unsigned: 239616 -u 234k
'
-test_expect_success 'OPT_MAGNITUDE() mega' '
- check magnitude: 104857600 -m 100m
+test_expect_success 'OPT_UNSIGNED() mega' '
+ check unsigned: 104857600 -u 100m
'
-test_expect_success 'OPT_MAGNITUDE() giga' '
- check magnitude: 1073741824 -m 1g
+test_expect_success 'OPT_UNSIGNED() giga' '
+ check unsigned: 1073741824 -u 1g
'
-test_expect_success 'OPT_MAGNITUDE() 3giga' '
- check magnitude: 3221225472 -m 3g
+test_expect_success 'OPT_UNSIGNED() 3giga' '
+ check unsigned: 3221225472 -u 3g
'
cat >expect <<\EOF
boolean: 2
integer: 1729
-magnitude: 16384
+unsigned: 16384
timestamp: 0
string: 123
abbrev: 7
EOF
test_expect_success 'short options' '
- test-tool parse-options -s123 -b -i 1729 -m 16k -b -vv -n -F my.file \
+ test-tool parse-options -s123 -b -i 1729 -u 16k -b -vv -n -F my.file \
>output 2>output.err &&
test_cmp expect output &&
test_must_be_empty output.err
cat >expect <<\EOF
boolean: 2
integer: 1729
-magnitude: 16384
+unsigned: 16384
timestamp: 0
string: 321
abbrev: 10
EOF
test_expect_success 'long options' '
- test-tool parse-options --boolean --integer 1729 --magnitude 16k \
+ test-tool parse-options --boolean --integer 1729 --unsigned 16k \
--boolean --string2=321 --verbose --verbose --no-dry-run \
--abbrev=10 --file fi.le --obsolete \
>output 2>output.err &&
cat >expect <<-EOF &&
boolean: 0
integer: 0
- magnitude: 0
+ unsigned: 0
timestamp: 0
string: (not set)
abbrev: 100
cat >expect <<\EOF
boolean: 1
integer: 13
-magnitude: 0
+unsigned: 0
timestamp: 0
string: 123
abbrev: 7
cat >expect <<\EOF
boolean: 0
integer: 2
-magnitude: 0
+unsigned: 0
timestamp: 0
string: (not set)
abbrev: 7
Callback: "four", 0
boolean: 5
integer: 4
-magnitude: 0
+unsigned: 0
timestamp: 0
string: (not set)
abbrev: 7
cat >expect <<\EOF
boolean: 1
integer: 23
-magnitude: 0
+unsigned: 0
timestamp: 0
string: (not set)
abbrev: 7
cat >expect <<\EOF
boolean: 0
integer: 0
-magnitude: 0
+unsigned: 0
timestamp: 0
string: (not set)
abbrev: 7
grep ^BUG err
'
-test_expect_success 'negative magnitude' '
- test_must_fail test-tool parse-options --magnitude -1 >out 2>err &&
+test_expect_success 'negative unsigned' '
+ test_must_fail test-tool parse-options --unsigned -1 >out 2>err &&
grep "non-negative integer" err &&
test_must_be_empty out
'
-test_expect_success 'magnitude with units but no numbers' '
- test_must_fail test-tool parse-options --magnitude m >out 2>err &&
+test_expect_success 'unsigned with units but no numbers' '
+ test_must_fail test-tool parse-options --unsigned m >out 2>err &&
grep "non-negative integer" err &&
test_must_be_empty out
'