]>
Commit | Line | Data |
---|---|---|
29796c6c JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='basic work tree status reporting' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | test_expect_success setup ' | |
6a38ef2c | 8 | git config --global advice.statusuoption false && |
29796c6c JH |
9 | test_commit A && |
10 | test_commit B oneside added && | |
11 | git checkout A^0 && | |
12 | test_commit C oneside created | |
13 | ' | |
14 | ||
15 | test_expect_success 'A/A conflict' ' | |
16 | git checkout B^0 && | |
17 | test_must_fail git merge C | |
18 | ' | |
19 | ||
20 | test_expect_success 'Report path with conflict' ' | |
21 | git diff --cached --name-status >actual && | |
22 | echo "U oneside" >expect && | |
23 | test_cmp expect actual | |
24 | ' | |
25 | ||
26 | test_expect_success 'Report new path with conflict' ' | |
27 | git diff --cached --name-status HEAD^ >actual && | |
28 | echo "U oneside" >expect && | |
29 | test_cmp expect actual | |
30 | ' | |
31 | ||
1c7969c9 MM |
32 | test_expect_success 'M/D conflict does not segfault' ' |
33 | cat >expect <<EOF && | |
34 | On branch side | |
35 | You have unmerged paths. | |
36 | (fix conflicts and run "git commit") | |
37 | ||
38 | Unmerged paths: | |
39 | (use "git add/rm <file>..." as appropriate to mark resolution) | |
40 | ||
c7cb333f | 41 | deleted by us: foo |
1c7969c9 | 42 | |
4d4d5726 JH |
43 | no changes added to commit (use "git add" and/or "git commit -a") |
44 | EOF | |
4d4d5726 JH |
45 | mkdir mdconflict && |
46 | ( | |
47 | cd mdconflict && | |
48 | git init && | |
49 | test_commit initial foo "" && | |
50 | test_commit modify foo foo && | |
51 | git checkout -b side HEAD^ && | |
52 | git rm foo && | |
53 | git commit -m delete && | |
54 | test_must_fail git merge master && | |
9e4b7ab6 | 55 | test_must_fail git commit --dry-run >../actual && |
b3e1900a | 56 | test_i18ncmp ../expect ../actual && |
9e4b7ab6 | 57 | git status >../actual && |
b3e1900a | 58 | test_i18ncmp ../expect ../actual |
9e4b7ab6 | 59 | ) |
4d4d5726 JH |
60 | ' |
61 | ||
d7c9bf22 MZ |
62 | test_expect_success 'rename & unmerged setup' ' |
63 | git rm -f -r . && | |
64 | cat "$TEST_DIRECTORY/README" >ONE && | |
65 | git add ONE && | |
66 | test_tick && | |
67 | git commit -m "One commit with ONE" && | |
68 | ||
69 | echo Modified >TWO && | |
70 | cat ONE >>TWO && | |
71 | cat ONE >>THREE && | |
72 | git add TWO THREE && | |
73 | sha1=$(git rev-parse :ONE) && | |
74 | git rm --cached ONE && | |
75 | ( | |
76 | echo "100644 $sha1 1 ONE" && | |
77 | echo "100644 $sha1 2 ONE" && | |
78 | echo "100644 $sha1 3 ONE" | |
79 | ) | git update-index --index-info && | |
80 | echo Further >>THREE | |
81 | ' | |
82 | ||
83 | test_expect_success 'rename & unmerged status' ' | |
84 | git status -suno >actual && | |
85 | cat >expect <<-EOF && | |
86 | UU ONE | |
87 | AM THREE | |
88 | A TWO | |
89 | EOF | |
90 | test_cmp expect actual | |
91 | ' | |
92 | ||
93 | test_expect_success 'git diff-index --cached shows 2 added + 1 unmerged' ' | |
94 | cat >expected <<-EOF && | |
95 | U ONE | |
96 | A THREE | |
97 | A TWO | |
98 | EOF | |
99 | git diff-index --cached --name-status HEAD >actual && | |
100 | test_cmp expected actual | |
101 | ' | |
102 | ||
103 | test_expect_success 'git diff-index --cached -M shows 2 added + 1 unmerged' ' | |
104 | cat >expected <<-EOF && | |
105 | U ONE | |
106 | A THREE | |
107 | A TWO | |
108 | EOF | |
109 | git diff-index --cached --name-status HEAD >actual && | |
110 | test_cmp expected actual | |
111 | ' | |
112 | ||
113 | test_expect_success 'git diff-index --cached -C shows 2 copies + 1 unmerged' ' | |
114 | cat >expected <<-EOF && | |
115 | U ONE | |
116 | C ONE THREE | |
117 | C ONE TWO | |
118 | EOF | |
119 | git diff-index --cached -C --name-status HEAD | | |
120 | sed "s/^C[0-9]*/C/g" >actual && | |
121 | test_cmp expected actual | |
122 | ' | |
123 | ||
83c750ac LK |
124 | |
125 | test_expect_success 'status when conflicts with add and rm advice (deleted by them)' ' | |
126 | git reset --hard && | |
127 | git checkout master && | |
128 | test_commit init main.txt init && | |
129 | git checkout -b second_branch && | |
130 | git rm main.txt && | |
131 | git commit -m "main.txt deleted on second_branch" && | |
132 | test_commit second conflict.txt second && | |
133 | git checkout master && | |
134 | test_commit on_second main.txt on_second && | |
135 | test_commit master conflict.txt master && | |
136 | test_must_fail git merge second_branch && | |
1c7969c9 MM |
137 | cat >expected <<\EOF && |
138 | On branch master | |
139 | You have unmerged paths. | |
140 | (fix conflicts and run "git commit") | |
141 | ||
142 | Unmerged paths: | |
143 | (use "git add/rm <file>..." as appropriate to mark resolution) | |
144 | ||
c7cb333f JH |
145 | both added: conflict.txt |
146 | deleted by them: main.txt | |
1c7969c9 MM |
147 | |
148 | no changes added to commit (use "git add" and/or "git commit -a") | |
149 | EOF | |
83c750ac LK |
150 | git status --untracked-files=no >actual && |
151 | test_i18ncmp expected actual | |
152 | ' | |
153 | ||
154 | ||
96b0ec1a | 155 | test_expect_success 'prepare for conflicts' ' |
83c750ac LK |
156 | git reset --hard && |
157 | git checkout -b conflict && | |
158 | test_commit one main.txt one && | |
159 | git branch conflict_second && | |
160 | git mv main.txt sub_master.txt && | |
161 | git commit -m "main.txt renamed in sub_master.txt" && | |
162 | git checkout conflict_second && | |
163 | git mv main.txt sub_second.txt && | |
96b0ec1a LK |
164 | git commit -m "main.txt renamed in sub_second.txt" |
165 | ' | |
166 | ||
167 | ||
168 | test_expect_success 'status when conflicts with add and rm advice (both deleted)' ' | |
83c750ac | 169 | test_must_fail git merge conflict && |
1c7969c9 MM |
170 | cat >expected <<\EOF && |
171 | On branch conflict_second | |
172 | You have unmerged paths. | |
173 | (fix conflicts and run "git commit") | |
174 | ||
175 | Unmerged paths: | |
176 | (use "git add/rm <file>..." as appropriate to mark resolution) | |
177 | ||
c7cb333f JH |
178 | both deleted: main.txt |
179 | added by them: sub_master.txt | |
180 | added by us: sub_second.txt | |
1c7969c9 MM |
181 | |
182 | no changes added to commit (use "git add" and/or "git commit -a") | |
183 | EOF | |
83c750ac LK |
184 | git status --untracked-files=no >actual && |
185 | test_i18ncmp expected actual | |
186 | ' | |
187 | ||
188 | ||
96b0ec1a LK |
189 | test_expect_success 'status when conflicts with only rm advice (both deleted)' ' |
190 | git reset --hard conflict_second && | |
191 | test_must_fail git merge conflict && | |
192 | git add sub_master.txt && | |
193 | git add sub_second.txt && | |
1c7969c9 MM |
194 | cat >expected <<\EOF && |
195 | On branch conflict_second | |
196 | You have unmerged paths. | |
197 | (fix conflicts and run "git commit") | |
198 | ||
199 | Changes to be committed: | |
200 | ||
201 | new file: sub_master.txt | |
202 | ||
203 | Unmerged paths: | |
204 | (use "git rm <file>..." to mark resolution) | |
205 | ||
c7cb333f | 206 | both deleted: main.txt |
1c7969c9 MM |
207 | |
208 | Untracked files not listed (use -u option to show untracked files) | |
209 | EOF | |
96b0ec1a LK |
210 | git status --untracked-files=no >actual && |
211 | test_i18ncmp expected actual && | |
212 | git reset --hard && | |
213 | git checkout master | |
214 | ' | |
215 | ||
216 | ||
29796c6c | 217 | test_done |