repack: track the ODB source via existing_packs
Store the ODB source in the `existing_packs` struct and use that in place of the raw `repo->objects->sources` access within `cmd_repack()`. The source used is still assigned from the first source in the list, so there are no functional changes in this commit. The changes instead serve two purposes (one immediate, one not): - The incremental MIDX-based repacking machinery will need to know what source is being used to read the existing MIDX/chain (should one exist). - In the future, if "git repack" is taught how to operate on other object sources, this field will serve as the authoritative value for that source. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
May 19, 2026 at 11:57 UTC
f0ef2afb8be0aa37b80bc1cf1f1a9acfb208f00f
3 files changed
+5
-3
builtin/repack.c
+2
-3
@@ -417,7 +417,7 @@ int cmd_repack(int argc,
417
* midx_has_unknown_packs() will make the decision for
418
* us.
419
*/
420
- if (!get_multi_pack_index(repo->objects->sources))
420
+ if (!get_multi_pack_index(existing.source))
421
midx_must_contain_cruft = 1;
422
}
423
@@ -564,8 +564,7 @@ int cmd_repack(int argc,
564
unsigned flags = 0;
565
if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL, 0))
566
flags |= MIDX_WRITE_INCREMENTAL;
567
- write_midx_file(repo->objects->sources,
568
- NULL, NULL, flags);
567
+ write_midx_file(existing.source, NULL, NULL, flags);
568
}
569
570
cleanup:
repack.c
+2
@@ -154,6 +154,8 @@ void existing_packs_collect(struct existing_packs *existing,
154
string_list_append(&existing->non_kept_packs, buf.buf);
155
}
156
157
+ existing->source = existing->repo->objects->sources;
158
+
159
string_list_sort(&existing->kept_packs);
160
string_list_sort(&existing->non_kept_packs);
161
string_list_sort(&existing->cruft_packs);
repack.h
+1
@@ -56,6 +56,7 @@ struct packed_git;
56
57
struct existing_packs {
58
struct repository *repo;
59
+ struct odb_source *source;
60
struct string_list kept_packs;
61
struct string_list non_kept_packs;
62
struct string_list cruft_packs;