MCPcopy Index your code
hub / github.com/git/git / walk_path

Function walk_path

path-walk.c:301–412  ·  view source on GitHub ↗

* For each path in paths_to_explore, walk the trees another level * and add any found blobs to the batch (but only if they exist and * haven't been added yet). */

Source from the content-addressed store, hash-verified

299 * haven't been added yet).
300 */
301static int walk_path(struct path_walk_context *ctx,
302 const char *path)
303{
304 struct type_and_oid_list *list;
305 int ret = 0;
306
307 list = strmap_get(&ctx->paths_to_lists, path);
308
309 if (!list)
310 BUG("provided path '%s' that had no associated list", path);
311
312 if (!list->oids.nr)
313 return 0;
314
315 if (ctx->info->prune_all_uninteresting) {
316 /*
317 * This is true if all objects were UNINTERESTING
318 * when added to the list.
319 */
320 if (!list->maybe_interesting)
321 return 0;
322
323 /*
324 * But it's still possible that the objects were set
325 * as UNINTERESTING after being added. Do a quick check.
326 */
327 list->maybe_interesting = 0;
328 for (size_t i = 0;
329 !list->maybe_interesting && i < list->oids.nr;
330 i++) {
331 if (list->type == OBJ_TREE) {
332 struct tree *t = lookup_tree(ctx->repo,
333 &list->oids.oid[i]);
334 if (t && !(t->object.flags & UNINTERESTING))
335 list->maybe_interesting = 1;
336 } else if (list->type == OBJ_BLOB) {
337 struct blob *b = lookup_blob(ctx->repo,
338 &list->oids.oid[i]);
339 if (b && !(b->object.flags & UNINTERESTING))
340 list->maybe_interesting = 1;
341 } else {
342 /* Tags are always interesting if visited. */
343 list->maybe_interesting = 1;
344 }
345 }
346
347 /* We have confirmed that all objects are UNINTERESTING. */
348 if (!list->maybe_interesting)
349 return 0;
350 }
351
352 if (list->type == OBJ_BLOB &&
353 ctx->revs->prune_data.nr &&
354 !path_is_for_direct_objects(path) &&
355 !match_pathspec(ctx->repo->index, &ctx->revs->prune_data,
356 path, strlen(path), 0,
357 NULL, 0))
358 return 0;

Callers 1

walk_objects_by_pathFunction · 0.85

Calls 10

strmap_getFunction · 0.85
lookup_treeFunction · 0.85
lookup_blobFunction · 0.85
match_pathspecFunction · 0.85
odb_read_object_infoFunction · 0.85
oid_array_appendFunction · 0.85
oid_array_clearFunction · 0.85
add_tree_entriesFunction · 0.85
strmap_removeFunction · 0.85

Tested by

no test coverage detected