]> git.ipfire.org Git - thirdparty/git.git/blame - t/t9903-bash-prompt.sh
Merge branch 'maint-1.9' into maint-2.0
[thirdparty/git.git] / t / t9903-bash-prompt.sh
CommitLineData
963c0407
SG
1#!/bin/sh
2#
3# Copyright (c) 2012 SZEDER Gábor
4#
5
6test_description='test git-specific bash prompt functions'
7
8. ./lib-bash.sh
9
af31a456 10. "$GIT_BUILD_DIR/contrib/completion/git-prompt.sh"
963c0407
SG
11
12actual="$TRASH_DIRECTORY/actual"
1572e18e
EA
13c_red='\\[\\e[31m\\]'
14c_green='\\[\\e[32m\\]'
15c_lblue='\\[\\e[1;34m\\]'
16c_clear='\\[\\e[0m\\]'
963c0407
SG
17
18test_expect_success 'setup for prompt tests' '
963c0407 19 git init otherrepo &&
4fe00b4f 20 echo 1 >file &&
963c0407
SG
21 git add file &&
22 test_tick &&
23 git commit -m initial &&
24 git tag -a -m msg1 t1 &&
25 git checkout -b b1 &&
4fe00b4f 26 echo 2 >file &&
963c0407 27 git commit -m "second b1" file &&
4fe00b4f 28 echo 3 >file &&
963c0407
SG
29 git commit -m "third b1" file &&
30 git tag -a -m msg2 t2 &&
31 git checkout -b b2 master &&
4fe00b4f 32 echo 0 >file &&
963c0407 33 git commit -m "second b2" file &&
4fe00b4f 34 echo 00 >file &&
b71dc3e1 35 git commit -m "another b2" file &&
4fe00b4f 36 echo 000 >file &&
b71dc3e1 37 git commit -m "yet another b2" file &&
963c0407
SG
38 git checkout master
39'
40
963c0407 41test_expect_success 'prompt - branch name' '
4fe00b4f
SG
42 printf " (master)" >expected &&
43 __git_ps1 >"$actual" &&
963c0407
SG
44 test_cmp expected "$actual"
45'
46
868dc1ac
SG
47test_expect_success SYMLINKS 'prompt - branch name - symlink symref' '
48 printf " (master)" >expected &&
49 test_when_finished "git checkout master" &&
50 test_config core.preferSymlinkRefs true &&
51 git checkout master &&
52 __git_ps1 >"$actual" &&
53 test_cmp expected "$actual"
54'
55
e3e0b937
SG
56test_expect_success 'prompt - unborn branch' '
57 printf " (unborn)" >expected &&
58 git checkout --orphan unborn &&
59 test_when_finished "git checkout master" &&
60 __git_ps1 >"$actual" &&
61 test_cmp expected "$actual"
62'
63
a4889e64
SG
64repo_with_newline='repo
65with
66newline'
67
68if mkdir "$repo_with_newline" 2>/dev/null
69then
70 test_set_prereq FUNNYNAMES
71else
72 say 'Your filesystem does not allow newlines in filenames.'
73fi
74
75test_expect_success FUNNYNAMES 'prompt - with newline in path' '
76 printf " (master)" >expected &&
77 git init "$repo_with_newline" &&
78 test_when_finished "rm -rf \"$repo_with_newline\"" &&
79 mkdir "$repo_with_newline"/subdir &&
80 (
81 cd "$repo_with_newline/subdir" &&
82 __git_ps1 >"$actual"
83 ) &&
84 test_cmp expected "$actual"
85'
86
963c0407 87test_expect_success 'prompt - detached head' '
e8f21caf
SG
88 printf " ((%s...))" $(git log -1 --format="%h" --abbrev=13 b1^) >expected &&
89 test_config core.abbrev 13 &&
963c0407
SG
90 git checkout b1^ &&
91 test_when_finished "git checkout master" &&
4fe00b4f 92 __git_ps1 >"$actual" &&
963c0407
SG
93 test_cmp expected "$actual"
94'
95
96test_expect_success 'prompt - describe detached head - contains' '
4fe00b4f 97 printf " ((t2~1))" >expected &&
963c0407
SG
98 git checkout b1^ &&
99 test_when_finished "git checkout master" &&
100 (
101 GIT_PS1_DESCRIBE_STYLE=contains &&
4fe00b4f 102 __git_ps1 >"$actual"
963c0407
SG
103 ) &&
104 test_cmp expected "$actual"
105'
106
107test_expect_success 'prompt - describe detached head - branch' '
4fe00b4f 108 printf " ((b1~1))" >expected &&
963c0407
SG
109 git checkout b1^ &&
110 test_when_finished "git checkout master" &&
111 (
112 GIT_PS1_DESCRIBE_STYLE=branch &&
4fe00b4f 113 __git_ps1 >"$actual"
963c0407
SG
114 ) &&
115 test_cmp expected "$actual"
116'
117
118test_expect_success 'prompt - describe detached head - describe' '
4fe00b4f 119 printf " ((t1-1-g%s))" $(git log -1 --format="%h" b1^) >expected &&
963c0407
SG
120 git checkout b1^ &&
121 test_when_finished "git checkout master" &&
122 (
123 GIT_PS1_DESCRIBE_STYLE=describe &&
4fe00b4f 124 __git_ps1 >"$actual"
963c0407
SG
125 ) &&
126 test_cmp expected "$actual"
127'
128
129test_expect_success 'prompt - describe detached head - default' '
4fe00b4f 130 printf " ((t2))" >expected &&
963c0407
SG
131 git checkout --detach b1 &&
132 test_when_finished "git checkout master" &&
4fe00b4f 133 __git_ps1 >"$actual" &&
963c0407
SG
134 test_cmp expected "$actual"
135'
136
137test_expect_success 'prompt - inside .git directory' '
4fe00b4f 138 printf " (GIT_DIR!)" >expected &&
963c0407
SG
139 (
140 cd .git &&
4fe00b4f 141 __git_ps1 >"$actual"
963c0407
SG
142 ) &&
143 test_cmp expected "$actual"
144'
145
146test_expect_success 'prompt - deep inside .git directory' '
4fe00b4f 147 printf " (GIT_DIR!)" >expected &&
963c0407
SG
148 (
149 cd .git/refs/heads &&
4fe00b4f 150 __git_ps1 >"$actual"
963c0407
SG
151 ) &&
152 test_cmp expected "$actual"
153'
154
155test_expect_success 'prompt - inside bare repository' '
4fe00b4f 156 printf " (BARE:master)" >expected &&
963c0407
SG
157 git init --bare bare.git &&
158 test_when_finished "rm -rf bare.git" &&
159 (
160 cd bare.git &&
4fe00b4f 161 __git_ps1 >"$actual"
963c0407
SG
162 ) &&
163 test_cmp expected "$actual"
164'
165
166test_expect_success 'prompt - interactive rebase' '
4fe00b4f 167 printf " (b1|REBASE-i 2/3)" >expected
7412290c
SG
168 write_script fake_editor.sh <<-\EOF &&
169 echo "exec echo" >"$1"
170 echo "edit $(git log -1 --format="%h")" >>"$1"
171 echo "exec echo" >>"$1"
172 EOF
963c0407 173 test_when_finished "rm -f fake_editor.sh" &&
963c0407
SG
174 test_set_editor "$TRASH_DIRECTORY/fake_editor.sh" &&
175 git checkout b1 &&
176 test_when_finished "git checkout master" &&
177 git rebase -i HEAD^ &&
178 test_when_finished "git rebase --abort"
4fe00b4f 179 __git_ps1 >"$actual" &&
963c0407
SG
180 test_cmp expected "$actual"
181'
182
183test_expect_success 'prompt - rebase merge' '
4fe00b4f 184 printf " (b2|REBASE-m 1/3)" >expected &&
963c0407
SG
185 git checkout b2 &&
186 test_when_finished "git checkout master" &&
187 test_must_fail git rebase --merge b1 b2 &&
188 test_when_finished "git rebase --abort" &&
4fe00b4f 189 __git_ps1 >"$actual" &&
963c0407
SG
190 test_cmp expected "$actual"
191'
192
193test_expect_success 'prompt - rebase' '
4fe00b4f 194 printf " (b2|REBASE 1/3)" >expected &&
963c0407
SG
195 git checkout b2 &&
196 test_when_finished "git checkout master" &&
197 test_must_fail git rebase b1 b2 &&
198 test_when_finished "git rebase --abort" &&
4fe00b4f 199 __git_ps1 >"$actual" &&
963c0407
SG
200 test_cmp expected "$actual"
201'
202
203test_expect_success 'prompt - merge' '
4fe00b4f 204 printf " (b1|MERGING)" >expected &&
963c0407
SG
205 git checkout b1 &&
206 test_when_finished "git checkout master" &&
207 test_must_fail git merge b2 &&
208 test_when_finished "git reset --hard" &&
4fe00b4f 209 __git_ps1 >"$actual" &&
963c0407
SG
210 test_cmp expected "$actual"
211'
212
213test_expect_success 'prompt - cherry-pick' '
4fe00b4f 214 printf " (master|CHERRY-PICKING)" >expected &&
963c0407
SG
215 test_must_fail git cherry-pick b1 &&
216 test_when_finished "git reset --hard" &&
4fe00b4f 217 __git_ps1 >"$actual" &&
963c0407
SG
218 test_cmp expected "$actual"
219'
220
221test_expect_success 'prompt - bisect' '
4fe00b4f 222 printf " (master|BISECTING)" >expected &&
963c0407
SG
223 git bisect start &&
224 test_when_finished "git bisect reset" &&
4fe00b4f 225 __git_ps1 >"$actual" &&
963c0407
SG
226 test_cmp expected "$actual"
227'
228
229test_expect_success 'prompt - dirty status indicator - clean' '
4fe00b4f 230 printf " (master)" >expected &&
963c0407
SG
231 (
232 GIT_PS1_SHOWDIRTYSTATE=y &&
4fe00b4f 233 __git_ps1 >"$actual"
963c0407
SG
234 ) &&
235 test_cmp expected "$actual"
236'
237
238test_expect_success 'prompt - dirty status indicator - dirty worktree' '
4fe00b4f
SG
239 printf " (master *)" >expected &&
240 echo "dirty" >file &&
963c0407
SG
241 test_when_finished "git reset --hard" &&
242 (
243 GIT_PS1_SHOWDIRTYSTATE=y &&
4fe00b4f 244 __git_ps1 >"$actual"
963c0407
SG
245 ) &&
246 test_cmp expected "$actual"
247'
248
249test_expect_success 'prompt - dirty status indicator - dirty index' '
4fe00b4f
SG
250 printf " (master +)" >expected &&
251 echo "dirty" >file &&
963c0407
SG
252 test_when_finished "git reset --hard" &&
253 git add -u &&
254 (
255 GIT_PS1_SHOWDIRTYSTATE=y &&
4fe00b4f 256 __git_ps1 >"$actual"
963c0407
SG
257 ) &&
258 test_cmp expected "$actual"
259'
260
261test_expect_success 'prompt - dirty status indicator - dirty index and worktree' '
4fe00b4f
SG
262 printf " (master *+)" >expected &&
263 echo "dirty index" >file &&
963c0407
SG
264 test_when_finished "git reset --hard" &&
265 git add -u &&
4fe00b4f 266 echo "dirty worktree" >file &&
963c0407
SG
267 (
268 GIT_PS1_SHOWDIRTYSTATE=y &&
4fe00b4f 269 __git_ps1 >"$actual"
963c0407
SG
270 ) &&
271 test_cmp expected "$actual"
272'
273
274test_expect_success 'prompt - dirty status indicator - before root commit' '
4fe00b4f 275 printf " (master #)" >expected &&
963c0407
SG
276 (
277 GIT_PS1_SHOWDIRTYSTATE=y &&
278 cd otherrepo &&
4fe00b4f 279 __git_ps1 >"$actual"
963c0407
SG
280 ) &&
281 test_cmp expected "$actual"
282'
283
dc7e7bce 284test_expect_success 'prompt - dirty status indicator - shell variable unset with config disabled' '
4fe00b4f
SG
285 printf " (master)" >expected &&
286 echo "dirty" >file &&
963c0407
SG
287 test_when_finished "git reset --hard" &&
288 test_config bash.showDirtyState false &&
dc7e7bce
MEW
289 (
290 sane_unset GIT_PS1_SHOWDIRTYSTATE &&
4fe00b4f 291 __git_ps1 >"$actual"
dc7e7bce
MEW
292 ) &&
293 test_cmp expected "$actual"
294'
295
296test_expect_success 'prompt - dirty status indicator - shell variable unset with config enabled' '
4fe00b4f
SG
297 printf " (master)" >expected &&
298 echo "dirty" >file &&
dc7e7bce
MEW
299 test_when_finished "git reset --hard" &&
300 test_config bash.showDirtyState true &&
301 (
302 sane_unset GIT_PS1_SHOWDIRTYSTATE &&
4fe00b4f 303 __git_ps1 >"$actual"
dc7e7bce
MEW
304 ) &&
305 test_cmp expected "$actual"
306'
307
308test_expect_success 'prompt - dirty status indicator - shell variable set with config disabled' '
4fe00b4f
SG
309 printf " (master)" >expected &&
310 echo "dirty" >file &&
dc7e7bce
MEW
311 test_when_finished "git reset --hard" &&
312 test_config bash.showDirtyState false &&
313 (
314 GIT_PS1_SHOWDIRTYSTATE=y &&
4fe00b4f 315 __git_ps1 >"$actual"
dc7e7bce
MEW
316 ) &&
317 test_cmp expected "$actual"
318'
319
320test_expect_success 'prompt - dirty status indicator - shell variable set with config enabled' '
4fe00b4f
SG
321 printf " (master *)" >expected &&
322 echo "dirty" >file &&
dc7e7bce
MEW
323 test_when_finished "git reset --hard" &&
324 test_config bash.showDirtyState true &&
963c0407
SG
325 (
326 GIT_PS1_SHOWDIRTYSTATE=y &&
4fe00b4f 327 __git_ps1 >"$actual"
963c0407
SG
328 ) &&
329 test_cmp expected "$actual"
330'
331
332test_expect_success 'prompt - dirty status indicator - not shown inside .git directory' '
4fe00b4f
SG
333 printf " (GIT_DIR!)" >expected &&
334 echo "dirty" >file &&
963c0407
SG
335 test_when_finished "git reset --hard" &&
336 (
337 GIT_PS1_SHOWDIRTYSTATE=y &&
338 cd .git &&
4fe00b4f 339 __git_ps1 >"$actual"
963c0407
SG
340 ) &&
341 test_cmp expected "$actual"
342'
343
344test_expect_success 'prompt - stash status indicator - no stash' '
4fe00b4f 345 printf " (master)" >expected &&
963c0407
SG
346 (
347 GIT_PS1_SHOWSTASHSTATE=y &&
4fe00b4f 348 __git_ps1 >"$actual"
963c0407
SG
349 ) &&
350 test_cmp expected "$actual"
351'
352
353test_expect_success 'prompt - stash status indicator - stash' '
4fe00b4f 354 printf " (master $)" >expected &&
963c0407
SG
355 echo 2 >file &&
356 git stash &&
357 test_when_finished "git stash drop" &&
dd0b72cb 358 git pack-refs --all &&
963c0407
SG
359 (
360 GIT_PS1_SHOWSTASHSTATE=y &&
4fe00b4f 361 __git_ps1 >"$actual"
963c0407
SG
362 ) &&
363 test_cmp expected "$actual"
364'
365
366test_expect_success 'prompt - stash status indicator - not shown inside .git directory' '
4fe00b4f 367 printf " (GIT_DIR!)" >expected &&
963c0407
SG
368 echo 2 >file &&
369 git stash &&
370 test_when_finished "git stash drop" &&
371 (
372 GIT_PS1_SHOWSTASHSTATE=y &&
373 cd .git &&
4fe00b4f 374 __git_ps1 >"$actual"
963c0407
SG
375 ) &&
376 test_cmp expected "$actual"
377'
378
379test_expect_success 'prompt - untracked files status indicator - no untracked files' '
4fe00b4f 380 printf " (master)" >expected &&
963c0407
SG
381 (
382 GIT_PS1_SHOWUNTRACKEDFILES=y &&
383 cd otherrepo &&
4fe00b4f 384 __git_ps1 >"$actual"
963c0407
SG
385 ) &&
386 test_cmp expected "$actual"
387'
388
389test_expect_success 'prompt - untracked files status indicator - untracked files' '
4fe00b4f 390 printf " (master %%)" >expected &&
963c0407
SG
391 (
392 GIT_PS1_SHOWUNTRACKEDFILES=y &&
4fe00b4f 393 __git_ps1 >"$actual"
963c0407
SG
394 ) &&
395 test_cmp expected "$actual"
396'
397
58978e82 398test_expect_success 'prompt - untracked files status indicator - shell variable unset with config disabled' '
4fe00b4f 399 printf " (master)" >expected &&
58978e82
MEW
400 test_config bash.showUntrackedFiles false &&
401 (
402 sane_unset GIT_PS1_SHOWUNTRACKEDFILES &&
4fe00b4f 403 __git_ps1 >"$actual"
58978e82
MEW
404 ) &&
405 test_cmp expected "$actual"
406'
407
408test_expect_success 'prompt - untracked files status indicator - shell variable unset with config enabled' '
4fe00b4f 409 printf " (master)" >expected &&
58978e82
MEW
410 test_config bash.showUntrackedFiles true &&
411 (
412 sane_unset GIT_PS1_SHOWUNTRACKEDFILES &&
4fe00b4f 413 __git_ps1 >"$actual"
58978e82
MEW
414 ) &&
415 test_cmp expected "$actual"
416'
417
418test_expect_success 'prompt - untracked files status indicator - shell variable set with config disabled' '
4fe00b4f 419 printf " (master)" >expected &&
58978e82
MEW
420 test_config bash.showUntrackedFiles false &&
421 (
422 GIT_PS1_SHOWUNTRACKEDFILES=y &&
4fe00b4f 423 __git_ps1 >"$actual"
58978e82
MEW
424 ) &&
425 test_cmp expected "$actual"
426'
427
428test_expect_success 'prompt - untracked files status indicator - shell variable set with config enabled' '
4fe00b4f 429 printf " (master %%)" >expected &&
58978e82
MEW
430 test_config bash.showUntrackedFiles true &&
431 (
432 GIT_PS1_SHOWUNTRACKEDFILES=y &&
4fe00b4f 433 __git_ps1 >"$actual"
58978e82
MEW
434 ) &&
435 test_cmp expected "$actual"
436'
437
963c0407 438test_expect_success 'prompt - untracked files status indicator - not shown inside .git directory' '
4fe00b4f 439 printf " (GIT_DIR!)" >expected &&
963c0407
SG
440 (
441 GIT_PS1_SHOWUNTRACKEDFILES=y &&
442 cd .git &&
4fe00b4f 443 __git_ps1 >"$actual"
963c0407
SG
444 ) &&
445 test_cmp expected "$actual"
446'
447
448test_expect_success 'prompt - format string starting with dash' '
4fe00b4f
SG
449 printf -- "-master" >expected &&
450 __git_ps1 "-%s" >"$actual" &&
963c0407
SG
451 test_cmp expected "$actual"
452'
453
1572e18e 454test_expect_success 'prompt - pc mode' '
8976500c 455 printf "BEFORE: (\${__git_ps1_branch_name}):AFTER\\nmaster" >expected &&
1572e18e
EA
456 printf "" >expected_output &&
457 (
458 __git_ps1 "BEFORE:" ":AFTER" >"$actual" &&
459 test_cmp expected_output "$actual" &&
8976500c 460 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
1572e18e
EA
461 ) &&
462 test_cmp expected "$actual"
463'
464
465test_expect_success 'prompt - bash color pc mode - branch name' '
8976500c 466 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nmaster" >expected &&
1572e18e
EA
467 (
468 GIT_PS1_SHOWCOLORHINTS=y &&
469 __git_ps1 "BEFORE:" ":AFTER" >"$actual"
8976500c 470 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
1572e18e
EA
471 ) &&
472 test_cmp expected "$actual"
473'
474
475test_expect_success 'prompt - bash color pc mode - detached head' '
8976500c 476 printf "BEFORE: (${c_red}\${__git_ps1_branch_name}${c_clear}):AFTER\\n(%s...)" $(git log -1 --format="%h" b1^) >expected &&
1572e18e
EA
477 git checkout b1^ &&
478 test_when_finished "git checkout master" &&
479 (
480 GIT_PS1_SHOWCOLORHINTS=y &&
481 __git_ps1 "BEFORE:" ":AFTER" &&
8976500c 482 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
1572e18e
EA
483 ) &&
484 test_cmp expected "$actual"
485'
486
487test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty worktree' '
8976500c 488 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_clear}):AFTER\\nmaster" >expected &&
1572e18e
EA
489 echo "dirty" >file &&
490 test_when_finished "git reset --hard" &&
491 (
492 GIT_PS1_SHOWDIRTYSTATE=y &&
493 GIT_PS1_SHOWCOLORHINTS=y &&
494 __git_ps1 "BEFORE:" ":AFTER" &&
8976500c 495 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
1572e18e
EA
496 ) &&
497 test_cmp expected "$actual"
498'
499
500test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index' '
8976500c 501 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}+${c_clear}):AFTER\\nmaster" >expected &&
1572e18e
EA
502 echo "dirty" >file &&
503 test_when_finished "git reset --hard" &&
504 git add -u &&
505 (
506 GIT_PS1_SHOWDIRTYSTATE=y &&
507 GIT_PS1_SHOWCOLORHINTS=y &&
508 __git_ps1 "BEFORE:" ":AFTER" &&
8976500c 509 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
1572e18e
EA
510 ) &&
511 test_cmp expected "$actual"
512'
513
514test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index and worktree' '
8976500c 515 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_green}+${c_clear}):AFTER\\nmaster" >expected &&
1572e18e
EA
516 echo "dirty index" >file &&
517 test_when_finished "git reset --hard" &&
518 git add -u &&
519 echo "dirty worktree" >file &&
520 (
521 GIT_PS1_SHOWCOLORHINTS=y &&
522 GIT_PS1_SHOWDIRTYSTATE=y &&
523 __git_ps1 "BEFORE:" ":AFTER" &&
8976500c 524 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
1572e18e
EA
525 ) &&
526 test_cmp expected "$actual"
527'
528
529test_expect_success 'prompt - bash color pc mode - dirty status indicator - before root commit' '
8976500c 530 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}#${c_clear}):AFTER\\nmaster" >expected &&
1572e18e
EA
531 (
532 GIT_PS1_SHOWDIRTYSTATE=y &&
533 GIT_PS1_SHOWCOLORHINTS=y &&
534 cd otherrepo &&
535 __git_ps1 "BEFORE:" ":AFTER" &&
8976500c 536 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
1572e18e
EA
537 ) &&
538 test_cmp expected "$actual"
539'
540
541test_expect_success 'prompt - bash color pc mode - inside .git directory' '
8976500c 542 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nGIT_DIR!" >expected &&
1572e18e
EA
543 echo "dirty" >file &&
544 test_when_finished "git reset --hard" &&
545 (
546 GIT_PS1_SHOWDIRTYSTATE=y &&
547 GIT_PS1_SHOWCOLORHINTS=y &&
548 cd .git &&
549 __git_ps1 "BEFORE:" ":AFTER" &&
8976500c 550 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
1572e18e
EA
551 ) &&
552 test_cmp expected "$actual"
553'
554
555test_expect_success 'prompt - bash color pc mode - stash status indicator' '
8976500c 556 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_lblue}\$${c_clear}):AFTER\\nmaster" >expected &&
1572e18e
EA
557 echo 2 >file &&
558 git stash &&
559 test_when_finished "git stash drop" &&
560 (
561 GIT_PS1_SHOWSTASHSTATE=y &&
562 GIT_PS1_SHOWCOLORHINTS=y &&
563 __git_ps1 "BEFORE:" ":AFTER" &&
8976500c 564 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
1572e18e
EA
565 ) &&
566 test_cmp expected "$actual"
567'
568
569test_expect_success 'prompt - bash color pc mode - untracked files status indicator' '
8976500c 570 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}%%${c_clear}):AFTER\\nmaster" >expected &&
1572e18e
EA
571 (
572 GIT_PS1_SHOWUNTRACKEDFILES=y &&
573 GIT_PS1_SHOWCOLORHINTS=y &&
574 __git_ps1 "BEFORE:" ":AFTER" &&
8976500c 575 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
1572e18e
EA
576 ) &&
577 test_cmp expected "$actual"
578'
579
f3bd62d0 580test_expect_success 'prompt - zsh color pc mode' '
1e4119c8 581 printf "BEFORE: (%%F{green}master%%f):AFTER" >expected &&
1572e18e
EA
582 (
583 ZSH_VERSION=5.0.0 &&
584 GIT_PS1_SHOWCOLORHINTS=y &&
1e4119c8
RH
585 __git_ps1 "BEFORE:" ":AFTER" &&
586 printf "%s" "$PS1" >"$actual"
1572e18e
EA
587 ) &&
588 test_cmp expected "$actual"
589'
590
963c0407 591test_done