]> git.ipfire.org Git - thirdparty/git.git/commitdiff
repack: remove 'remove_redundant_pack' from the builtin
authorTaylor Blau <me@ttaylorr.com>
Wed, 15 Oct 2025 22:28:07 +0000 (18:28 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 16 Oct 2025 17:08:54 +0000 (10:08 -0700)
Extract "remove_redundant_pack()" as generic repack-related
functionality by moving its implementation to the repack.[ch]
compilation unit.

This is a prerequisite to moving the "existing_packs" API, which is one
of the callers of this function. (The remaining caller in the pack
geometry code will eventually move to its own compilation unit as well,
and will likewise rely on this function.)

While moving it over, prefix the function name with "repack_" to
indicate that it belongs to the repack-subsystem.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/repack.c
repack.c
repack.h

index f82e6c393073a037d2764c68e9be6ffe5934372f..31137cf711265a84e6b302103c71d05dcaa432f7 100644 (file)
@@ -208,20 +208,6 @@ static void existing_packs_mark_for_deletion(struct existing_packs *existing,
                                           &existing->cruft_packs);
 }
 
-static void remove_redundant_pack(struct repository *repo,
-                                 const char *dir_name, const char *base_name)
-{
-       struct strbuf buf = STRBUF_INIT;
-       struct odb_source *source = repo->objects->sources;
-       struct multi_pack_index *m = get_multi_pack_index(source);
-       strbuf_addf(&buf, "%s.pack", base_name);
-       if (m && source->local && midx_contains_pack(m, buf.buf))
-               clear_midx_file(repo);
-       strbuf_insertf(&buf, 0, "%s/", dir_name);
-       unlink_pack_path(buf.buf, 1);
-       strbuf_release(&buf);
-}
-
 static void remove_redundant_packs_1(struct repository *repo,
                                     struct string_list *packs)
 {
@@ -229,7 +215,7 @@ static void remove_redundant_packs_1(struct repository *repo,
        for_each_string_list_item(item, packs) {
                if (!existing_pack_is_marked_for_deletion(item))
                        continue;
-               remove_redundant_pack(repo, packdir, item->string);
+               repack_remove_redundant_pack(repo, packdir, item->string);
        }
 }
 
@@ -652,7 +638,7 @@ static void geometry_remove_redundant_packs(struct pack_geometry *geometry,
                    (string_list_has_string(&existing->kept_packs, buf.buf)))
                        continue;
 
-               remove_redundant_pack(existing->repo, packdir, buf.buf);
+               repack_remove_redundant_pack(existing->repo, packdir, buf.buf);
        }
 
        strbuf_release(&buf);
index 91b6e1cc09cacdc80302af635948dd28ecb2327a..3aaa351b5b5486400011cc024d72fd6a2fadb555 100644 (file)
--- a/repack.c
+++ b/repack.c
@@ -1,5 +1,9 @@
 #include "git-compat-util.h"
+#include "midx.h"
+#include "odb.h"
+#include "packfile.h"
 #include "repack.h"
+#include "repository.h"
 #include "run-command.h"
 
 void prepare_pack_objects(struct child_process *cmd,
@@ -44,3 +48,17 @@ void pack_objects_args_release(struct pack_objects_args *args)
        free(args->threads);
        list_objects_filter_release(&args->filter_options);
 }
+
+void repack_remove_redundant_pack(struct repository *repo, const char *dir_name,
+                                 const char *base_name)
+{
+       struct strbuf buf = STRBUF_INIT;
+       struct odb_source *source = repo->objects->sources;
+       struct multi_pack_index *m = get_multi_pack_index(source);
+       strbuf_addf(&buf, "%s.pack", base_name);
+       if (m && source->local && midx_contains_pack(m, buf.buf))
+               clear_midx_file(repo);
+       strbuf_insertf(&buf, 0, "%s/", dir_name);
+       unlink_pack_path(buf.buf, 1);
+       strbuf_release(&buf);
+}
index 3f7ec207355bf7b6cb9339bd44d03538c41096e1..a62bfa2ff970c8e2d5c41b52c989633896f8ca2b 100644 (file)
--- a/repack.h
+++ b/repack.h
@@ -28,4 +28,7 @@ void prepare_pack_objects(struct child_process *cmd,
                          const char *out);
 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);
+
 #endif /* REPACK_H */