diff options
author | Patrick Steinhardt <ps@pks.im> | 2023-04-14 08:01:49 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-04-14 10:27:51 -0700 |
commit | 732194b5f2ff50fc536b28c3d5a3e43e0110419b (patch) | |
tree | b769cc1b4008718d64d7823126fb6f2f4cc0ef0b /builtin | |
parent | b7b8f048f567f1dde24874e82227fbf2c64a1aed (diff) | |
download | git-732194b5f2ff50fc536b28c3d5a3e43e0110419b.tar.gz |
pack-objects: fix error when packing same pack twice
When passed the same packfile twice via `--stdin-packs` we return an
error that the packfile supposedly was not found. This is because when
reading packs into the list of included or excluded packfiles, we will
happily re-add packfiles even if they are part of the lists already. And
while the list can now contain duplicates, we will only set the `util`
pointer of the first list entry to the `packed_git` structure. We notice
that at a later point when checking that all list entries have their
`util` pointer set and die with an error.
While this is kind of a nonsensical request, this scenario can be hit
when doing geometric repacks. When a repository is connected to an
alternate object directory and both have the exact same packfile then
both would get added to the geometric sequence. And when we then decide
to perform the repack, we will invoke git-pack-objects(1) with the same
packfile twice.
Fix this bug by removing any duplicates from both the included and
excluded packs.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/pack-objects.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 74a167a180..c97ae1b6d0 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -3344,7 +3344,9 @@ static void read_packs_list_from_stdin(void) } string_list_sort(&include_packs); + string_list_remove_duplicates(&include_packs, 0); string_list_sort(&exclude_packs); + string_list_remove_duplicates(&exclude_packs, 0); for (p = get_all_packs(the_repository); p; p = p->next) { const char *pack_name = pack_basename(p); |