3 test_description
='Test various callers of read_index_unmerged'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success
'setup modify/delete + directory/file conflict' '
9 test_create_repo df_plus_modify_delete &&
11 cd df_plus_modify_delete &&
13 test_write_lines a b c d e f g h >letters &&
15 git commit -m initial &&
17 git checkout -b modify &&
18 # Throw in letters.txt for sorting order fun
19 # ("letters.txt" sorts between "letters" and "letters/file")
21 echo "version 2" >letters.txt &&
22 git add letters letters.txt &&
23 git commit -m modified &&
25 git checkout -b delete HEAD^ &&
29 echo "version 1" >letters.txt &&
30 git add letters letters.txt &&
35 test_expect_success
'read-tree --reset cleans unmerged entries' '
36 test_when_finished "git -C df_plus_modify_delete clean -f" &&
37 test_when_finished "git -C df_plus_modify_delete reset --hard" &&
39 cd df_plus_modify_delete &&
41 git checkout delete^0 &&
42 test_must_fail git merge modify &&
44 git read-tree --reset HEAD &&
45 git ls-files -u >conflicts &&
46 test_must_be_empty conflicts
50 test_expect_success
'One reset --hard cleans unmerged entries' '
51 test_when_finished "git -C df_plus_modify_delete clean -f" &&
52 test_when_finished "git -C df_plus_modify_delete reset --hard" &&
54 cd df_plus_modify_delete &&
56 git checkout delete^0 &&
57 test_must_fail git merge modify &&
60 test_path_is_missing .git/MERGE_HEAD &&
61 git ls-files -u >conflicts &&
62 test_must_be_empty conflicts
66 test_expect_success
'setup directory/file conflict + simple edit/edit' '
67 test_create_repo df_plus_edit_edit &&
69 cd df_plus_edit_edit &&
71 test_seq 1 10 >numbers &&
73 git commit -m initial &&
75 git checkout -b d-edit &&
77 echo content >foo/bar &&
81 git commit -m "directory and edit" &&
83 git checkout -b f-edit d-edit^1 &&
86 echo eleven >>numbers &&
88 git commit -m "file and edit"
92 test_expect_success
'git merge --abort succeeds despite D/F conflict' '
93 test_when_finished "git -C df_plus_edit_edit clean -f" &&
94 test_when_finished "git -C df_plus_edit_edit reset --hard" &&
96 cd df_plus_edit_edit &&
98 git checkout f-edit^0 &&
99 test_must_fail git merge d-edit^0 &&
102 test_path_is_missing .git/MERGE_HEAD &&
103 git ls-files -u >conflicts &&
104 test_must_be_empty conflicts
108 test_expect_success
'git am --skip succeeds despite D/F conflict' '
109 test_when_finished "git -C df_plus_edit_edit clean -f" &&
110 test_when_finished "git -C df_plus_edit_edit reset --hard" &&
112 cd df_plus_edit_edit &&
114 git checkout f-edit^0 &&
115 git format-patch -1 d-edit &&
116 test_must_fail git am -3 0001*.patch &&
119 test_path_is_missing .git/rebase-apply &&
120 git ls-files -u >conflicts &&
121 test_must_be_empty conflicts