[GSoC PATCH v2 3/7] repack-promisor: allow excluding objects from the rebuilt promisor pack
Siddharth Shrimali <[email protected]> Thu, 30 Jul 2026 23:11:49 +0530
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <[email protected]> |
Add a to_drop oidset parameter to repack_promisor_objects(). When it is non-NULL, write_oid() omits those objects from the rebuilt promisor pack. This is the mechanism --drop-filtered will use to remove promisor blobs, i.e. rebuild the promisor pack without them. All existing callers pass NULL, so behavior is unchanged. Mentored-by: Christian Couder <[email protected]> Mentored-by: Siddharth Asthana <[email protected]> Signed-off-by: Siddharth Shrimali <[email protected]> --- builtin/repack.c | 2 +- repack-promisor.c | 15 ++++++++++++++- repack.h | 4 +++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/builtin/repack.c b/builtin/repack.c index 322b01cb3e..f25d189b07 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -425,7 +425,7 @@ int cmd_repack(int argc, strvec_push(&cmd.args, "--delta-islands"); if (pack_everything & ALL_INTO_ONE) { - repack_promisor_objects(repo, &po_args, &names, packtmp); + repack_promisor_objects(repo, &po_args, &names, packtmp, NULL); if (existing_packs_has_non_kept(&existing) && delete_redundant && diff --git a/repack-promisor.c b/repack-promisor.c index 90318ce150..fabfdc168a 100644 --- a/repack-promisor.c +++ b/repack-promisor.c @@ -6,10 +6,12 @@ #include "path.h" #include "repository.h" #include "run-command.h" +#include "oidset.h" struct write_oid_context { struct child_process *cmd; const struct git_hash_algo *algop; + const struct oidset *to_drop; }; /* @@ -23,6 +25,15 @@ static int write_oid(const struct object_id *oid, struct write_oid_context *ctx = data; struct child_process *cmd = ctx->cmd; + /* + * Objects in to_drop are being removed from the repository, so + * omit them from the rebuilt promisor pack. Each such object is a + * promisor object and therefore remains recoverable from the + * promisor remote. + */ + if (ctx->to_drop && oidset_contains(ctx->to_drop, oid)) + return 0; + if (cmd->in == -1) { if (start_command(cmd)) die(_("could not start pack-objects to repack promisor objects")); @@ -81,7 +92,8 @@ static void finish_repacking_promisor_objects(struct repository *repo, void repack_promisor_objects(struct repository *repo, const struct pack_objects_args *args, - struct string_list *names, const char *packtmp) + struct string_list *names, const char *packtmp, + const struct oidset *to_drop) { struct write_oid_context ctx; struct child_process cmd = CHILD_PROCESS_INIT; @@ -98,6 +110,7 @@ void repack_promisor_objects(struct repository *repo, */ ctx.cmd = &cmd; ctx.algop = repo->hash_algo; + ctx.to_drop = to_drop; odb_for_each_object(repo->objects, NULL, write_oid, &ctx, ODB_FOR_EACH_OBJECT_PROMISOR_ONLY); diff --git a/repack.h b/repack.h index f9fbc895f0..a5a3f7c6ba 100644 --- a/repack.h +++ b/repack.h @@ -3,6 +3,7 @@ #include "list-objects-filter-options.h" #include "string-list.h" +#include "oidset.h" struct pack_objects_args { char *window; @@ -100,7 +101,8 @@ void generated_pack_install(struct generated_pack *pack, const char *name, void repack_promisor_objects(struct repository *repo, const struct pack_objects_args *args, - struct string_list *names, const char *packtmp); + struct string_list *names, const char *packtmp, + const struct oidset *to_drop); struct pack_geometry { struct packed_git **pack; -- 2.54.0