| 1458 | } |
| 1459 | |
| 1460 | static int unpack_sparse_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *names, struct traverse_info *info) |
| 1461 | { |
| 1462 | struct cache_entry *src[MAX_UNPACK_TREES + 1] = { NULL, }; |
| 1463 | struct unpack_trees_options *o = info->data; |
| 1464 | int ret, is_new_sparse_dir; |
| 1465 | |
| 1466 | assert(o->merge); |
| 1467 | |
| 1468 | /* |
| 1469 | * Unlike in 'unpack_callback', where src[0] is derived from the index when |
| 1470 | * merging, src[0] is a transient cache entry derived from the first tree |
| 1471 | * provided. Create the temporary entry as if it came from a non-sparse index. |
| 1472 | */ |
| 1473 | if (!is_null_oid(&names[0].oid)) { |
| 1474 | src[0] = create_ce_entry(info, &names[0], 0, |
| 1475 | &o->internal.result, 1, |
| 1476 | dirmask & (1ul << 0)); |
| 1477 | src[0]->ce_flags |= (CE_SKIP_WORKTREE | CE_NEW_SKIP_WORKTREE); |
| 1478 | } |
| 1479 | |
| 1480 | /* |
| 1481 | * 'unpack_single_entry' assumes that src[0] is derived directly from |
| 1482 | * the index, rather than from an entry in 'names'. This is *not* true when |
| 1483 | * merging a sparse directory, in which case names[0] is the "index" source |
| 1484 | * entry. To match the expectations of 'unpack_single_entry', shift past the |
| 1485 | * "index" tree (i.e., names[0]) and adjust 'names', 'n', 'mask', and |
| 1486 | * 'dirmask' accordingly. |
| 1487 | */ |
| 1488 | ret = unpack_single_entry(n - 1, mask >> 1, dirmask >> 1, src, names + 1, info, &is_new_sparse_dir); |
| 1489 | |
| 1490 | if (src[0]) |
| 1491 | discard_cache_entry(src[0]); |
| 1492 | |
| 1493 | return ret >= 0 ? mask : -1; |
| 1494 | } |
| 1495 | |
| 1496 | /* |
| 1497 | * Note that traverse_by_cache_tree() duplicates some logic in this function |
nothing calls this directly
no test coverage detected