diff options
author | Taylor Blau <me@ttaylorr.com> | 2022-05-20 22:01:51 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-05-20 23:54:44 +0300 |
commit | 66731ff921a56cf3e7049fae614fcf7eec663bde (patch) | |
tree | c6be5489ef06484b1a08f0015fade4e48d7d3123 /t/t7703-repack-geometric.sh | |
parent | aab7bea14fee0f185b26413bf27a1cfefbe0114d (diff) |
builtin/repack.c: ensure that `names` is sorted
The previous patch demonstrates a scenario where the list of packs
written by `pack-objects` (and stored in the `names` string_list) is
out-of-order, and can thus cause us to delete packs we shouldn't.
This patch resolves that bug by ensuring that `names` is sorted in all
cases, not just when
delete_redundant && pack_everything & ALL_INTO_ONE
is true.
Because we did sort `names` in that case (which, prior to `--geometric`
repacks, was the only time we would actually delete packs, this is only
a bug for `--geometric` repacks.
It would be sufficient to only sort `names` when `delete_redundant` is
set to a non-zero value. But sorting a small list of strings is cheap,
and it is defensive against future calls to `string_list_has_string()`
on this list.
Co-discovered-by: Victoria Dye <vdye@github.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
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 | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/t/t7703-repack-geometric.sh b/t/t7703-repack-geometric.sh index 2cd1de7295..da87f8b2d8 100755 --- a/t/t7703-repack-geometric.sh +++ b/t/t7703-repack-geometric.sh @@ -231,7 +231,7 @@ test_expect_success '--geometric chooses largest MIDX preferred pack' ' ) ' -test_expect_failure '--geometric with pack.packSizeLimit' ' +test_expect_success '--geometric with pack.packSizeLimit' ' git init pack-rewrite && test_when_finished "rm -fr pack-rewrite" && ( |