diff mbox series

[WIP,v2,4/4] repack: use new exclude promisor pack objects option

Message ID 20240823124354.12982-5-hanyang.tony@bytedance.com (mailing list archive)
State New
Headers show
Series revision: fix reachable objects being gc'ed in no blob clone repo | expand

Commit Message

Han Young Aug. 23, 2024, 12:43 p.m. UTC
use --exclude-promisor-pack-objects to pack objects in partial clone repo.
git repack will call git pack-objects twice on a partially cloned repo.
The first call to pack-objects combines all the objects in promisor packfiles,
and the second pack-objects command packs all reachable non-promisor objects
into a normal packfile. However 'objects in promisor packfiles' plus
'non-promisor objects' does not equal 'all the reachable objects in repo',
Since promisor objects also include objects referenced in promisor packfile.

--exclude-promisor-pack-objects only excludes objects in promisor packfiles,
this way we don't discard any reachable objects in git repack.
---
 builtin/pack-objects.c | 8 ++++----
 builtin/repack.c       | 2 +-
 list-objects.c         | 3 ++-
 3 files changed, 7 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index c481feadbf..a2b1aaa2e0 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -238,7 +238,7 @@  static enum {
 } write_bitmap_index;
 static uint16_t write_bitmap_options = BITMAP_OPT_HASH_CACHE;
 
-static int exclude_promisor_objects;
+static int exclude_promisor_pack_objects;
 
 static int use_delta_islands;
 
@@ -4391,7 +4391,7 @@  int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 		OPT_CALLBACK_F(0, "missing", NULL, N_("action"),
 		  N_("handling for missing objects"), PARSE_OPT_NONEG,
 		  option_parse_missing_action),
-		OPT_BOOL(0, "exclude-promisor-objects", &exclude_promisor_objects,
+		OPT_BOOL(0, "exclude-promisor-pack-objects", &exclude_promisor_pack_objects,
 			 N_("do not pack objects in promisor packfiles")),
 		OPT_BOOL(0, "delta-islands", &use_delta_islands,
 			 N_("respect islands during delta compression")),
@@ -4473,10 +4473,10 @@  int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 		strvec_push(&rp, "--unpacked");
 	}
 
-	if (exclude_promisor_objects) {
+	if (exclude_promisor_pack_objects) {
 		use_internal_rev_list = 1;
 		fetch_if_missing = 0;
-		strvec_push(&rp, "--exclude-promisor-objects");
+		strvec_push(&rp, "--exclude-promisor-pack-objects");
 	}
 	if (unpack_unreachable || keep_unreachable || pack_loose_unreachable)
 		use_internal_rev_list = 1;
diff --git a/builtin/repack.c b/builtin/repack.c
index 62cfa50c50..aafe7d30ce 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -1289,7 +1289,7 @@  int cmd_repack(int argc, const char **argv, const char *prefix)
 		strvec_push(&cmd.args, "--indexed-objects");
 	}
 	if (repo_has_promisor_remote(the_repository))
-		strvec_push(&cmd.args, "--exclude-promisor-objects");
+		strvec_push(&cmd.args, "--exclude-promisor-pack-objects");
 	if (!write_midx) {
 		if (write_bitmaps > 0)
 			strvec_push(&cmd.args, "--write-bitmap-index");
diff --git a/list-objects.c b/list-objects.c
index 985d008799..9b3ff0fe1d 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -178,7 +178,8 @@  static void process_tree(struct traversal_context *ctx,
 		 * requested.  This may cause the actual filter to report
 		 * an incomplete list of missing objects.
 		 */
-		if (revs->exclude_promisor_objects &&
+		if ((revs->exclude_promisor_objects ||
+		    revs->exclude_promisor_pack_objects) &&
 		    is_promisor_object(&obj->oid))
 			return;