Git development
 help / color / mirror / Atom feed
From: Samuel Bronson <naesten@gmail.com>
To: Siddharth Shrimali <r.siddharth.shrimali@gmail.com>
Cc: git@vger.kernel.org,  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
Subject: Re: [GSoC PATCH v5 6/6] builtin/repack: add guards for --drop-filtered
Date: Thu, 03 Sep 2026 17:52:06 -0400	[thread overview]
Message-ID: <s0vqzjavw8p.fsf@gmail.com> (raw)
In-Reply-To: <20260813200830.84348-7-r.siddharth.shrimali@gmail.com> (Siddharth Shrimali's message of "Fri, 14 Aug 2026 01:38:30 +0530")

[-- Attachment #1: Type: text/plain, Size: 2050 bytes --]

Siddharth Shrimali <r.siddharth.shrimali@gmail.com> writes:

> @@ -332,6 +361,29 @@ int cmd_repack(int argc,
>  		if (ret)
>  			goto cleanup;
>  
> +		/*
> +		 * Refuse to drop blobs that the current index references.
> +		 * Such a blob would only be lazily re-fetched by the next
> +		 * command that touches the worktree, so dropping it reclaims
> +		 * nothing. This guard just avoids that churn. Bare
> +		 * repositories have no index, so the check is skipped there.
> +		 */
> +		if (!is_bare_repository(repo) && oidset_size(&drop_oids)) {
> +			struct index_state *istate = repo->index;
> +			unsigned int i;
> +
> +			if (repo_read_index(repo) < 0)
> +				die(_("could not read the index"));
> +
> +			for (i = 0; i < istate->cache_nr; i++) {
> +				const struct cache_entry *ce = istate->cache[i];
> +
> +				if (oidset_contains(&drop_oids, &ce->oid))
> +					die(_("cannot drop '%s' (%s): it is referenced by the current index"),
> +						ce->name, oid_to_hex(&ce->oid));

The good news: I've tried this whole feature on a real repository and it
*seems* to work quite well on the whole.

I was able to greatly reduce the size of my llvm-project clone's object
databasev not originally cloned with --filter, using it.

The bad news: dying at this time is *not* convenient, especially after
we've finished that *entire* enumerate_promisor_blobs(), (which is kind
of slow for a step with no progress output, btw).

While I do want to keep the index blobs, I do *not* want to cancel the
whole operation over them.

The following seems much more convenient:

-- >8 --
Subject: [RFC] builtin/repack: just don't --drop-filtered index blobs

Instead of dying when we would drop a blob referenced by the index, just
... don't drop it. (Retain the explanatory message as a warning.)

This allows `git repack -a --filter=blob:limit=0 --drop-filtered` to
work in non-bare repositories that have non-trivial files around.

Not done:

  - Fixing the tests to match

  - Allowing `--filter=blob:none`

Signed-off-by: Samuel Bronson <naesten@gmail.com>


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: convenience.patch --]
[-- Type: text/x-patch, Size: 580 bytes --]

diff --git a/builtin/repack.c b/builtin/repack.c
index c4360382c1..ab4471f740 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -378,8 +378,8 @@ int cmd_repack(int argc,
 			for (i = 0; i < istate->cache_nr; i++) {
 				const struct cache_entry *ce = istate->cache[i];
 
-				if (oidset_contains(&drop_oids, &ce->oid))
-					die(_("cannot drop '%s' (%s): it is referenced by the current index"),
+				if (oidset_remove(&drop_oids, &ce->oid))
+					warning(_("cannot drop '%s' (%s): it is referenced by the current index"),
 						ce->name, oid_to_hex(&ce->oid));
 			}
 		}

  reply	other threads:[~2026-09-03 21:54 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         ` [GSoC PATCH v5 5/6] builtin/repack: actually drop filtered promisor blobs Siddharth Shrimali
2026-08-13 20:08         ` [GSoC PATCH v5 6/6] builtin/repack: add guards for --drop-filtered Siddharth Shrimali
2026-09-03 21:52           ` Samuel Bronson [this message]
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=s0vqzjavw8p.fsf@gmail.com \
    --to=naesten@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=r.siddharth.shrimali@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox