aboutsummaryrefslogtreecommitdiff
path: root/repack.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2025-10-15 18:28:07 -0400
committerJunio C Hamano <gitster@pobox.com>2025-10-16 10:08:54 -0700
commitf905f49c68f9cf3aff93f0dcd065dd95345c21d5 (patch)
treeb50238bb6acc925e2364271bda4dfaa27962fd7f /repack.c
parenta0dcecb14613e5bdfdc06616271bffac9e1366e8 (diff)
downloadgit-f905f49c68f9cf3aff93f0dcd065dd95345c21d5.tar.xz
repack: remove 'remove_redundant_pack' from the builtin
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>
Diffstat (limited to 'repack.c')
-rw-r--r--repack.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/repack.c b/repack.c
index 91b6e1cc09..3aaa351b5b 100644
--- 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);
+}