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

Function oneway_merge

unpack-trees.c:3020–3049  ·  view source on GitHub ↗

* One-way merge. * * The rule is: * - take the stat information from stage0, take the data from stage1 */

Source from the content-addressed store, hash-verified

3018 * - take the stat information from stage0, take the data from stage1
3019 */
3020int oneway_merge(const struct cache_entry * const *src,
3021 struct unpack_trees_options *o)
3022{
3023 const struct cache_entry *old = src[0];
3024 const struct cache_entry *a = src[1];
3025
3026 if (o->internal.merge_size != 1)
3027 return error("Cannot do a oneway merge of %d trees",
3028 o->internal.merge_size);
3029
3030 if (!a || a == o->df_conflict_entry)
3031 return deleted_entry(old, old, o);
3032
3033 if (old && same(old, a)) {
3034 int update = 0;
3035 if (o->reset && o->update && !ce_uptodate(old) && !ce_skip_worktree(old) &&
3036 !(old->ce_flags & CE_FSMONITOR_VALID)) {
3037 struct stat st;
3038 if (lstat(old->name, &st) ||
3039 ie_match_stat(o->src_index, old, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE))
3040 update |= CE_UPDATE;
3041 }
3042 if (o->update && S_ISGITLINK(old->ce_mode) &&
3043 should_update_submodules() && !verify_uptodate(old, o))
3044 update |= CE_UPDATE;
3045 add_entry(o, old, update, CE_STAGEMASK);
3046 return 0;
3047 }
3048 return merged_entry(a, old, o);
3049}
3050
3051/*
3052 * Merge worktree and untracked entries in a stash entry.

Callers

nothing calls this directly

Calls 8

errorFunction · 0.85
deleted_entryFunction · 0.85
sameFunction · 0.85
ie_match_statFunction · 0.85
should_update_submodulesFunction · 0.85
verify_uptodateFunction · 0.85
merged_entryFunction · 0.85
add_entryFunction · 0.70

Tested by

no test coverage detected