diff options
author | Patrick Steinhardt <ps@pks.im> | 2023-04-14 09:01:40 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-04-14 20:27:51 +0300 |
commit | 51861340f8d7f76a99e0d7265f4417b0a9a6871c (patch) | |
tree | 764b70c21b4233e029f532f1046b42695b718215 /t/t7703-repack-geometric.sh | |
parent | 3d74a2337c679839265efa16b2bca2a9b7795a00 (diff) |
repack: fix generating multi-pack-index with only non-local packs
When writing the multi-pack-index with geometric repacking we will add
all packfiles to the index that are part of the geometric sequence. This
can potentially also include packfiles borrowed from an alternate object
directory. But given that a multi-pack-index can only ever include packs
that are part of the main object database this does not make much sense
whatsoever.
In the edge case where all packfiles are contained in the alternate
object database and the local repository has none itself this bug can
cause us to invoke git-multi-pack-index(1) with only non-local packfiles
that it ultimately cannot find. This causes it to return an error and
thus causes the geometric repack to fail.
Fix the code to skip non-local packfiles.
Co-authored-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7703-repack-geometric.sh')
-rwxr-xr-x | t/t7703-repack-geometric.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/t/t7703-repack-geometric.sh b/t/t7703-repack-geometric.sh index 4abc7d4c55..9dd002437f 100755 --- a/t/t7703-repack-geometric.sh +++ b/t/t7703-repack-geometric.sh @@ -313,4 +313,27 @@ test_expect_success '--geometric --write-midx with packfiles in main and alterna test_cmp expect actual ' +test_expect_success '--geometric --with-midx with no local objects' ' + test_when_finished "rm -fr shared member" && + + # Create a repository with a single packfile that acts as alternate + # object database. + git init shared && + test_commit -C shared "shared-objects" && + git -C shared repack -ad && + + # Create a second repository linked to the first one and perform a + # geometric repack on it. + git clone --shared shared member && + git -C member repack --geometric 2 --write-midx 2>err && + test_must_be_empty err && + + # Assert that we wrote neither a new packfile nor a multi-pack-index. + # We should not have a packfile because the single packfile in the + # alternate object database does not invalidate the geometric sequence. + # And we should not have a multi-pack-index because these only index + # local packfiles, and there are none. + test_dir_is_empty member/$packdir +' + test_done |