1
0
mirror of https://github.com/git/git.git synced 2024-09-08 03:50:44 +02:00

Merge branch 'ds/midx-write-repack-fix'

Repacking a repository with multi-pack index started making stupid
pack selections in Git 2.45, which has been corrected.

* ds/midx-write-repack-fix:
  midx-write: revert use of --stdin-packs
  t5319: add failing test case for repack/expire
This commit is contained in:
Junio C Hamano 2024-07-23 16:54:33 -07:00
commit ec9d46588e
2 changed files with 64 additions and 9 deletions

View File

@ -1499,8 +1499,7 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
repo_config_get_bool(r, "repack.usedeltabaseoffset", &delta_base_offset);
repo_config_get_bool(r, "repack.usedeltaislands", &use_delta_islands);
strvec_pushl(&cmd.args, "pack-objects", "--stdin-packs", "--non-empty",
NULL);
strvec_push(&cmd.args, "pack-objects");
strvec_pushf(&cmd.args, "%s/pack/pack", object_dir);
@ -1524,15 +1523,16 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
}
cmd_in = xfdopen(cmd.in, "w");
for (i = 0; i < m->num_packs; i++) {
struct packed_git *p = m->packs[i];
if (!p)
for (i = 0; i < m->num_objects; i++) {
struct object_id oid;
uint32_t pack_int_id = nth_midxed_pack_int_id(m, i);
if (!include_pack[pack_int_id])
continue;
if (include_pack[i])
fprintf(cmd_in, "%s\n", pack_basename(p));
else
fprintf(cmd_in, "^%s\n", pack_basename(p));
nth_midxed_object_oid(&oid, m, i);
fprintf(cmd_in, "%s\n", oid_to_hex(&oid));
}
fclose(cmd_in);

View File

@ -1027,6 +1027,61 @@ test_expect_success 'repack --batch-size=<large> repacks everything' '
)
'
test_expect_success 'repack/expire loop' '
git init repack-expire &&
test_when_finished "rm -fr repack-expire" &&
(
cd repack-expire &&
test_commit_bulk 5 &&
# Create three overlapping pack-files
git rev-list --objects HEAD~3 >in-1 &&
git rev-list --objects HEAD~4..HEAD~2 >in-2 &&
git rev-list --objects HEAD~3..HEAD >in-3 &&
# Create disconnected blobs
obj1=$(git hash-object -w in-1) &&
obj2=$(git hash-object -w in-2) &&
obj3=$(git hash-object -w in-3) &&
echo $obj2 >>in-2 &&
echo $obj3 >>in-3 &&
for i in $(test_seq 3)
do
git pack-objects .git/objects/pack/test-$i <in-$i \
|| return 1
done &&
rm -fr .git/objects/pack/pack-* &&
git multi-pack-index write &&
for i in $(test_seq 3)
do
for file in $(ls .git/objects/pack/test-$i*)
do
test-tool chmtime =+$((3600*$i-25000)) $file || return 1
done || return 1
done &&
pack1=$(ls .git/objects/pack/test-1-*.pack) &&
pack2=$(ls .git/objects/pack/test-2-*.pack) &&
pack3=$(ls .git/objects/pack/test-3-*.pack) &&
# Prevent test-1 from being rewritten.
touch "${pack1%.pack}.keep" &&
# This repack-expire loop should repack all non-kept packs
# into a new pack and then delete the old packs.
git multi-pack-index repack &&
git multi-pack-index expire &&
test_path_is_missing $pack3 &&
test_path_is_missing $pack2
)
'
test_expect_success 'load reverse index when missing .idx, .pack' '
git init repo &&
test_when_finished "rm -fr repo" &&