Skip to content

Commit cee2d6a

Browse files
committed
Aggressive three-way merge: fix D/F case
When the ancestor used to have a blob "P", your tree removed it, and the tree you are merging with also removed it, the agressive three-way cleanly merges to remove that blob. If the other tree added a new blob "P/Q" while removing "P", it should also merge cleanly to remove "P" and create "P/Q" (since neither the ancestor nor your tree could have had it, so it is a typical "created in one"). The "aggressive" rule is not new anymore. Reword the stale comment. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1ee2657 commit cee2d6a

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

t/t6035-merge-dir-to-symlink.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ test_expect_success 'setup a merge where dir a/b-2 changed to symlink' '
7474
git tag test2
7575
'
7676

77-
test_expect_failure 'merge should not have conflicts (resolve)' '
77+
test_expect_success 'merge should not have conflicts (resolve)' '
7878
git reset --hard &&
7979
git checkout baseline^0 &&
8080
git merge -s resolve test2 &&

unpack-trees.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,8 @@ int threeway_merge(struct cache_entry **stages, struct unpack_trees_options *o)
767767
remote = NULL;
768768
}
769769

770-
/* First, if there's a #16 situation, note that to prevent #13
770+
/*
771+
* First, if there's a #16 situation, note that to prevent #13
771772
* and #14.
772773
*/
773774
if (!same(remote, head)) {
@@ -781,7 +782,8 @@ int threeway_merge(struct cache_entry **stages, struct unpack_trees_options *o)
781782
}
782783
}
783784

784-
/* We start with cases where the index is allowed to match
785+
/*
786+
* We start with cases where the index is allowed to match
785787
* something other than the head: #14(ALT) and #2ALT, where it
786788
* is permitted to match the result instead.
787789
*/
@@ -811,12 +813,13 @@ int threeway_merge(struct cache_entry **stages, struct unpack_trees_options *o)
811813
if (!head && !remote && any_anc_missing)
812814
return 0;
813815

814-
/* Under the new "aggressive" rule, we resolve mostly trivial
816+
/*
817+
* Under the "aggressive" rule, we resolve mostly trivial
815818
* cases that we historically had git-merge-one-file resolve.
816819
*/
817820
if (o->aggressive) {
818-
int head_deleted = !head && !df_conflict_head;
819-
int remote_deleted = !remote && !df_conflict_remote;
821+
int head_deleted = !head;
822+
int remote_deleted = !remote;
820823
struct cache_entry *ce = NULL;
821824

822825
if (index)

0 commit comments

Comments
 (0)