From: Junio C Hamano Date: Mon, 7 Oct 2019 02:32:54 +0000 (+0900) Subject: Merge branch 'jk/partial-clone-sparse-blob' X-Git-Tag: v2.24.0-rc0~85 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ad8f0368b45bf1ab0f1339033d0a62cee94b1ae2;p=thirdparty%2Fgit.git Merge branch 'jk/partial-clone-sparse-blob' 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= filter --- ad8f0368b45bf1ab0f1339033d0a62cee94b1ae2 diff --cc list-objects-filter-options.c index 4d88bfe64a,adbea552a0..256bcfbdfe --- a/list-objects-filter-options.c +++ b/list-objects-filter-options.c @@@ -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)); } diff --cc list-objects-filter-options.h index b63c5ee1a3,20b9d1e587..2ffb39222c --- a/list-objects-filter-options.h +++ b/list-objects-filter-options.h @@@ -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 */ diff --cc list-objects-filter.c index d624f1c898,83c788e8b5..1e8d4e763d --- a/list-objects-filter.c +++ b/list-objects-filter.c @@@ -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++;