From 44b96ecaa84b1de72a57e27143bf9aca75f251b9 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 22 Jan 2014 20:27:52 -0500 Subject: repack: fix typo in max-pack-size option When we see "--max-pack-size", we accidentally propagated this to pack-objects as "--max_pack_size", which does not work at all. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin/repack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/repack.c b/builtin/repack.c index a0ff5c704f..512a53afd8 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -191,7 +191,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix) if (depth) argv_array_pushf(&cmd_args, "--depth=%u", depth); if (max_pack_size) - argv_array_pushf(&cmd_args, "--max_pack_size=%u", max_pack_size); + argv_array_pushf(&cmd_args, "--max-pack-size=%u", max_pack_size); if (no_reuse_delta) argv_array_pushf(&cmd_args, "--no-reuse-delta"); if (no_reuse_object) -- cgit v1.2.3 From aa8bd519dbf044f4b54a365c9c80c6eb9a1ee2ea Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 22 Jan 2014 20:28:30 -0500 Subject: repack: make parsed string options const-correct When we use OPT_STRING to parse an option, we get back a pointer into the argv array, which should be "const char *". The compiler doesn't notice because it gets passed through a "void *" in the option struct. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin/repack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/repack.c b/builtin/repack.c index 512a53afd8..3dbb0ed199 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -129,7 +129,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix) /* variables to be filled by option parsing */ int pack_everything = 0; int delete_redundant = 0; - char *unpack_unreachable = NULL; + const char *unpack_unreachable = NULL; int window = 0, window_memory = 0; int depth = 0; int max_pack_size = 0; -- cgit v1.2.3 From b861e235bc68e1c085e48d029579afbeeeec995c Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 22 Jan 2014 20:30:13 -0500 Subject: repack: propagate pack-objects options as strings In the original shell version of git-repack, any options destined for pack-objects were left as strings, and passed as a whole. Since the C rewrite in commit a1bbc6c (repack: rewrite the shell script in C, 2013-09-15), we now parse these values to integers internally, then reformat the integers when passing the option to pack-objects. This has the advantage that we catch format errors earlier (i.e., when repack is invoked, rather than when pack-objects is invoked). It has three disadvantages, though: 1. Our internal data types may not be the right size. In the case of "--window-memory" and "--max-pack-size", these are "unsigned long" in pack-objects, but we can only represent a regular "int". 2. Our parsing routines might not be the same as those of pack-objects. For the two options above, pack-objects understands "100m" to mean "100 megabytes", but repack does not. 3. We have to keep a sentinel value to know whether it is worth passing the option along. In the case of "--window-memory", we currently do not pass it if the value is "0". But that is a meaningful value to pack-objects, where it overrides any configured value. We can fix all of these by simply passing the strings from the user along to pack-objects verbatim. This does not actually fix anything for "--depth" or "--window", but these are converted, too, for consistency. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin/repack.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'builtin') diff --git a/builtin/repack.c b/builtin/repack.c index 3dbb0ed199..bca771054e 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -130,9 +130,9 @@ int cmd_repack(int argc, const char **argv, const char *prefix) int pack_everything = 0; int delete_redundant = 0; const char *unpack_unreachable = NULL; - int window = 0, window_memory = 0; - int depth = 0; - int max_pack_size = 0; + const char *window = NULL, *window_memory = NULL; + const char *depth = NULL; + const char *max_pack_size = NULL; int no_reuse_delta = 0, no_reuse_object = 0; int no_update_server_info = 0; int quiet = 0; @@ -157,13 +157,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix) N_("pass --local to git-pack-objects")), OPT_STRING(0, "unpack-unreachable", &unpack_unreachable, N_("approxidate"), N_("with -A, do not loosen objects older than this")), - OPT_INTEGER(0, "window", &window, + OPT_STRING(0, "window", &window, N_("n"), N_("size of the window used for delta compression")), - OPT_INTEGER(0, "window-memory", &window_memory, + OPT_STRING(0, "window-memory", &window_memory, N_("bytes"), N_("same as the above, but limit memory size instead of entries count")), - OPT_INTEGER(0, "depth", &depth, + OPT_STRING(0, "depth", &depth, N_("n"), N_("limits the maximum delta depth")), - OPT_INTEGER(0, "max-pack-size", &max_pack_size, + OPT_STRING(0, "max-pack-size", &max_pack_size, N_("bytes"), N_("maximum size of each packfile")), OPT_END() }; @@ -185,13 +185,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix) argv_array_push(&cmd_args, "--all"); argv_array_push(&cmd_args, "--reflog"); if (window) - argv_array_pushf(&cmd_args, "--window=%u", window); + argv_array_pushf(&cmd_args, "--window=%s", window); if (window_memory) - argv_array_pushf(&cmd_args, "--window-memory=%u", window_memory); + argv_array_pushf(&cmd_args, "--window-memory=%s", window_memory); if (depth) - argv_array_pushf(&cmd_args, "--depth=%u", depth); + argv_array_pushf(&cmd_args, "--depth=%s", depth); if (max_pack_size) - argv_array_pushf(&cmd_args, "--max-pack-size=%u", max_pack_size); + argv_array_pushf(&cmd_args, "--max-pack-size=%s", max_pack_size); if (no_reuse_delta) argv_array_pushf(&cmd_args, "--no-reuse-delta"); if (no_reuse_object) -- cgit v1.2.3