248
return 0;
249
}
250
251
+/*
252
+ * Paths starting with '/' (e.g., "/tags", "/tagged-blobs") hold objects that
253
+ * were directly requested by 'pending' objects rather than discovered during
254
+ * tree traversal.
255
+ */
256
+static int path_is_for_direct_objects(const char *path)
257
+{
258
+ ASSERT(path);
259
+ return path[0] == '/';
260
+}
261
+
262
/*
263
* For each path in paths_to_explore, walk the trees another level
264
* and add any found blobs to the batch (but only if they exist and
317
318
if (list->type == OBJ_BLOB &&
319
ctx->revs->prune_data.nr &&
320
+ !path_is_for_direct_objects(path) &&
321
!match_pathspec(ctx->repo->index, &ctx->revs->prune_data,
322
path, strlen(path), 0,
323
NULL, 0))
324
return 0;
325
314
- /* Evaluate function pointer on this data, if requested. */
315
- if ((list->type == OBJ_TREE && ctx->info->trees) ||
316
- (list->type == OBJ_BLOB && ctx->info->blobs) ||
326
+ /*
327
+ * Evaluate function pointer on this data, if requested.
328
+ * Ignore object type filters for tagged objects (path starts
329
+ * with `/`).
330
+ */
331
+ if ((list->type == OBJ_TREE && (ctx->info->trees || path_is_for_direct_objects(path))) ||
332
+ (list->type == OBJ_BLOB && (ctx->info->blobs || path_is_for_direct_objects(path))) ||
333
(list->type == OBJ_TAG && ctx->info->tags))
334
ret = ctx->info->path_fn(path, &list->oids, list->type,
335
ctx->info->path_fn_data);
390
391
if (info->tags)
392
CALLOC_ARRAY(tags, 1);
377
- if (info->blobs)
378
- CALLOC_ARRAY(tagged_blobs, 1);
379
- if (info->trees)
380
- root_tree_list = strmap_get(&ctx->paths_to_lists, root_path);
393
+ CALLOC_ARRAY(tagged_blobs, 1);
394
+ root_tree_list = strmap_get(&ctx->paths_to_lists, root_path);
395
396
/*
397
* Pending objects include:
435
436
switch (obj->type) {
437
case OBJ_TREE:
424
- if (!info->trees)
425
- continue;
438
if (pending->path) {
439
char *path = *pending->path ? xstrfmt("%s/", pending->path)
440
: xstrdup("");
447
break;
448
449
case OBJ_BLOB:
438
- if (!info->blobs)
439
- continue;
450
if (pending->path)
451
add_path_to_list(ctx, pending->path, OBJ_BLOB, &obj->oid, 1);
452
else
542
push_to_stack(&ctx, root_path);
543
544
/*
535
- * Set these values before preparing the walk to catch
536
- * lightweight tags pointing to non-commits and indexed objects.
545
+ * Ensure that prepare_revision_walk() keeps all pending objects
546
+ * even through an object type filter.
547
*/
538
- info->revs->blob_objects = info->blobs;
539
- info->revs->tree_objects = info->trees;
548
+ info->revs->blob_objects = info->revs->tree_objects = 1;
549
550
if (prepare_revision_walk(info->revs))
551
die(_("failed to setup revision walk"));
552
553
+ info->revs->blob_objects = info->blobs;
554
+ info->revs->tree_objects = info->trees;
555
+
556
/*
557
* Walk trees to mark them as UNINTERESTING.
558
* This is particularly important when 'edge_aggressive' is set.