| 445 | } |
| 446 | |
| 447 | static int setup_pending_objects(struct path_walk_info *info, |
| 448 | struct path_walk_context *ctx) |
| 449 | { |
| 450 | struct type_and_oid_list *tags = NULL; |
| 451 | struct type_and_oid_list *tagged_blobs = NULL; |
| 452 | struct type_and_oid_list *tagged_trees = NULL; |
| 453 | |
| 454 | if (info->tags) |
| 455 | CALLOC_ARRAY(tags, 1); |
| 456 | CALLOC_ARRAY(tagged_blobs, 1); |
| 457 | CALLOC_ARRAY(tagged_trees, 1); |
| 458 | |
| 459 | /* |
| 460 | * Pending objects include: |
| 461 | * * Commits at branch tips. |
| 462 | * * Annotated tags at tag tips. |
| 463 | * * Any kind of object at lightweight tag tips. |
| 464 | * * Trees and blobs in the index (with an associated path). |
| 465 | */ |
| 466 | for (size_t i = 0; i < info->revs->pending.nr; i++) { |
| 467 | struct object_array_entry *pending = info->revs->pending.objects + i; |
| 468 | struct object *obj = pending->item; |
| 469 | |
| 470 | /* Commits will be picked up by revision walk. */ |
| 471 | if (obj->type == OBJ_COMMIT) |
| 472 | continue; |
| 473 | |
| 474 | /* Navigate annotated tag object chains. */ |
| 475 | while (obj->type == OBJ_TAG) { |
| 476 | struct tag *tag = lookup_tag(info->revs->repo, &obj->oid); |
| 477 | if (!tag) { |
| 478 | error(_("failed to find tag %s"), |
| 479 | oid_to_hex(&obj->oid)); |
| 480 | return -1; |
| 481 | } |
| 482 | if (tag->object.flags & SEEN) |
| 483 | break; |
| 484 | tag->object.flags |= SEEN; |
| 485 | |
| 486 | if (tags) |
| 487 | oid_array_append(&tags->oids, &obj->oid); |
| 488 | obj = tag->tagged; |
| 489 | } |
| 490 | |
| 491 | if (obj->type == OBJ_TAG) |
| 492 | continue; |
| 493 | |
| 494 | /* We are now at a non-tag object. */ |
| 495 | if (obj->flags & SEEN) |
| 496 | continue; |
| 497 | obj->flags |= SEEN; |
| 498 | |
| 499 | switch (obj->type) { |
| 500 | case OBJ_TREE: |
| 501 | if (pending->path && *pending->path) { |
| 502 | char *path = xstrfmt("%s/", pending->path); |
| 503 | add_path_to_list(ctx, path, OBJ_TREE, &obj->oid, 1); |
| 504 | free(path); |
no test coverage detected