aboutsummaryrefslogtreecommitdiff
path: root/repack.h
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2025-10-15 18:28:15 -0400
committerJunio C Hamano <gitster@pobox.com>2025-10-16 10:08:54 -0700
commit7d1f4425889ea7f663ca30dd1d63591e52a628f6 (patch)
treededbd2cd796206787cb34ec5d0afd3508d25864c /repack.h
parentdab24e4bcbd8499c9262da5e259212765b28b77c (diff)
downloadgit-7d1f4425889ea7f663ca30dd1d63591e52a628f6.tar.xz
repack: remove 'existing_packs' API from the builtin
The repack builtin defines an API for keeping track of which packs were found in the repository at the beginning of the repack operation. This is used to classify what state a pack was in (kept, non-kept, or cruft), and is also used to mark which packs to delete (or keep) at the end of a repack operation. Now that the prerequisite refactoring is complete, this API is isolated enough that it can be moved out to repack.[ch] and removed from the builtin entirely. As a result, some of its functions become static within repack.c, cleaning up the visible API. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'repack.h')
-rw-r--r--repack.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/repack.h b/repack.h
index a62bfa2ff9..19796e2243 100644
--- a/repack.h
+++ b/repack.h
@@ -2,6 +2,7 @@
#define REPACK_H
#include "list-objects-filter-options.h"
+#include "string-list.h"
struct pack_objects_args {
char *window;
@@ -31,4 +32,38 @@ void pack_objects_args_release(struct pack_objects_args *args);
void repack_remove_redundant_pack(struct repository *repo, const char *dir_name,
const char *base_name);
+struct repository;
+struct packed_git;
+
+struct existing_packs {
+ struct repository *repo;
+ struct string_list kept_packs;
+ struct string_list non_kept_packs;
+ struct string_list cruft_packs;
+};
+
+#define EXISTING_PACKS_INIT { \
+ .kept_packs = STRING_LIST_INIT_DUP, \
+ .non_kept_packs = STRING_LIST_INIT_DUP, \
+ .cruft_packs = STRING_LIST_INIT_DUP, \
+}
+
+/*
+ * Adds all packs hex strings (pack-$HASH) to either packs->non_kept
+ * or packs->kept based on whether each pack has a corresponding
+ * .keep file or not. Packs without a .keep file are not to be kept
+ * if we are going to pack everything into one file.
+ */
+void existing_packs_collect(struct existing_packs *existing,
+ const struct string_list *extra_keep);
+int existing_packs_has_non_kept(const struct existing_packs *existing);
+int existing_pack_is_marked_for_deletion(struct string_list_item *item);
+void existing_packs_retain_cruft(struct existing_packs *existing,
+ struct packed_git *cruft);
+void existing_packs_mark_for_deletion(struct existing_packs *existing,
+ struct string_list *names);
+void existing_packs_remove_redundant(struct existing_packs *existing,
+ const char *packdir);
+void existing_packs_release(struct existing_packs *existing);
+
#endif /* REPACK_H */