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