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

Function unpack_sparse_callback

unpack-trees.c:1460–1494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1458}
1459
1460static 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

Callers

nothing calls this directly

Calls 4

is_null_oidFunction · 0.85
create_ce_entryFunction · 0.85
unpack_single_entryFunction · 0.85
discard_cache_entryFunction · 0.85

Tested by

no test coverage detected