@@ -85,17 +85,34 @@ static int repack_config(const char *var, const char *value,
85
85
run_update_server_info = git_config_bool (var , value );
86
86
return 0 ;
87
87
}
88
- if (!strcmp (var , "repack.cruftwindow" ))
88
+ if (!strcmp (var , "repack.cruftwindow" )) {
89
+ free (cruft_po_args -> window );
89
90
return git_config_string (& cruft_po_args -> window , var , value );
90
- if (!strcmp (var , "repack.cruftwindowmemory" ))
91
+ }
92
+ if (!strcmp (var , "repack.cruftwindowmemory" )) {
93
+ free (cruft_po_args -> window_memory );
91
94
return git_config_string (& cruft_po_args -> window_memory , var , value );
92
- if (!strcmp (var , "repack.cruftdepth" ))
95
+ }
96
+ if (!strcmp (var , "repack.cruftdepth" )) {
97
+ free (cruft_po_args -> depth );
93
98
return git_config_string (& cruft_po_args -> depth , var , value );
94
- if (!strcmp (var , "repack.cruftthreads" ))
99
+ }
100
+ if (!strcmp (var , "repack.cruftthreads" )) {
101
+ free (cruft_po_args -> threads );
95
102
return git_config_string (& cruft_po_args -> threads , var , value );
103
+ }
96
104
return git_default_config (var , value , ctx , cb );
97
105
}
98
106
107
+ static void pack_objects_args_release (struct pack_objects_args * args )
108
+ {
109
+ free (args -> window );
110
+ free (args -> window_memory );
111
+ free (args -> depth );
112
+ free (args -> threads );
113
+ list_objects_filter_release (& args -> filter_options );
114
+ }
115
+
99
116
struct existing_packs {
100
117
struct string_list kept_packs ;
101
118
struct string_list non_kept_packs ;
@@ -1152,12 +1169,16 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
1152
1169
const char * unpack_unreachable = NULL ;
1153
1170
int keep_unreachable = 0 ;
1154
1171
struct string_list keep_pack_list = STRING_LIST_INIT_NODUP ;
1155
- struct pack_objects_args po_args = {NULL };
1156
- struct pack_objects_args cruft_po_args = {NULL };
1172
+ struct pack_objects_args po_args = { 0 };
1173
+ struct pack_objects_args cruft_po_args = { 0 };
1157
1174
int write_midx = 0 ;
1158
1175
const char * cruft_expiration = NULL ;
1159
1176
const char * expire_to = NULL ;
1160
1177
const char * filter_to = NULL ;
1178
+ const char * opt_window = NULL ;
1179
+ const char * opt_window_memory = NULL ;
1180
+ const char * opt_depth = NULL ;
1181
+ const char * opt_threads = NULL ;
1161
1182
1162
1183
struct option builtin_repack_options [] = {
1163
1184
OPT_BIT ('a' , NULL , & pack_everything ,
@@ -1191,13 +1212,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
1191
1212
N_ ("with -A, do not loosen objects older than this" )),
1192
1213
OPT_BOOL ('k' , "keep-unreachable" , & keep_unreachable ,
1193
1214
N_ ("with -a, repack unreachable objects" )),
1194
- OPT_STRING (0 , "window" , & po_args . window , N_ ("n" ),
1215
+ OPT_STRING (0 , "window" , & opt_window , N_ ("n" ),
1195
1216
N_ ("size of the window used for delta compression" )),
1196
- OPT_STRING (0 , "window-memory" , & po_args . window_memory , N_ ("bytes" ),
1217
+ OPT_STRING (0 , "window-memory" , & opt_window_memory , N_ ("bytes" ),
1197
1218
N_ ("same as the above, but limit memory size instead of entries count" )),
1198
- OPT_STRING (0 , "depth" , & po_args . depth , N_ ("n" ),
1219
+ OPT_STRING (0 , "depth" , & opt_depth , N_ ("n" ),
1199
1220
N_ ("limits the maximum delta depth" )),
1200
- OPT_STRING (0 , "threads" , & po_args . threads , N_ ("n" ),
1221
+ OPT_STRING (0 , "threads" , & opt_threads , N_ ("n" ),
1201
1222
N_ ("limits the maximum number of threads" )),
1202
1223
OPT_MAGNITUDE (0 , "max-pack-size" , & po_args .max_pack_size ,
1203
1224
N_ ("maximum size of each packfile" )),
@@ -1224,6 +1245,11 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
1224
1245
argc = parse_options (argc , argv , prefix , builtin_repack_options ,
1225
1246
git_repack_usage , 0 );
1226
1247
1248
+ po_args .window = xstrdup_or_null (opt_window );
1249
+ po_args .window_memory = xstrdup_or_null (opt_window_memory );
1250
+ po_args .depth = xstrdup_or_null (opt_depth );
1251
+ po_args .threads = xstrdup_or_null (opt_threads );
1252
+
1227
1253
if (delete_redundant && repository_format_precious_objects )
1228
1254
die (_ ("cannot delete packs in a precious-objects repo" ));
1229
1255
@@ -1389,13 +1415,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
1389
1415
const char * pack_prefix = find_pack_prefix (packdir , packtmp );
1390
1416
1391
1417
if (!cruft_po_args .window )
1392
- cruft_po_args .window = po_args .window ;
1418
+ cruft_po_args .window = xstrdup_or_null ( po_args .window ) ;
1393
1419
if (!cruft_po_args .window_memory )
1394
- cruft_po_args .window_memory = po_args .window_memory ;
1420
+ cruft_po_args .window_memory = xstrdup_or_null ( po_args .window_memory ) ;
1395
1421
if (!cruft_po_args .depth )
1396
- cruft_po_args .depth = po_args .depth ;
1422
+ cruft_po_args .depth = xstrdup_or_null ( po_args .depth ) ;
1397
1423
if (!cruft_po_args .threads )
1398
- cruft_po_args .threads = po_args .threads ;
1424
+ cruft_po_args .threads = xstrdup_or_null ( po_args .threads ) ;
1399
1425
if (!cruft_po_args .max_pack_size )
1400
1426
cruft_po_args .max_pack_size = po_args .max_pack_size ;
1401
1427
@@ -1547,7 +1573,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
1547
1573
string_list_clear (& names , 1 );
1548
1574
existing_packs_release (& existing );
1549
1575
free_pack_geometry (& geometry );
1550
- list_objects_filter_release (& po_args .filter_options );
1576
+ pack_objects_args_release (& po_args );
1577
+ pack_objects_args_release (& cruft_po_args );
1551
1578
1552
1579
return ret ;
1553
1580
}
0 commit comments