| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='Test various callers of read_index_unmerged' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success 'setup modify/delete + directory/file conflict' ' |
| 8 | test_create_repo df_plus_modify_delete && |
| 9 | ( |
| 10 | cd df_plus_modify_delete && |
| 11 | |
| 12 | test_write_lines a b c d e f g h >letters && |
| 13 | git add letters && |
| 14 | git commit -m initial && |
| 15 | |
| 16 | git checkout -b modify && |
| 17 | # Throw in letters.txt for sorting order fun |
| 18 | # ("letters.txt" sorts between "letters" and "letters/file") |
| 19 | echo i >>letters && |
| 20 | echo "version 2" >letters.txt && |
| 21 | git add letters letters.txt && |
| 22 | git commit -m modified && |
| 23 | |
| 24 | git checkout -b delete HEAD^ && |
| 25 | git rm letters && |
| 26 | mkdir letters && |
| 27 | >letters/file && |
| 28 | echo "version 1" >letters.txt && |
| 29 | git add letters letters.txt && |
| 30 | git commit -m deleted |
| 31 | ) |
| 32 | ' |
| 33 | |
| 34 | test_expect_success 'read-tree --reset cleans unmerged entries' ' |
| 35 | test_when_finished "git -C df_plus_modify_delete clean -f" && |
| 36 | test_when_finished "git -C df_plus_modify_delete reset --hard" && |
| 37 | ( |
| 38 | cd df_plus_modify_delete && |
| 39 | |
| 40 | git checkout delete^0 && |
| 41 | test_must_fail git merge modify && |
| 42 | |
| 43 | git read-tree --reset HEAD && |
| 44 | git ls-files -u >conflicts && |
| 45 | test_must_be_empty conflicts |
| 46 | ) |
| 47 | ' |
| 48 | |
| 49 | test_expect_success 'One reset --hard cleans unmerged entries' ' |
| 50 | test_when_finished "git -C df_plus_modify_delete clean -f" && |
| 51 | test_when_finished "git -C df_plus_modify_delete reset --hard" && |
| 52 | ( |
| 53 | cd df_plus_modify_delete && |
| 54 | |
| 55 | git checkout delete^0 && |
| 56 | test_must_fail git merge modify && |
| 57 | |
| 58 | git reset --hard && |
| 59 | test_path_is_missing .git/MERGE_HEAD && |
| 60 | git ls-files -u >conflicts && |
| 61 | test_must_be_empty conflicts |
| 62 | ) |
| 63 | ' |
| 64 | |
| 65 | test_expect_success 'setup directory/file conflict + simple edit/edit' ' |
| 66 | test_create_repo df_plus_edit_edit && |
| 67 | ( |
| 68 | cd df_plus_edit_edit && |
| 69 | |
| 70 | test_seq 1 10 >numbers && |
| 71 | git add numbers && |
| 72 | git commit -m initial && |
| 73 | |
| 74 | git checkout -b d-edit && |
| 75 | mkdir foo && |
| 76 | echo content >foo/bar && |
| 77 | git add foo && |
| 78 | echo 11 >>numbers && |
| 79 | git add numbers && |
| 80 | git commit -m "directory and edit" && |
| 81 | |
| 82 | git checkout -b f-edit d-edit^1 && |
| 83 | echo content >foo && |
| 84 | git add foo && |
| 85 | echo eleven >>numbers && |
| 86 | git add numbers && |
| 87 | git commit -m "file and edit" |
| 88 | ) |
| 89 | ' |
| 90 | |
| 91 | test_expect_success 'git merge --abort succeeds despite D/F conflict' ' |
| 92 | test_when_finished "git -C df_plus_edit_edit clean -f" && |
| 93 | test_when_finished "git -C df_plus_edit_edit reset --hard" && |
| 94 | ( |
| 95 | cd df_plus_edit_edit && |
| 96 | |
| 97 | git checkout f-edit^0 && |
| 98 | test_must_fail git merge d-edit^0 && |
| 99 | |
| 100 | git merge --abort && |
| 101 | test_path_is_missing .git/MERGE_HEAD && |
| 102 | git ls-files -u >conflicts && |
| 103 | test_must_be_empty conflicts |
| 104 | ) |
| 105 | ' |
| 106 | |
| 107 | test_expect_success 'git am --skip succeeds despite D/F conflict' ' |
| 108 | test_when_finished "git -C df_plus_edit_edit clean -f" && |
| 109 | test_when_finished "git -C df_plus_edit_edit reset --hard" && |
| 110 | ( |
| 111 | cd df_plus_edit_edit && |
| 112 | |
| 113 | git checkout f-edit^0 && |
| 114 | git format-patch -1 d-edit && |
| 115 | test_must_fail git am -3 0001*.patch && |
| 116 | |
| 117 | git am --skip && |
| 118 | test_path_is_missing .git/rebase-apply && |
| 119 | git ls-files -u >conflicts && |
| 120 | test_must_be_empty conflicts |
| 121 | ) |
| 122 | ' |
| 123 | |
| 124 | test_done |