* One-way merge. * * The rule is: * - take the stat information from stage0, take the data from stage1 */
| 3018 | * - take the stat information from stage0, take the data from stage1 |
| 3019 | */ |
| 3020 | int 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. |
nothing calls this directly
no test coverage detected