@@ -138,6 +138,47 @@ static void remove_redundant_pack(const char *dir_name, const char *base_name)
138
138
strbuf_release (& buf );
139
139
}
140
140
141
+ struct pack_objects_args {
142
+ const char * window ;
143
+ const char * window_memory ;
144
+ const char * depth ;
145
+ const char * threads ;
146
+ const char * max_pack_size ;
147
+ int no_reuse_delta ;
148
+ int no_reuse_object ;
149
+ int quiet ;
150
+ int local ;
151
+ };
152
+
153
+ static void prepare_pack_objects (struct child_process * cmd ,
154
+ const struct pack_objects_args * args )
155
+ {
156
+ argv_array_push (& cmd -> args , "pack-objects" );
157
+ if (args -> window )
158
+ argv_array_pushf (& cmd -> args , "--window=%s" , args -> window );
159
+ if (args -> window_memory )
160
+ argv_array_pushf (& cmd -> args , "--window-memory=%s" , args -> window_memory );
161
+ if (args -> depth )
162
+ argv_array_pushf (& cmd -> args , "--depth=%s" , args -> depth );
163
+ if (args -> threads )
164
+ argv_array_pushf (& cmd -> args , "--threads=%s" , args -> threads );
165
+ if (args -> max_pack_size )
166
+ argv_array_pushf (& cmd -> args , "--max-pack-size=%s" , args -> max_pack_size );
167
+ if (args -> no_reuse_delta )
168
+ argv_array_pushf (& cmd -> args , "--no-reuse-delta" );
169
+ if (args -> no_reuse_object )
170
+ argv_array_pushf (& cmd -> args , "--no-reuse-object" );
171
+ if (args -> local )
172
+ argv_array_push (& cmd -> args , "--local" );
173
+ if (args -> quiet )
174
+ argv_array_push (& cmd -> args , "--quiet" );
175
+ if (delta_base_offset )
176
+ argv_array_push (& cmd -> args , "--delta-base-offset" );
177
+ argv_array_push (& cmd -> args , packtmp );
178
+ cmd -> git_cmd = 1 ;
179
+ cmd -> out = -1 ;
180
+ }
181
+
141
182
#define ALL_INTO_ONE 1
142
183
#define LOOSEN_UNREACHABLE 2
143
184
@@ -165,15 +206,9 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
165
206
int delete_redundant = 0 ;
166
207
const char * unpack_unreachable = NULL ;
167
208
int keep_unreachable = 0 ;
168
- const char * window = NULL , * window_memory = NULL ;
169
- const char * depth = NULL ;
170
- const char * threads = NULL ;
171
- const char * max_pack_size = NULL ;
172
209
struct string_list keep_pack_list = STRING_LIST_INIT_NODUP ;
173
- int no_reuse_delta = 0 , no_reuse_object = 0 ;
174
210
int no_update_server_info = 0 ;
175
- int quiet = 0 ;
176
- int local = 0 ;
211
+ struct pack_objects_args po_args = {NULL };
177
212
178
213
struct option builtin_repack_options [] = {
179
214
OPT_BIT ('a' , NULL , & pack_everything ,
@@ -183,30 +218,30 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
183
218
LOOSEN_UNREACHABLE | ALL_INTO_ONE ),
184
219
OPT_BOOL ('d' , NULL , & delete_redundant ,
185
220
N_ ("remove redundant packs, and run git-prune-packed" )),
186
- OPT_BOOL ('f' , NULL , & no_reuse_delta ,
221
+ OPT_BOOL ('f' , NULL , & po_args . no_reuse_delta ,
187
222
N_ ("pass --no-reuse-delta to git-pack-objects" )),
188
- OPT_BOOL ('F' , NULL , & no_reuse_object ,
223
+ OPT_BOOL ('F' , NULL , & po_args . no_reuse_object ,
189
224
N_ ("pass --no-reuse-object to git-pack-objects" )),
190
225
OPT_BOOL ('n' , NULL , & no_update_server_info ,
191
226
N_ ("do not run git-update-server-info" )),
192
- OPT__QUIET (& quiet , N_ ("be quiet" )),
193
- OPT_BOOL ('l' , "local" , & local ,
227
+ OPT__QUIET (& po_args . quiet , N_ ("be quiet" )),
228
+ OPT_BOOL ('l' , "local" , & po_args . local ,
194
229
N_ ("pass --local to git-pack-objects" )),
195
230
OPT_BOOL ('b' , "write-bitmap-index" , & write_bitmaps ,
196
231
N_ ("write bitmap index" )),
197
232
OPT_STRING (0 , "unpack-unreachable" , & unpack_unreachable , N_ ("approxidate" ),
198
233
N_ ("with -A, do not loosen objects older than this" )),
199
234
OPT_BOOL ('k' , "keep-unreachable" , & keep_unreachable ,
200
235
N_ ("with -a, repack unreachable objects" )),
201
- OPT_STRING (0 , "window" , & window , N_ ("n" ),
236
+ OPT_STRING (0 , "window" , & po_args . window , N_ ("n" ),
202
237
N_ ("size of the window used for delta compression" )),
203
- OPT_STRING (0 , "window-memory" , & window_memory , N_ ("bytes" ),
238
+ OPT_STRING (0 , "window-memory" , & po_args . window_memory , N_ ("bytes" ),
204
239
N_ ("same as the above, but limit memory size instead of entries count" )),
205
- OPT_STRING (0 , "depth" , & depth , N_ ("n" ),
240
+ OPT_STRING (0 , "depth" , & po_args . depth , N_ ("n" ),
206
241
N_ ("limits the maximum delta depth" )),
207
- OPT_STRING (0 , "threads" , & threads , N_ ("n" ),
242
+ OPT_STRING (0 , "threads" , & po_args . threads , N_ ("n" ),
208
243
N_ ("limits the maximum number of threads" )),
209
- OPT_STRING (0 , "max-pack-size" , & max_pack_size , N_ ("bytes" ),
244
+ OPT_STRING (0 , "max-pack-size" , & po_args . max_pack_size , N_ ("bytes" ),
210
245
N_ ("maximum size of each packfile" )),
211
246
OPT_BOOL (0 , "pack-kept-objects" , & pack_kept_objects ,
212
247
N_ ("repack objects in packs marked with .keep" )),
@@ -238,7 +273,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
238
273
239
274
sigchain_push_common (remove_pack_on_signal );
240
275
241
- argv_array_push (& cmd .args , "pack-objects" );
276
+ prepare_pack_objects (& cmd , & po_args );
277
+
242
278
argv_array_push (& cmd .args , "--keep-true-parents" );
243
279
if (!pack_kept_objects )
244
280
argv_array_push (& cmd .args , "--honor-pack-keep" );
@@ -251,20 +287,6 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
251
287
argv_array_push (& cmd .args , "--indexed-objects" );
252
288
if (repository_format_partial_clone )
253
289
argv_array_push (& cmd .args , "--exclude-promisor-objects" );
254
- if (window )
255
- argv_array_pushf (& cmd .args , "--window=%s" , window );
256
- if (window_memory )
257
- argv_array_pushf (& cmd .args , "--window-memory=%s" , window_memory );
258
- if (depth )
259
- argv_array_pushf (& cmd .args , "--depth=%s" , depth );
260
- if (threads )
261
- argv_array_pushf (& cmd .args , "--threads=%s" , threads );
262
- if (max_pack_size )
263
- argv_array_pushf (& cmd .args , "--max-pack-size=%s" , max_pack_size );
264
- if (no_reuse_delta )
265
- argv_array_pushf (& cmd .args , "--no-reuse-delta" );
266
- if (no_reuse_object )
267
- argv_array_pushf (& cmd .args , "--no-reuse-object" );
268
290
if (write_bitmaps )
269
291
argv_array_push (& cmd .args , "--write-bitmap-index" );
270
292
@@ -292,17 +314,6 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
292
314
argv_array_push (& cmd .args , "--incremental" );
293
315
}
294
316
295
- if (local )
296
- argv_array_push (& cmd .args , "--local" );
297
- if (quiet )
298
- argv_array_push (& cmd .args , "--quiet" );
299
- if (delta_base_offset )
300
- argv_array_push (& cmd .args , "--delta-base-offset" );
301
-
302
- argv_array_push (& cmd .args , packtmp );
303
-
304
- cmd .git_cmd = 1 ;
305
- cmd .out = -1 ;
306
317
cmd .no_stdin = 1 ;
307
318
308
319
ret = start_command (& cmd );
@@ -320,7 +331,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
320
331
if (ret )
321
332
return ret ;
322
333
323
- if (!names .nr && !quiet )
334
+ if (!names .nr && !po_args . quiet )
324
335
printf ("Nothing new to pack.\n" );
325
336
326
337
/*
@@ -441,7 +452,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
441
452
if (!string_list_has_string (& names , sha1 ))
442
453
remove_redundant_pack (packdir , item -> string );
443
454
}
444
- if (!quiet && isatty (2 ))
455
+ if (!po_args . quiet && isatty (2 ))
445
456
opts |= PRUNE_PACKED_VERBOSE ;
446
457
prune_packed_objects (opts );
447
458
}
0 commit comments