From: Siddharth Shrimali <r.siddharth.shrimali@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, christian.couder@gmail.com,
siddharthasthana31@gmail.com, ttaylorr@openai.com, ps@pks.im,
johannes.schindelin@gmx.de, l.s.r@web.de,
r.siddharth.shrimali@gmail.com
Subject: [GSoC PATCH v5 5/6] builtin/repack: actually drop filtered promisor blobs
Date: Fri, 14 Aug 2026 01:38:29 +0530 [thread overview]
Message-ID: <20260813200830.84348-6-r.siddharth.shrimali@gmail.com> (raw)
In-Reply-To: <20260813200830.84348-1-r.siddharth.shrimali@gmail.com>
Make --drop-filtered remove the enumerated promisor blobs instead of
only listing them.
The drop set is computed before repack_promisor_objects() runs, and on
a real run it is passed in so the rebuilt promisor pack omits those
blobs. --drop-filtered implies -d so the old promisor packs, which
still contain the dropped blobs, are removed. Without this the blobs
would survive in the redundant packs. The existing repack machinery
performs the write-before-delete and fsync, so the drop is crash-safe.
The dropped blobs become absent locally but remain recoverable from the
promisor remote, so a later access lazy-fetches them back
transparently. --dry-run keeps its previous behavior, i.e. it lists the
candidates and changes nothing.
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Siddharth Asthana <siddharthasthana31@gmail.com>
Signed-off-by: Siddharth Shrimali <r.siddharth.shrimali@gmail.com>
---
Documentation/git-repack.adoc | 28 ++++++++++++++++++++++++++++
builtin/repack.c | 14 ++++++++++----
t/t7706-repack-drop-filtered.sh | 12 ++++++++++++
3 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-repack.adoc b/Documentation/git-repack.adoc
index 72c42015e2..130249a139 100644
--- a/Documentation/git-repack.adoc
+++ b/Documentation/git-repack.adoc
@@ -12,6 +12,7 @@ SYNOPSIS
'git repack' [-a] [-A] [-d] [-f] [-F] [-l] [-n] [-q] [-b] [-m]
[--window=<n>] [--depth=<n>] [--threads=<n>] [--keep-pack=<pack-name>]
[--write-midx[=<mode>]] [--name-hash-version=<n>] [--path-walk]
+ [--filter=<filter-spec>] [--drop-filtered [--dry-run]]
DESCRIPTION
-----------
@@ -182,6 +183,33 @@ depth is 4095.
`objects` and `objects/info/alternates` sections of
linkgit:gitrepository-layout[5].
+--drop-filtered::
+ Delete the local objects that match the `--filter` specification
+ instead of keeping them in a separate packfile, reclaiming the
+ disk space they occupy. This is intended for partial clones,
+ where the filtered objects are promisor objects that remain
+ recoverable from the promisor remote and are lazily re-fetched
+ on demand when they are next needed.
++
+Only large blobs are supported for now, so `--filter=blob:limit=<n>`
+is currently the only accepted filter. Because dropped objects must be
+recoverable, this option requires a promisor remote to be configured
+and refuses to run otherwise.
++
+This option requires `-a`, and implies `-d`: the objects are dropped by
+rebuilding the promisor pack without them and then removing the now
+redundant old packs, so the redundant packs must be deleted for the
+space to actually be reclaimed. It is incompatible with `--filter-to`
+and with bitmap writing (`-b`/`--write-bitmap-index`), since filtering
+breaks the single-pack closure that bitmaps require. A bitmap setting
+coming from configuration is silently disabled for the duration of the
+command.
+
+--dry-run::
+ Only meaningful with `--drop-filtered`. List the objects that
+ would be dropped, one object ID per line, without rebuilding any
+ pack or deleting anything.
+
-b::
--write-bitmap-index::
Write a reachability bitmap index as part of the repack. This
diff --git a/builtin/repack.c b/builtin/repack.c
index 3633b17ce8..a5f13fdd87 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -287,9 +287,6 @@ int cmd_repack(int argc,
die(_("--dry-run only takes effect with --drop-filtered"));
if (drop_filtered) {
- if (!dry_run)
- die(_("--drop-filtered does not work without --dry-run yet"));
-
if (!po_args.filter_options.choice)
die(_("--drop-filtered requires --filter"));
@@ -322,6 +319,14 @@ int cmd_repack(int argc,
write_bitmaps = 0;
+ /*
+ * Dropping objects means rebuilding the promisor packs
+ * without them and then removing the old packs, so the
+ * redundant packs must be deleted. Imply -d on a real run.
+ */
+ if (!dry_run)
+ delete_redundant = 1;
+
ret = enumerate_promisor_blobs(repo, &po_args.filter_options, &drop_oids);
if (ret)
@@ -447,7 +452,8 @@ 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, NULL);
+ repack_promisor_objects(repo, &po_args, &names, packtmp,
+ (drop_filtered && !dry_run) ? &drop_oids : NULL);
if (existing_packs_has_non_kept(&existing) &&
delete_redundant &&
diff --git a/t/t7706-repack-drop-filtered.sh b/t/t7706-repack-drop-filtered.sh
index 6352f1fdce..80c695742f 100755
--- a/t/t7706-repack-drop-filtered.sh
+++ b/t/t7706-repack-drop-filtered.sh
@@ -135,4 +135,16 @@ test_expect_success '--dry-run does not remove the filtered objects' '
git -C repo cat-file -e "$BIG"
'
+test_expect_success '--drop-filtered removes the promisor blob locally' '
+ BIG=$(cat big_oid) &&
+ SMALL=$(cat small_oid) &&
+
+ git -C repo -c repack.writeBitmaps=false \
+ repack --drop-filtered --filter=blob:limit=1k -a &&
+
+ git -C repo cat-file --batch-all-objects --batch-check="%(objectname)" >present &&
+ test_grep ! "$BIG" present &&
+ test_grep "$SMALL" present
+'
+
test_done
--
2.54.0
next prev parent reply other threads:[~2026-08-13 20:09 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 13:28 [RFC PATCH 0/7] repack: add --drop-filtered to reclaim space in partial clones Siddharth Shrimali
2026-07-16 13:28 ` [RFC PATCH 1/7] builtin/repack.c: add --drop-filtered and --dry-run options Siddharth Shrimali
2026-07-16 21:08 ` Junio C Hamano
2026-07-17 18:00 ` Siddharth Shrimali
2026-07-23 19:31 ` Siddharth Asthana
2026-07-18 12:30 ` Christian Couder
2026-07-20 10:19 ` Siddharth Shrimali
2026-07-16 13:28 ` [RFC PATCH 2/7] list-objects-filter: add list_objects_filter__filter_oidset() Siddharth Shrimali
2026-07-16 13:28 ` [RFC PATCH 3/7] repack-promisor: allow excluding objects from the rebuilt promisor pack Siddharth Shrimali
2026-07-16 13:28 ` [RFC PATCH 4/7] builtin/repack: enumerate promisor blobs for --drop-filtered Siddharth Shrimali
2026-07-16 13:28 ` [RFC PATCH 5/7] t7706: test --drop-filtered enumeration and validation Siddharth Shrimali
2026-07-16 13:28 ` [RFC PATCH 6/7] builtin/repack: actually drop filtered promisor blobs Siddharth Shrimali
2026-07-23 19:42 ` Siddharth Asthana
2026-07-25 19:30 ` Siddharth Shrimali
2026-07-16 13:28 ` [RFC PATCH 7/7] repack-promisor: record dropped objects in a drop log Siddharth Shrimali
2026-07-23 19:41 ` Siddharth Asthana
2026-07-25 19:35 ` Siddharth Shrimali
2026-07-23 19:26 ` [RFC PATCH 0/7] repack: add --drop-filtered to reclaim space in partial clones Siddharth Asthana
2026-07-25 19:23 ` Siddharth Shrimali
2026-07-30 17:41 ` [GSoC PATCH v2 " Siddharth Shrimali
2026-07-30 17:41 ` [GSoC PATCH v2 1/7] builtin/repack.c: add --drop-filtered and --dry-run options Siddharth Shrimali
2026-08-04 21:13 ` Siddharth Asthana
2026-07-30 17:41 ` [GSoC PATCH v2 2/7] list-objects-filter: add list_objects_filter__filter_oidset() Siddharth Shrimali
2026-07-30 17:41 ` [GSoC PATCH v2 3/7] repack-promisor: allow excluding objects from the rebuilt promisor pack Siddharth Shrimali
2026-07-30 17:41 ` [GSoC PATCH v2 4/7] builtin/repack: enumerate promisor blobs for --drop-filtered Siddharth Shrimali
2026-07-30 17:41 ` [GSoC PATCH v2 5/7] builtin/repack: actually drop filtered promisor blobs Siddharth Shrimali
2026-07-30 17:41 ` [GSoC PATCH v2 6/7] builtin/repack: add safety guards for --drop-filtered Siddharth Shrimali
2026-08-04 21:13 ` Siddharth Asthana
2026-07-30 17:41 ` [GSoC PATCH v2 7/7] Documentation/git-repack: document --drop-filtered and --dry-run Siddharth Shrimali
2026-07-31 15:33 ` [GSoC PATCH v2 0/7] repack: add --drop-filtered to reclaim space in partial clones Junio C Hamano
2026-08-01 18:19 ` Siddharth Shrimali
2026-08-02 2:18 ` Junio C Hamano
2026-08-02 11:28 ` Siddharth Shrimali
2026-08-04 21:12 ` Siddharth Asthana
2026-08-06 11:21 ` [GSoC PATCH v3 " Siddharth Shrimali
2026-08-06 11:21 ` [GSoC PATCH v3 1/7] builtin/repack.c: add --drop-filtered and --dry-run options Siddharth Shrimali
2026-08-06 11:21 ` [GSoC PATCH v3 2/7] list-objects-filter: add list_objects_filter__filter_oidset() Siddharth Shrimali
2026-08-06 11:21 ` [GSoC PATCH v3 3/7] repack-promisor: allow excluding objects from the rebuilt promisor pack Siddharth Shrimali
2026-08-06 11:21 ` [GSoC PATCH v3 4/7] builtin/repack: enumerate promisor blobs for --drop-filtered Siddharth Shrimali
2026-08-06 11:22 ` [GSoC PATCH v3 5/7] builtin/repack: actually drop filtered promisor blobs Siddharth Shrimali
2026-08-06 11:22 ` [GSoC PATCH v3 6/7] builtin/repack: add guards for --drop-filtered Siddharth Shrimali
2026-08-06 11:22 ` [GSoC PATCH v3 7/7] Documentation/git-repack: document --drop-filtered and --dry-run Siddharth Shrimali
2026-08-06 21:34 ` [GSoC PATCH v3 0/7] repack: add --drop-filtered to reclaim space in partial clones Junio C Hamano
2026-08-06 22:19 ` Junio C Hamano
2026-08-07 9:06 ` Siddharth Shrimali
2026-08-07 20:52 ` Junio C Hamano
2026-08-08 20:07 ` Siddharth Shrimali
2026-08-10 17:40 ` [GSoC PATCH v4 " Siddharth Shrimali
2026-08-10 17:40 ` [GSoC PATCH v4 1/7] builtin/repack.c: add --drop-filtered and --dry-run options Siddharth Shrimali
2026-08-10 17:40 ` [GSoC PATCH v4 2/7] list-objects-filter: add list_objects_filter__filter_oidset() Siddharth Shrimali
2026-08-12 17:09 ` Christian Couder
2026-08-12 18:04 ` Junio C Hamano
2026-08-12 19:22 ` Siddharth Shrimali
2026-08-10 17:40 ` [GSoC PATCH v4 3/7] repack-promisor: allow excluding objects from the rebuilt promisor pack Siddharth Shrimali
2026-08-10 17:40 ` [GSoC PATCH v4 4/7] builtin/repack: enumerate promisor blobs for --drop-filtered Siddharth Shrimali
2026-08-12 17:21 ` Christian Couder
2026-08-10 17:40 ` [GSoC PATCH v4 5/7] builtin/repack: actually drop filtered promisor blobs Siddharth Shrimali
2026-08-10 17:40 ` [GSoC PATCH v4 6/7] builtin/repack: add guards for --drop-filtered Siddharth Shrimali
2026-08-12 17:41 ` Christian Couder
2026-08-12 19:45 ` Siddharth Shrimali
2026-08-10 17:40 ` [GSoC PATCH v4 7/7] Documentation/git-repack: document --drop-filtered and --dry-run Siddharth Shrimali
2026-08-12 17:51 ` Christian Couder
2026-08-11 17:50 ` [GSoC PATCH v4 0/7] repack: add --drop-filtered to reclaim space in partial clones Junio C Hamano
2026-08-12 7:35 ` Siddharth Shrimali
2026-08-13 20:08 ` [GSoC PATCH v5 0/6] " Siddharth Shrimali
2026-08-13 20:08 ` [GSoC PATCH v5 1/6] builtin/repack: add --drop-filtered and --dry-run options Siddharth Shrimali
2026-08-13 20:08 ` [GSoC PATCH v5 2/6] list-objects-filter: add list_objects_filter__filter_oidset() Siddharth Shrimali
2026-08-13 20:08 ` [GSoC PATCH v5 3/6] repack-promisor: allow excluding objects from the rebuilt promisor pack Siddharth Shrimali
2026-08-13 20:08 ` [GSoC PATCH v5 4/6] builtin/repack: enumerate promisor blobs for --drop-filtered Siddharth Shrimali
2026-08-13 20:08 ` Siddharth Shrimali [this message]
2026-08-13 20:08 ` [GSoC PATCH v5 6/6] builtin/repack: add guards " Siddharth Shrimali
2026-09-03 21:52 ` Samuel Bronson
2026-09-04 10:51 ` Siddharth Shrimali
2026-08-14 17:12 ` [GSoC PATCH v5 0/6] repack: add --drop-filtered to reclaim space in partial clones Christian Couder
2026-08-14 17:17 ` Junio C Hamano
2026-08-14 19:32 ` Siddharth Shrimali
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260813200830.84348-6-r.siddharth.shrimali@gmail.com \
--to=r.siddharth.shrimali@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
--cc=l.s.r@web.de \
--cc=ps@pks.im \
--cc=siddharthasthana31@gmail.com \
--cc=ttaylorr@openai.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.