]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jk/partial-clone-sparse-blob'
authorJunio C Hamano <gitster@pobox.com>
Mon, 7 Oct 2019 02:32:54 +0000 (11:32 +0900)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Oct 2019 02:32:54 +0000 (11:32 +0900)
The name of the blob object that stores the filter specification
for sparse cloning/fetching was interpreted in a wrong place in the
code, causing Git to abort.

* jk/partial-clone-sparse-blob:
  list-objects-filter: use empty string instead of NULL for sparse "base"
  list-objects-filter: give a more specific error sparse parsing error
  list-objects-filter: delay parsing of sparse oid
  t5616: test cloning/fetching with sparse:oid=<oid> filter

1  2 
list-objects-filter-options.c
list-objects-filter-options.h
list-objects-filter.c
t/t5616-partial-clone.sh

index 4d88bfe64ad230b4055a77b79432ae2db8af87f6,adbea552a0c1c2f4483049364baab48f5b428b28..256bcfbdfe666db068599baeb8aae4c09a3ac8fb
@@@ -315,15 -127,8 +305,15 @@@ const char *expand_list_objects_filter_
  void list_objects_filter_release(
        struct list_objects_filter_options *filter_options)
  {
 -      free(filter_options->filter_spec);
 +      size_t sub;
 +
 +      if (!filter_options)
 +              return;
 +      string_list_clear(&filter_options->filter_spec, /*free_util=*/0);
-       free(filter_options->sparse_oid_value);
+       free(filter_options->sparse_oid_name);
 +      for (sub = 0; sub < filter_options->sub_nr; sub++)
 +              list_objects_filter_release(&filter_options->sub[sub]);
 +      free(filter_options->sub);
        memset(filter_options, 0, sizeof(*filter_options));
  }
  
index b63c5ee1a368aa4d34cda8bbc41fce905692495b,20b9d1e587a74da0196d09ad0c8551e0c7280648..2ffb39222c49745f68134fe6e360ba8cc00f15cc
@@@ -41,23 -38,13 +41,23 @@@ struct list_objects_filter_options 
        unsigned int no_filter : 1;
  
        /*
 -       * Parsed values (fields) from within the filter-spec.  These are
 -       * choice-specific; not all values will be defined for any given
 -       * choice.
 +       * BEGIN choice-specific parsed values from within the filter-spec. Only
 +       * some values will be defined for any given choice.
         */
-       struct object_id *sparse_oid_value;
 +
+       char *sparse_oid_name;
        unsigned long blob_limit_value;
        unsigned long tree_exclude_depth;
 +
 +      /* LOFC_COMBINE values */
 +
 +      /* This array contains all the subfilters which this filter combines. */
 +      size_t sub_nr, sub_alloc;
 +      struct list_objects_filter_options *sub;
 +
 +      /*
 +       * END choice-specific parsed values.
 +       */
  };
  
  /* Normalized command line arguments */
index d624f1c898dbdb76c65525badb9b07062fbfb240,83c788e8b51602468d8d0bf69686641718f796a4..1e8d4e763da07377263086d252d1228004971383
@@@ -478,17 -456,28 +478,25 @@@ static void filter_sparse_free(void *fi
        free(d);
  }
  
 -static void *filter_sparse_oid__init(
 -      struct oidset *omitted,
 +static void filter_sparse_oid__init(
        struct list_objects_filter_options *filter_options,
 -      filter_object_fn *filter_fn,
 -      filter_free_fn *filter_free_fn)
 +      struct filter *filter)
  {
        struct filter_sparse_data *d = xcalloc(1, sizeof(*d));
-       if (add_patterns_from_blob_to_list(filter_options->sparse_oid_value,
-                                          NULL, 0, &d->pl) < 0)
-               die("could not load filter specification");
+       struct object_context oc;
+       struct object_id sparse_oid;
+       if (get_oid_with_context(the_repository,
+                                filter_options->sparse_oid_name,
+                                GET_OID_BLOB, &sparse_oid, &oc))
+               die(_("unable to access sparse blob in '%s'"),
+                   filter_options->sparse_oid_name);
 -      d->omits = omitted;
 -      if (add_excludes_from_blob_to_list(&sparse_oid, "", 0, &d->el) < 0)
++      if (add_patterns_from_blob_to_list(&sparse_oid, "", 0, &d->pl) < 0)
+               die(_("unable to parse sparse filter data in %s"),
+                   oid_to_hex(&sparse_oid));
  
        ALLOC_GROW(d->array_frame, d->nr + 1, d->alloc);
 -      d->array_frame[d->nr].defval = 0; /* default to include */
 +      d->array_frame[d->nr].default_match = 0; /* default to include */
        d->array_frame[d->nr].child_prov_omit = 0;
        d->nr++;
  
Simple merge