202
static void filter_spec_append_urlencode(
203
struct list_objects_filter_options *filter, const char *raw)
204
{
205
- struct strbuf buf = STRBUF_INIT;
206
- strbuf_addstr_urlencode(&buf, raw, allow_unencoded);
207
- trace_printf("Add to combine filter-spec: %s\n", buf.buf);
208
- string_list_append_nodup(&filter->filter_spec, strbuf_detach(&buf, NULL));
205
+ size_t orig_len = filter->filter_spec.len;
206
+ strbuf_addstr_urlencode(&filter->filter_spec, raw, allow_unencoded);
207
+ trace_printf("Add to combine filter-spec: %s\n",
208
+ filter->filter_spec.buf + orig_len);
209
}
210
211
/*
229
}
230
filter_options->sub_nr = 1;
231
filter_options->choice = LOFC_COMBINE;
232
- string_list_append(&filter_options->filter_spec, "combine:");
232
+ strbuf_addstr(&filter_options->filter_spec, "combine:");
233
filter_spec_append_urlencode(
234
filter_options,
235
list_objects_filter_spec(&filter_options->sub[0]));
237
* We don't need the filter_spec strings for subfilter specs, only the
238
* top level.
239
*/
240
- string_list_clear(&filter_options->sub[0].filter_spec, /*free_util=*/0);
240
+ strbuf_release(&filter_options->sub[0].filter_spec);
241
}
242
243
void list_objects_filter_die_if_populated(
254
struct strbuf errbuf = STRBUF_INIT;
255
int parse_error;
256
257
- if (!filter_options->filter_spec.strdup_strings)
257
+ if (!filter_options->filter_spec.buf)
258
BUG("filter_options not properly initialized");
259
260
if (!filter_options->choice) {
261
- string_list_append(&filter_options->filter_spec, arg);
261
+ strbuf_addstr(&filter_options->filter_spec, arg);
262
263
parse_error = gently_parse_list_objects_filter(
264
filter_options, arg, &errbuf);
269
*/
270
transform_to_combine_type(filter_options);
271
272
- string_list_append(&filter_options->filter_spec, "+");
272
+ strbuf_addch(&filter_options->filter_spec, '+');
273
filter_spec_append_urlencode(filter_options, arg);
274
ALLOC_GROW_BY(filter_options->sub, filter_options->sub_nr, 1,
275
filter_options->sub_alloc);
300
301
const char *list_objects_filter_spec(struct list_objects_filter_options *filter)
302
{
303
- if (!filter->filter_spec.nr)
303
+ if (!filter->filter_spec.len)
304
BUG("no filter_spec available for this filter");
305
- if (filter->filter_spec.nr != 1) {
306
- struct strbuf concatted = STRBUF_INIT;
307
- strbuf_add_separated_string_list(
308
- &concatted, "", &filter->filter_spec);
309
- string_list_clear(&filter->filter_spec, /*free_util=*/0);
310
- string_list_append_nodup(
311
- &filter->filter_spec, strbuf_detach(&concatted, NULL));
312
- }
313
-
314
- return filter->filter_spec.items[0].string;
305
+ return filter->filter_spec.buf;
306
}
307
308
const char *expand_list_objects_filter_spec(
309
struct list_objects_filter_options *filter)
310
{
311
if (filter->choice == LOFC_BLOB_LIMIT) {
321
- struct strbuf expanded_spec = STRBUF_INIT;
322
- strbuf_addf(&expanded_spec, "blob:limit=%lu",
312
+ strbuf_release(&filter->filter_spec);
313
+ strbuf_addf(&filter->filter_spec, "blob:limit=%lu",
314
filter->blob_limit_value);
324
- string_list_clear(&filter->filter_spec, /*free_util=*/0);
325
- string_list_append_nodup(
326
- &filter->filter_spec,
327
- strbuf_detach(&expanded_spec, NULL));
315
}
316
317
return list_objects_filter_spec(filter);
324
325
if (!filter_options)
326
return;
340
- string_list_clear(&filter_options->filter_spec, /*free_util=*/0);
327
+ strbuf_release(&filter_options->filter_spec);
328
free(filter_options->sparse_oid_name);
329
for (sub = 0; sub < filter_options->sub_nr; sub++)
330
list_objects_filter_release(&filter_options->sub[sub]);
385
if (!promisor || !promisor->partial_clone_filter)
386
return;
387
401
- string_list_append(&filter_options->filter_spec,
402
- promisor->partial_clone_filter);
388
+ strbuf_addstr(&filter_options->filter_spec,
389
+ promisor->partial_clone_filter);
390
gently_parse_list_objects_filter(filter_options,
391
promisor->partial_clone_filter,
392
&errbuf);
398
const struct list_objects_filter_options *src)
399
{
400
int i;
414
- struct string_list_item *item;
401
402
/* Copy everything. We will overwrite the pointers shortly. */
403
memcpy(dest, src, sizeof(struct list_objects_filter_options));
404
419
- string_list_init_dup(&dest->filter_spec);
420
- for_each_string_list_item(item, &src->filter_spec)
421
- string_list_append(&dest->filter_spec, item->string);
405
+ strbuf_init(&dest->filter_spec, 0);
406
+ strbuf_addbuf(&dest->filter_spec, &src->filter_spec);
407
dest->sparse_oid_name = xstrdup_or_null(src->sparse_oid_name);
408
409
ALLOC_ARRAY(dest->sub, dest->sub_alloc);