MCPcopy Create free account
hub / github.com/git/git / unpack_callback

Function unpack_callback

unpack-trees.c:1501–1601  ·  view source on GitHub ↗

* Note that traverse_by_cache_tree() duplicates some logic in this function * without actually calling it. If you change the logic here you may need to * check and change there as well. */

Source from the content-addressed store, hash-verified

1499 * check and change there as well.
1500 */
1501static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *names, struct traverse_info *info)
1502{
1503 struct cache_entry *src[MAX_UNPACK_TREES + 1] = { NULL, };
1504 struct unpack_trees_options *o = info->data;
1505 const struct name_entry *p = names;
1506 int is_new_sparse_dir;
1507
1508 /* Find first entry with a real name (we could use "mask" too) */
1509 while (!p->mode)
1510 p++;
1511
1512 if (o->internal.debug_unpack)
1513 debug_unpack_callback(n, mask, dirmask, names, info);
1514
1515 /* Are we supposed to look at the index too? */
1516 if (o->merge) {
1517 while (1) {
1518 int cmp;
1519 struct cache_entry *ce;
1520
1521 if (o->diff_index_cached)
1522 ce = next_cache_entry(o);
1523 else
1524 ce = find_cache_entry(info, p);
1525
1526 if (!ce)
1527 break;
1528 cmp = compare_entry(ce, info, p);
1529 if (cmp < 0) {
1530 if (unpack_index_entry(ce, o) < 0)
1531 return unpack_failed(o, NULL);
1532 continue;
1533 }
1534 if (!cmp) {
1535 if (ce_stage(ce)) {
1536 /*
1537 * If we skip unmerged index
1538 * entries, we'll skip this
1539 * entry *and* the tree
1540 * entries associated with it!
1541 */
1542 if (o->skip_unmerged) {
1543 add_same_unmerged(ce, o);
1544 return mask;
1545 }
1546 }
1547 src[0] = ce;
1548 }
1549 break;
1550 }
1551 }
1552
1553 if (unpack_single_entry(n, mask, dirmask, src, names, info, &is_new_sparse_dir))
1554 return -1;
1555
1556 if (o->merge && src[0]) {
1557 if (ce_stage(src[0]))
1558 mark_ce_used_same_name(src[0], o);

Callers

nothing calls this directly

Calls 13

debug_unpack_callbackFunction · 0.85
next_cache_entryFunction · 0.85
find_cache_entryFunction · 0.85
compare_entryFunction · 0.85
unpack_index_entryFunction · 0.85
unpack_failedFunction · 0.85
add_same_unmergedFunction · 0.85
unpack_single_entryFunction · 0.85
mark_ce_used_same_nameFunction · 0.85
mark_ce_usedFunction · 0.85

Tested by

no test coverage detected