Subject: [PATCH v2 0/4] When fetching from a promisor remote, repack local objects referenced

From: Jonathan Tan <[email-masked]>
Date: Fri, 1 Nov 2024 13:11:44 -0700

Thanks everyone for looking at it. Here's version 2.

Jonathan Tan (4):
  t0410: make test description clearer
  t0410: use from-scratch server
  t5300: move --window clamp test next to unclamped
  index-pack: repack local links into promisor packs

 Documentation/git-index-pack.txt |   5 ++
 builtin/index-pack.c             | 110 ++++++++++++++++++++++++++++++-
 builtin/pack-objects.c           |  28 ++++++++
 t/t0410-partial-clone.sh         |   6 +-
 t/t5300-pack-object.sh           |  10 +--
 t/t5616-partial-clone.sh         |  30 +++++++++
 6 files changed, 179 insertions(+), 10 deletions(-)

Range-diff against v1:
1:  b2c76c207d < -:  ---------- pack-objects: make variable non-static
2:  c220e77ccf = 1:  f405c9c9aa t0410: make test description clearer
3:  08750988e0 = 2:  ce9d5af42a t0410: use from-scratch server
4:  85fc3fa77e = 3:  1526a59e2d t5300: move --window clamp test next to unclamped
5:  5dd7fdc16d ! 4:  c51fac33fb index-pack: repack local links into promisor packs
    @@ builtin/index-pack.c: int cmd_index_pack(int argc,
      	 */
     
      ## builtin/pack-objects.c ##
    +@@ builtin/pack-objects.c: static enum {
    + static uint16_t write_bitmap_options = BITMAP_OPT_HASH_CACHE;
    + 
    + static int exclude_promisor_objects;
    ++static int exclude_promisor_objects_best_effort;
    + 
    + static int use_delta_islands;
    + 
     @@ builtin/pack-objects.c: static int option_parse_cruft_expiration(const struct option *opt UNUSED,
      	return 0;
      }
      
    -+static int should_include_obj(struct object *obj, void *data UNUSED)
    ++static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)
     +{
     +	struct object_info info = OBJECT_INFO_INIT;
     +	if (oid_object_info_extended(the_repository, &obj->oid, &info, 0))
    @@ builtin/pack-objects.c: static int option_parse_cruft_expiration(const struct op
     +	return info.whence != OI_PACKED || !info.u.packed.pack->pack_promisor;
     +}
     +
    -+static int should_include(struct commit *commit, void *data) {
    -+	return should_include_obj((struct object *) commit, data);
    ++static int is_not_in_promisor_pack(struct commit *commit, void *data) {
    ++	return is_not_in_promisor_pack_obj((struct object *) commit, data);
     +}
     +
      int cmd_pack_objects(int argc,
      		     const char **argv,
      		     const char *prefix,
    -@@ builtin/pack-objects.c: int cmd_pack_objects(int argc,
    - 	struct list_objects_filter_options filter_options =
    - 		LIST_OBJECTS_FILTER_INIT;
    - 	int exclude_promisor_objects = 0;
    -+	int exclude_promisor_objects_best_effort = 0;
    - 
    - 	struct option pack_objects_options[] = {
    - 		OPT_CALLBACK_F('q', "quiet", &progress, NULL,
     @@ builtin/pack-objects.c: int cmd_pack_objects(int argc,
      		  option_parse_missing_action),
      		OPT_BOOL(0, "exclude-promisor-objects", &exclude_promisor_objects,
    @@ builtin/pack-objects.c: int cmd_pack_objects(int argc,
      		repo_init_revisions(the_repository, &revs, NULL);
      		list_objects_filter_copy(&revs.filter, &filter_options);
     +		if (exclude_promisor_objects_best_effort) {
    -+			revs.include_check = should_include;
    -+			revs.include_check_obj = should_include_obj;
    ++			revs.include_check = is_not_in_promisor_pack;
    ++			revs.include_check_obj = is_not_in_promisor_pack_obj;
     +		}
      		get_object_list(&revs, rp.nr, rp.v);
      		release_revisions(&revs);
-- 
2.47.0.163.g1226f6d8fa-goog