@matheusbsbs / matheus-bagliano / commits / e11d86de13
Fork 0

midx: teach "git multi-pack-index repack" honor "git repack" configurations

When the "repack" subcommand of "git multi-pack-index" command creates new packfile(s), it does not call the "git repack" command but instead directly calls the "git pack-objects" command, and the configuration variables meant for the "git repack" command, like "repack.usedaeltabaseoffset", are ignored. Check the configuration variables used by "git repack" ourselves in "git multi-index-pack" and pass the corresponding options to underlying "git pack-objects". Note that `repack.writeBitmaps` configuration is ignored, as the pack bitmap facility is useful only with a single packfile. Signed-off-by: Son Luong Ngoc <sluongng@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Son Luong Ngoc committed May 10, 2020 at 16:07 UTC e11d86de13988e986550043b307b1f9a52324458
1 file changed +16
midx.c
+16
@@ -1370,6 +1370,14 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
1370 struct strbuf base_name = STRBUF_INIT;
1371 struct multi_pack_index *m = load_multi_pack_index(object_dir, 1);
1372
1373 + /*
1374 + * When updating the default for these configuration
1375 + * variables in builtin/repack.c, these must be adjusted
1376 + * to match.
1377 + */
1378 + int delta_base_offset = 1;
1379 + int use_delta_islands = 0;
1380 +
1381 if (!m)
1382 return 0;
1383
@@ -1381,12 +1389,20 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
1389 } else if (fill_included_packs_all(m, include_pack))
1390 goto cleanup;
1391
1392 + repo_config_get_bool(r, "repack.usedeltabaseoffset", &delta_base_offset);
1393 + repo_config_get_bool(r, "repack.usedeltaislands", &use_delta_islands);
1394 +
1395 argv_array_push(&cmd.args, "pack-objects");
1396
1397 strbuf_addstr(&base_name, object_dir);
1398 strbuf_addstr(&base_name, "/pack/pack");
1399 argv_array_push(&cmd.args, base_name.buf);
1400
1401 + if (delta_base_offset)
1402 + argv_array_push(&cmd.args, "--delta-base-offset");
1403 + if (use_delta_islands)
1404 + argv_array_push(&cmd.args, "--delta-islands");
1405 +
1406 if (flags & MIDX_PROGRESS)
1407 argv_array_push(&cmd.args, "--progress");
1408 else