3 test_description="merges with unrelated index changes"
7 # Testcase for some simple merges
18 # Commit A: some file a
19 # Commit B: adds file b, modifies end of a
20 # Commit C: adds file c
21 # Commit D: adds file d, modifies beginning of a
22 # Commit E: renames a->subdir/a, adds subdir/e
23 # Commit F: empty commit
25 test_expect_success 'setup trivial merges' '
28 test_tick && git commit -m A &&
41 test_tick && git commit -m B &&
46 test_tick && git commit -m C &&
52 test_tick && git commit -m D &&
59 test_tick && git commit -m E &&
62 test_tick && git commit --allow-empty -m F
65 test_expect_success 'ff update' '
69 touch random_file && git add random_file &&
73 test_must_fail git rev-parse HEAD:random_file &&
74 test "$(git diff --name-only --cached E)" = "random_file"
77 test_expect_success 'ff update, important file modified' '
85 test_must_fail git merge E^0 &&
86 test_path_is_missing .git/MERGE_HEAD
89 test_expect_success 'resolve, trivial' '
93 touch random_file && git add random_file &&
95 test_must_fail git merge -s resolve C^0 &&
96 test_path_is_missing .git/MERGE_HEAD
99 test_expect_success 'resolve, non-trivial' '
103 touch random_file && git add random_file &&
105 test_must_fail git merge -s resolve D^0 &&
106 test_path_is_missing .git/MERGE_HEAD
109 test_expect_success 'recursive' '
113 touch random_file && git add random_file &&
115 test_must_fail git merge -s recursive C^0 &&
116 test_path_is_missing .git/MERGE_HEAD
119 test_expect_success 'recursive, when merge branch matches merge base' '
123 touch random_file && git add random_file &&
125 test_must_fail git merge -s recursive F^0 &&
126 test_path_is_missing .git/MERGE_HEAD
129 test_expect_failure 'merge-recursive, when index==head but head!=HEAD' '
134 git diff C B -- | git apply --cached &&
135 # Merge B & F, with B as "head"
136 git merge-recursive A -- B F > out &&
137 test_i18ngrep "Already up to date" out
140 test_expect_success 'octopus, unrelated file touched' '
144 touch random_file && git add random_file &&
146 test_must_fail git merge C^0 D^0 &&
147 test_path_is_missing .git/MERGE_HEAD
150 test_expect_success 'octopus, related file removed' '
156 test_must_fail git merge C^0 D^0 &&
157 test_path_is_missing .git/MERGE_HEAD
160 test_expect_success 'octopus, related file modified' '
164 echo 12 >>a && git add a &&
166 test_must_fail git merge C^0 D^0 &&
167 test_path_is_missing .git/MERGE_HEAD
170 test_expect_success 'ours' '
174 touch random_file && git add random_file &&
176 test_must_fail git merge -s ours C^0 &&
177 test_path_is_missing .git/MERGE_HEAD
180 test_expect_success 'subtree' '
184 touch random_file && git add random_file &&
186 test_must_fail git merge -s subtree E^0 &&
187 test_path_is_missing .git/MERGE_HEAD