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

Function merged_entry

unpack-trees.c:2559–2642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2557}
2558
2559static int merged_entry(const struct cache_entry *ce,
2560 const struct cache_entry *old,
2561 struct unpack_trees_options *o)
2562{
2563 int update = CE_UPDATE;
2564 struct cache_entry *merge = dup_cache_entry(ce, &o->internal.result);
2565
2566 if (!old) {
2567 /*
2568 * New index entries. In sparse checkout, the following
2569 * verify_absent() will be delayed until after
2570 * traverse_trees() finishes in unpack_trees(), then:
2571 *
2572 * - CE_NEW_SKIP_WORKTREE will be computed correctly
2573 * - verify_absent() be called again, this time with
2574 * correct CE_NEW_SKIP_WORKTREE
2575 *
2576 * verify_absent() call here does nothing in sparse
2577 * checkout (i.e. o->skip_sparse_checkout == 0)
2578 */
2579 update |= CE_ADDED;
2580 merge->ce_flags |= CE_NEW_SKIP_WORKTREE;
2581
2582 if (verify_absent(merge,
2583 ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN, o)) {
2584 discard_cache_entry(merge);
2585 return -1;
2586 }
2587 invalidate_ce_path(merge, o);
2588
2589 if (submodule_from_ce(ce) && file_exists(ce->name)) {
2590 int ret = check_submodule_move_head(ce, NULL,
2591 oid_to_hex(&ce->oid),
2592 o);
2593 if (ret)
2594 return ret;
2595 }
2596
2597 } else if (!(old->ce_flags & CE_CONFLICTED)) {
2598 /*
2599 * See if we can re-use the old CE directly?
2600 * That way we get the uptodate stat info.
2601 *
2602 * This also removes the UPDATE flag on a match; otherwise
2603 * we will end up overwriting local changes in the work tree.
2604 */
2605 if (same(old, merge)) {
2606 copy_cache_entry(merge, old);
2607 update = 0;
2608 } else {
2609 if (verify_uptodate(old, o)) {
2610 discard_cache_entry(merge);
2611 return -1;
2612 }
2613 /* Migrate old flags over */
2614 update |= old->ce_flags & (CE_SKIP_WORKTREE | CE_NEW_SKIP_WORKTREE);
2615 invalidate_ce_path(old, o);
2616 }

Callers 5

threeway_mergeFunction · 0.85
twoway_mergeFunction · 0.85
bind_mergeFunction · 0.85
oneway_mergeFunction · 0.85

Calls 13

dup_cache_entryFunction · 0.85
verify_absentFunction · 0.85
discard_cache_entryFunction · 0.85
invalidate_ce_pathFunction · 0.85
submodule_from_ceFunction · 0.85
file_existsFunction · 0.85
oid_to_hexFunction · 0.85
sameFunction · 0.85
copy_cache_entryFunction · 0.85
verify_uptodateFunction · 0.85

Tested by

no test coverage detected