Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit b861e23

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aa8bd51 commit b861e23

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

builtin/repack.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
130130
int pack_everything = 0;
131131
int delete_redundant = 0;
132132
const char *unpack_unreachable = NULL;
133-
int window = 0, window_memory = 0;
134-
int depth = 0;
135-
int max_pack_size = 0;
133+
const char *window = NULL, *window_memory = NULL;
134+
const char *depth = NULL;
135+
const char *max_pack_size = NULL;
136136
int no_reuse_delta = 0, no_reuse_object = 0;
137137
int no_update_server_info = 0;
138138
int quiet = 0;
@@ -157,13 +157,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
157157
N_("pass --local to git-pack-objects")),
158158
OPT_STRING(0, "unpack-unreachable", &unpack_unreachable, N_("approxidate"),
159159
N_("with -A, do not loosen objects older than this")),
160-
OPT_INTEGER(0, "window", &window,
160+
OPT_STRING(0, "window", &window, N_("n"),
161161
N_("size of the window used for delta compression")),
162-
OPT_INTEGER(0, "window-memory", &window_memory,
162+
OPT_STRING(0, "window-memory", &window_memory, N_("bytes"),
163163
N_("same as the above, but limit memory size instead of entries count")),
164-
OPT_INTEGER(0, "depth", &depth,
164+
OPT_STRING(0, "depth", &depth, N_("n"),
165165
N_("limits the maximum delta depth")),
166-
OPT_INTEGER(0, "max-pack-size", &max_pack_size,
166+
OPT_STRING(0, "max-pack-size", &max_pack_size, N_("bytes"),
167167
N_("maximum size of each packfile")),
168168
OPT_END()
169169
};
@@ -185,13 +185,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
185185
argv_array_push(&cmd_args, "--all");
186186
argv_array_push(&cmd_args, "--reflog");
187187
if (window)
188-
argv_array_pushf(&cmd_args, "--window=%u", window);
188+
argv_array_pushf(&cmd_args, "--window=%s", window);
189189
if (window_memory)
190-
argv_array_pushf(&cmd_args, "--window-memory=%u", window_memory);
190+
argv_array_pushf(&cmd_args, "--window-memory=%s", window_memory);
191191
if (depth)
192-
argv_array_pushf(&cmd_args, "--depth=%u", depth);
192+
argv_array_pushf(&cmd_args, "--depth=%s", depth);
193193
if (max_pack_size)
194-
argv_array_pushf(&cmd_args, "--max-pack-size=%u", max_pack_size);
194+
argv_array_pushf(&cmd_args, "--max-pack-size=%s", max_pack_size);
195195
if (no_reuse_delta)
196196
argv_array_pushf(&cmd_args, "--no-reuse-delta");
197197
if (no_reuse_object)

0 commit comments

Comments
 (0)