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