t7512-status-help.sh: better advices for git status
[git.git] / t / t7512-status-help.sh
blob3714e8e9c20ea3de6df102798459bf48696c2853
1 #!/bin/sh
3 # Copyright (c) 2012 Valentin Duperray, Lucien Kong, Franck Jonas,
4 # Thomas Nguy, Khoi Nguyen
5 # Grenoble INP Ensimag
8 test_description='git status advices'
10 . ./test-lib.sh
12 . "$TEST_DIRECTORY"/lib-rebase.sh
14 set_fake_editor
16 test_expect_success 'prepare for conflicts' '
17 test_commit init main.txt init &&
18 git branch conflicts &&
19 test_commit on_master main.txt on_master &&
20 git checkout conflicts &&
21 test_commit on_conflicts main.txt on_conflicts
25 test_expect_success 'status when conflicts unresolved' '
26 test_must_fail git merge master &&
27 cat >expected <<-\EOF &&
28 # On branch conflicts
29 # You have unmerged paths.
30 # (fix conflicts and run "git commit")
32 # Unmerged paths:
33 # (use "git add/rm <file>..." as appropriate to mark resolution)
35 # both modified: main.txt
37 no changes added to commit (use "git add" and/or "git commit -a")
38 EOF
39 git status --untracked-files=no >actual &&
40 test_i18ncmp expected actual
44 test_expect_success 'status when conflicts resolved before commit' '
45 git reset --hard conflicts &&
46 test_must_fail git merge master &&
47 echo one >main.txt &&
48 git add main.txt &&
49 cat >expected <<-\EOF &&
50 # On branch conflicts
51 # All conflicts fixed but you are still merging.
52 # (use "git commit" to conclude merge)
54 # Changes to be committed:
56 # modified: main.txt
58 # Untracked files not listed (use -u option to show untracked files)
59 EOF
60 git status --untracked-files=no >actual &&
61 test_i18ncmp expected actual
65 test_expect_success 'prepare for rebase conflicts' '
66 git reset --hard master &&
67 git checkout -b rebase_conflicts &&
68 test_commit one_rebase main.txt one &&
69 test_commit two_rebase main.txt two &&
70 test_commit three_rebase main.txt three
74 test_expect_success 'status when rebase in progress before resolving conflicts' '
75 test_when_finished "git rebase --abort" &&
76 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
77 cat >expected <<-\EOF &&
78 # Not currently on any branch.
79 # You are currently rebasing.
80 # (fix conflicts and then run "git rebase --continue")
81 # (use "git rebase --skip" to skip this patch)
82 # (use "git rebase --abort" to check out the original branch)
84 # Unmerged paths:
85 # (use "git reset HEAD <file>..." to unstage)
86 # (use "git add/rm <file>..." as appropriate to mark resolution)
88 # both modified: main.txt
90 no changes added to commit (use "git add" and/or "git commit -a")
91 EOF
92 git status --untracked-files=no >actual &&
93 test_i18ncmp expected actual
97 test_expect_success 'status when rebase in progress before rebase --continue' '
98 git reset --hard rebase_conflicts &&
99 test_when_finished "git rebase --abort" &&
100 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
101 echo three >main.txt &&
102 git add main.txt &&
103 cat >expected <<-\EOF &&
104 # Not currently on any branch.
105 # You are currently rebasing.
106 # (all conflicts fixed: run "git rebase --continue")
108 # Changes to be committed:
109 # (use "git reset HEAD <file>..." to unstage)
111 # modified: main.txt
113 # Untracked files not listed (use -u option to show untracked files)
115 git status --untracked-files=no >actual &&
116 test_i18ncmp expected actual
120 test_expect_success 'prepare for rebase_i_conflicts' '
121 git reset --hard master &&
122 git checkout -b rebase_i_conflicts &&
123 test_commit one_unmerge main.txt one_unmerge &&
124 git branch rebase_i_conflicts_second &&
125 test_commit one_master main.txt one_master &&
126 git checkout rebase_i_conflicts_second &&
127 test_commit one_second main.txt one_second
131 test_expect_success 'status during rebase -i when conflicts unresolved' '
132 test_when_finished "git rebase --abort" &&
133 test_must_fail git rebase -i rebase_i_conflicts &&
134 cat >expected <<-\EOF &&
135 # Not currently on any branch.
136 # You are currently rebasing.
137 # (fix conflicts and then run "git rebase --continue")
138 # (use "git rebase --skip" to skip this patch)
139 # (use "git rebase --abort" to check out the original branch)
141 # Unmerged paths:
142 # (use "git reset HEAD <file>..." to unstage)
143 # (use "git add/rm <file>..." as appropriate to mark resolution)
145 # both modified: main.txt
147 no changes added to commit (use "git add" and/or "git commit -a")
149 git status --untracked-files=no >actual &&
150 test_i18ncmp expected actual
154 test_expect_success 'status during rebase -i after resolving conflicts' '
155 git reset --hard rebase_i_conflicts_second &&
156 test_when_finished "git rebase --abort" &&
157 test_must_fail git rebase -i rebase_i_conflicts &&
158 git add main.txt &&
159 cat >expected <<-\EOF &&
160 # Not currently on any branch.
161 # You are currently rebasing.
162 # (all conflicts fixed: run "git rebase --continue")
164 # Changes to be committed:
165 # (use "git reset HEAD <file>..." to unstage)
167 # modified: main.txt
169 # Untracked files not listed (use -u option to show untracked files)
171 git status --untracked-files=no >actual &&
172 test_i18ncmp expected actual
176 test_expect_success 'status when rebasing -i in edit mode' '
177 git reset --hard master &&
178 git checkout -b rebase_i_edit &&
179 test_commit one_rebase_i main.txt one &&
180 test_commit two_rebase_i main.txt two &&
181 test_commit three_rebase_i main.txt three &&
182 FAKE_LINES="1 edit 2" &&
183 export FAKE_LINES &&
184 test_when_finished "git rebase --abort" &&
185 git rebase -i HEAD~2 &&
186 cat >expected <<-\EOF &&
187 # Not currently on any branch.
188 # You are currently editing a commit during a rebase.
189 # (use "git commit --amend" to amend the current commit)
190 # (use "git rebase --continue" once you are satisfied with your changes)
192 nothing to commit (use -u to show untracked files)
194 git status --untracked-files=no >actual &&
195 test_i18ncmp expected actual
199 test_expect_success 'prepare am_session' '
200 git reset --hard master &&
201 git checkout -b am_session &&
202 test_commit one_am one.txt "one" &&
203 test_commit two_am two.txt "two" &&
204 test_commit three_am three.txt "three"
208 test_expect_success 'status in an am session: file already exists' '
209 git checkout -b am_already_exists &&
210 test_when_finished "rm Maildir/* && git am --abort" &&
211 git format-patch -1 -oMaildir &&
212 test_must_fail git am Maildir/*.patch &&
213 cat >expected <<-\EOF &&
214 # On branch am_already_exists
215 # You are in the middle of an am session.
216 # (fix conflicts and then run "git am --resolved")
217 # (use "git am --skip" to skip this patch)
218 # (use "git am --abort" to restore the original branch)
220 nothing to commit (use -u to show untracked files)
222 git status --untracked-files=no >actual &&
223 test_i18ncmp expected actual
227 test_expect_success 'status in an am session: file does not exist' '
228 git reset --hard am_session &&
229 git checkout -b am_not_exists &&
230 git rm three.txt &&
231 git commit -m "delete three.txt" &&
232 test_when_finished "rm Maildir/* && git am --abort" &&
233 git format-patch -1 -oMaildir &&
234 test_must_fail git am Maildir/*.patch &&
235 cat >expected <<-\EOF &&
236 # On branch am_not_exists
237 # You are in the middle of an am session.
238 # (fix conflicts and then run "git am --resolved")
239 # (use "git am --skip" to skip this patch)
240 # (use "git am --abort" to restore the original branch)
242 nothing to commit (use -u to show untracked files)
244 git status --untracked-files=no >actual &&
245 test_i18ncmp expected actual
249 test_expect_success 'status in an am session: empty patch' '
250 git reset --hard am_session &&
251 git checkout -b am_empty &&
252 test_when_finished "rm Maildir/* && git am --abort" &&
253 git format-patch -3 -oMaildir &&
254 git rm one.txt two.txt three.txt &&
255 git commit -m "delete all am_empty" &&
256 echo error >Maildir/0002-two_am.patch &&
257 test_must_fail git am Maildir/*.patch &&
258 cat >expected <<-\EOF &&
259 # On branch am_empty
260 # You are in the middle of an am session.
261 # The current patch is empty.
262 # (use "git am --skip" to skip this patch)
263 # (use "git am --abort" to restore the original branch)
265 nothing to commit (use -u to show untracked files)
267 git status --untracked-files=no >actual &&
268 test_i18ncmp expected actual
272 test_expect_success 'status when bisecting' '
273 git reset --hard master &&
274 git checkout -b bisect &&
275 test_commit one_bisect main.txt one &&
276 test_commit two_bisect main.txt two &&
277 test_commit three_bisect main.txt three &&
278 test_when_finished "git bisect reset" &&
279 git bisect start &&
280 git bisect bad &&
281 git bisect good one_bisect &&
282 cat >expected <<-\EOF &&
283 # Not currently on any branch.
284 # You are currently bisecting.
285 # (use "git bisect reset" to get back to the original branch)
287 nothing to commit (use -u to show untracked files)
289 git status --untracked-files=no >actual &&
290 test_i18ncmp expected actual
294 test_expect_success 'status when rebase conflicts with statushints disabled' '
295 git reset --hard master &&
296 git checkout -b statushints_disabled &&
297 test_when_finished "git config --local advice.statushints true" &&
298 git config --local advice.statushints false &&
299 test_commit one_statushints main.txt one &&
300 test_commit two_statushints main.txt two &&
301 test_commit three_statushints main.txt three &&
302 test_when_finished "git rebase --abort" &&
303 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
304 cat >expected <<-\EOF &&
305 # Not currently on any branch.
306 # You are currently rebasing.
308 # Unmerged paths:
309 # both modified: main.txt
311 no changes added to commit
313 git status --untracked-files=no >actual &&
314 test_i18ncmp expected actual
318 test_expect_success 'prepare for cherry-pick conflicts' '
319 git reset --hard master &&
320 git checkout -b cherry_branch &&
321 test_commit one_cherry main.txt one &&
322 test_commit two_cherries main.txt two &&
323 git checkout -b cherry_branch_second &&
324 test_commit second_cherry main.txt second &&
325 git checkout cherry_branch &&
326 test_commit three_cherries main.txt three
330 test_expect_success 'status when cherry-picking before resolving conflicts' '
331 test_when_finished "git cherry-pick --abort" &&
332 test_must_fail git cherry-pick cherry_branch_second &&
333 cat >expected <<-\EOF &&
334 # On branch cherry_branch
335 # You are currently cherry-picking.
336 # (fix conflicts and run "git commit")
338 # Unmerged paths:
339 # (use "git add/rm <file>..." as appropriate to mark resolution)
341 # both modified: main.txt
343 no changes added to commit (use "git add" and/or "git commit -a")
345 git status --untracked-files=no >actual &&
346 test_i18ncmp expected actual
350 test_expect_success 'status when cherry-picking after resolving conflicts' '
351 git reset --hard cherry_branch &&
352 test_when_finished "git cherry-pick --abort" &&
353 test_must_fail git cherry-pick cherry_branch_second &&
354 echo end >main.txt &&
355 git add main.txt &&
356 cat >expected <<-\EOF &&
357 # On branch cherry_branch
358 # You are currently cherry-picking.
359 # (all conflicts fixed: run "git commit")
361 # Changes to be committed:
363 # modified: main.txt
365 # Untracked files not listed (use -u option to show untracked files)
367 git status --untracked-files=no >actual &&
368 test_i18ncmp expected actual
372 test_done