@@ -65,12 +65,20 @@ static int parse_object_dir(const struct option *opt, const char *arg,
65
65
char * * value = opt -> value ;
66
66
free (* value );
67
67
if (unset )
68
- * value = xstrdup (repo_get_object_directory ( the_repository ) );
68
+ * value = xstrdup (the_repository -> objects -> sources -> path );
69
69
else
70
70
* value = real_pathdup (arg , 1 );
71
71
return 0 ;
72
72
}
73
73
74
+ static struct odb_source * handle_object_dir_option (struct repository * repo )
75
+ {
76
+ struct odb_source * source = odb_find_source (repo -> objects , opts .object_dir );
77
+ if (!source )
78
+ source = odb_add_to_alternates_memory (repo -> objects , opts .object_dir );
79
+ return source ;
80
+ }
81
+
74
82
static struct option common_opts [] = {
75
83
OPT_CALLBACK (0 , "object-dir" , & opts .object_dir ,
76
84
N_ ("directory" ),
@@ -140,6 +148,7 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
140
148
N_ ("refs snapshot for selecting bitmap commits" )),
141
149
OPT_END (),
142
150
};
151
+ struct odb_source * source ;
143
152
int ret ;
144
153
145
154
opts .flags |= MIDX_WRITE_BITMAP_HASH_CACHE ;
@@ -158,6 +167,7 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
158
167
if (argc )
159
168
usage_with_options (builtin_multi_pack_index_write_usage ,
160
169
options );
170
+ source = handle_object_dir_option (repo );
161
171
162
172
FREE_AND_NULL (options );
163
173
@@ -166,7 +176,7 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
166
176
167
177
read_packs_from_stdin (& packs );
168
178
169
- ret = write_midx_file_only (repo , opts . object_dir , & packs ,
179
+ ret = write_midx_file_only (source , & packs ,
170
180
opts .preferred_pack ,
171
181
opts .refs_snapshot , opts .flags );
172
182
@@ -177,7 +187,7 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
177
187
178
188
}
179
189
180
- ret = write_midx_file (repo , opts . object_dir , opts .preferred_pack ,
190
+ ret = write_midx_file (source , opts .preferred_pack ,
181
191
opts .refs_snapshot , opts .flags );
182
192
183
193
free (opts .refs_snapshot );
@@ -194,6 +204,8 @@ static int cmd_multi_pack_index_verify(int argc, const char **argv,
194
204
N_ ("force progress reporting" ), MIDX_PROGRESS ),
195
205
OPT_END (),
196
206
};
207
+ struct odb_source * source ;
208
+
197
209
options = add_common_options (builtin_multi_pack_index_verify_options );
198
210
199
211
trace2_cmd_mode (argv [0 ]);
@@ -206,10 +218,11 @@ static int cmd_multi_pack_index_verify(int argc, const char **argv,
206
218
if (argc )
207
219
usage_with_options (builtin_multi_pack_index_verify_usage ,
208
220
options );
221
+ source = handle_object_dir_option (the_repository );
209
222
210
223
FREE_AND_NULL (options );
211
224
212
- return verify_midx_file (the_repository , opts . object_dir , opts .flags );
225
+ return verify_midx_file (source , opts .flags );
213
226
}
214
227
215
228
static int cmd_multi_pack_index_expire (int argc , const char * * argv ,
@@ -222,6 +235,8 @@ static int cmd_multi_pack_index_expire(int argc, const char **argv,
222
235
N_ ("force progress reporting" ), MIDX_PROGRESS ),
223
236
OPT_END (),
224
237
};
238
+ struct odb_source * source ;
239
+
225
240
options = add_common_options (builtin_multi_pack_index_expire_options );
226
241
227
242
trace2_cmd_mode (argv [0 ]);
@@ -234,10 +249,11 @@ static int cmd_multi_pack_index_expire(int argc, const char **argv,
234
249
if (argc )
235
250
usage_with_options (builtin_multi_pack_index_expire_usage ,
236
251
options );
252
+ source = handle_object_dir_option (the_repository );
237
253
238
254
FREE_AND_NULL (options );
239
255
240
- return expire_midx_packs (the_repository , opts . object_dir , opts .flags );
256
+ return expire_midx_packs (source , opts .flags );
241
257
}
242
258
243
259
static int cmd_multi_pack_index_repack (int argc , const char * * argv ,
@@ -252,6 +268,7 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv,
252
268
N_ ("force progress reporting" ), MIDX_PROGRESS ),
253
269
OPT_END (),
254
270
};
271
+ struct odb_source * source ;
255
272
256
273
options = add_common_options (builtin_multi_pack_index_repack_options );
257
274
@@ -266,11 +283,11 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv,
266
283
if (argc )
267
284
usage_with_options (builtin_multi_pack_index_repack_usage ,
268
285
options );
286
+ source = handle_object_dir_option (the_repository );
269
287
270
288
FREE_AND_NULL (options );
271
289
272
- return midx_repack (the_repository , opts .object_dir ,
273
- (size_t )opts .batch_size , opts .flags );
290
+ return midx_repack (source , (size_t )opts .batch_size , opts .flags );
274
291
}
275
292
276
293
int cmd_multi_pack_index (int argc ,
0 commit comments