Merge branch 'master' of git://repo.or.cz/alt-git
[git/mingw.git] / t / t9903-bash-prompt.sh
blob6b68777b9804a86a9d6e0bef63b5073e895efcfe
1 #!/bin/sh
3 # Copyright (c) 2012 SZEDER Gábor
6 test_description='test git-specific bash prompt functions'
8 . ./lib-bash.sh
10 . "$GIT_BUILD_DIR/contrib/completion/git-prompt.sh"
12 actual="$TRASH_DIRECTORY/actual"
13 c_red='\\[\\e[31m\\]'
14 c_green='\\[\\e[32m\\]'
15 c_lblue='\\[\\e[1;34m\\]'
16 c_clear='\\[\\e[0m\\]'
18 test_expect_success 'setup for prompt tests' '
19 git init otherrepo &&
20 echo 1 >file &&
21 git add file &&
22 test_tick &&
23 git commit -m initial &&
24 git tag -a -m msg1 t1 &&
25 git checkout -b b1 &&
26 echo 2 >file &&
27 git commit -m "second b1" file &&
28 echo 3 >file &&
29 git commit -m "third b1" file &&
30 git tag -a -m msg2 t2 &&
31 git checkout -b b2 master &&
32 echo 0 >file &&
33 git commit -m "second b2" file &&
34 echo 00 >file &&
35 git commit -m "another b2" file &&
36 echo 000 >file &&
37 git commit -m "yet another b2" file &&
38 mkdir ignored_dir &&
39 echo "ignored_dir/" >>.gitignore &&
40 git checkout master
43 test_expect_success 'prompt - branch name' '
44 printf " (master)" >expected &&
45 __git_ps1 >"$actual" &&
46 test_cmp expected "$actual"
49 test_expect_success SYMLINKS 'prompt - branch name - symlink symref' '
50 printf " (master)" >expected &&
51 test_when_finished "git checkout master" &&
52 test_config core.preferSymlinkRefs true &&
53 git checkout master &&
54 __git_ps1 >"$actual" &&
55 test_cmp expected "$actual"
58 test_expect_success 'prompt - unborn branch' '
59 printf " (unborn)" >expected &&
60 git checkout --orphan unborn &&
61 test_when_finished "git checkout master" &&
62 __git_ps1 >"$actual" &&
63 test_cmp expected "$actual"
66 repo_with_newline='repo
67 with
68 newline'
70 if mkdir "$repo_with_newline" 2>/dev/null
71 then
72 test_set_prereq FUNNYNAMES
73 else
74 say 'Your filesystem does not allow newlines in filenames.'
77 test_expect_success FUNNYNAMES 'prompt - with newline in path' '
78 printf " (master)" >expected &&
79 git init "$repo_with_newline" &&
80 test_when_finished "rm -rf \"$repo_with_newline\"" &&
81 mkdir "$repo_with_newline"/subdir &&
83 cd "$repo_with_newline/subdir" &&
84 __git_ps1 >"$actual"
85 ) &&
86 test_cmp expected "$actual"
89 test_expect_success 'prompt - detached head' '
90 printf " ((%s...))" $(git log -1 --format="%h" --abbrev=13 b1^) >expected &&
91 test_config core.abbrev 13 &&
92 git checkout b1^ &&
93 test_when_finished "git checkout master" &&
94 __git_ps1 >"$actual" &&
95 test_cmp expected "$actual"
98 test_expect_success 'prompt - describe detached head - contains' '
99 printf " ((t2~1))" >expected &&
100 git checkout b1^ &&
101 test_when_finished "git checkout master" &&
103 GIT_PS1_DESCRIBE_STYLE=contains &&
104 __git_ps1 >"$actual"
105 ) &&
106 test_cmp expected "$actual"
109 test_expect_success 'prompt - describe detached head - branch' '
110 printf " ((b1~1))" >expected &&
111 git checkout b1^ &&
112 test_when_finished "git checkout master" &&
114 GIT_PS1_DESCRIBE_STYLE=branch &&
115 __git_ps1 >"$actual"
116 ) &&
117 test_cmp expected "$actual"
120 test_expect_success 'prompt - describe detached head - describe' '
121 printf " ((t1-1-g%s))" $(git log -1 --format="%h" b1^) >expected &&
122 git checkout b1^ &&
123 test_when_finished "git checkout master" &&
125 GIT_PS1_DESCRIBE_STYLE=describe &&
126 __git_ps1 >"$actual"
127 ) &&
128 test_cmp expected "$actual"
131 test_expect_success 'prompt - describe detached head - default' '
132 printf " ((t2))" >expected &&
133 git checkout --detach b1 &&
134 test_when_finished "git checkout master" &&
135 __git_ps1 >"$actual" &&
136 test_cmp expected "$actual"
139 test_expect_success 'prompt - inside .git directory' '
140 printf " (GIT_DIR!)" >expected &&
142 cd .git &&
143 __git_ps1 >"$actual"
144 ) &&
145 test_cmp expected "$actual"
148 test_expect_success 'prompt - deep inside .git directory' '
149 printf " (GIT_DIR!)" >expected &&
151 cd .git/refs/heads &&
152 __git_ps1 >"$actual"
153 ) &&
154 test_cmp expected "$actual"
157 test_expect_success 'prompt - inside bare repository' '
158 printf " (BARE:master)" >expected &&
159 git init --bare bare.git &&
160 test_when_finished "rm -rf bare.git" &&
162 cd bare.git &&
163 __git_ps1 >"$actual"
164 ) &&
165 test_cmp expected "$actual"
168 test_expect_success 'prompt - interactive rebase' '
169 printf " (b1|REBASE-i 2/3)" >expected &&
170 write_script fake_editor.sh <<-\EOF &&
171 echo "exec echo" >"$1"
172 echo "edit $(git log -1 --format="%h")" >>"$1"
173 echo "exec echo" >>"$1"
175 test_when_finished "rm -f fake_editor.sh" &&
176 test_set_editor "$TRASH_DIRECTORY/fake_editor.sh" &&
177 git checkout b1 &&
178 test_when_finished "git checkout master" &&
179 git rebase -i HEAD^ &&
180 test_when_finished "git rebase --abort"
181 __git_ps1 >"$actual" &&
182 test_cmp expected "$actual"
185 test_expect_success 'prompt - rebase merge' '
186 printf " (b2|REBASE-m 1/3)" >expected &&
187 git checkout b2 &&
188 test_when_finished "git checkout master" &&
189 test_must_fail git rebase --merge b1 b2 &&
190 test_when_finished "git rebase --abort" &&
191 __git_ps1 >"$actual" &&
192 test_cmp expected "$actual"
195 test_expect_success 'prompt - rebase' '
196 printf " (b2|REBASE 1/3)" >expected &&
197 git checkout b2 &&
198 test_when_finished "git checkout master" &&
199 test_must_fail git rebase b1 b2 &&
200 test_when_finished "git rebase --abort" &&
201 __git_ps1 >"$actual" &&
202 test_cmp expected "$actual"
205 test_expect_success 'prompt - merge' '
206 printf " (b1|MERGING)" >expected &&
207 git checkout b1 &&
208 test_when_finished "git checkout master" &&
209 test_must_fail git merge b2 &&
210 test_when_finished "git reset --hard" &&
211 __git_ps1 >"$actual" &&
212 test_cmp expected "$actual"
215 test_expect_success 'prompt - cherry-pick' '
216 printf " (master|CHERRY-PICKING)" >expected &&
217 test_must_fail git cherry-pick b1 &&
218 test_when_finished "git reset --hard" &&
219 __git_ps1 >"$actual" &&
220 test_cmp expected "$actual"
223 test_expect_success 'prompt - bisect' '
224 printf " (master|BISECTING)" >expected &&
225 git bisect start &&
226 test_when_finished "git bisect reset" &&
227 __git_ps1 >"$actual" &&
228 test_cmp expected "$actual"
231 test_expect_success 'prompt - dirty status indicator - clean' '
232 printf " (master)" >expected &&
234 GIT_PS1_SHOWDIRTYSTATE=y &&
235 __git_ps1 >"$actual"
236 ) &&
237 test_cmp expected "$actual"
240 test_expect_success 'prompt - dirty status indicator - dirty worktree' '
241 printf " (master *)" >expected &&
242 echo "dirty" >file &&
243 test_when_finished "git reset --hard" &&
245 GIT_PS1_SHOWDIRTYSTATE=y &&
246 __git_ps1 >"$actual"
247 ) &&
248 test_cmp expected "$actual"
251 test_expect_success 'prompt - dirty status indicator - dirty index' '
252 printf " (master +)" >expected &&
253 echo "dirty" >file &&
254 test_when_finished "git reset --hard" &&
255 git add -u &&
257 GIT_PS1_SHOWDIRTYSTATE=y &&
258 __git_ps1 >"$actual"
259 ) &&
260 test_cmp expected "$actual"
263 test_expect_success 'prompt - dirty status indicator - dirty index and worktree' '
264 printf " (master *+)" >expected &&
265 echo "dirty index" >file &&
266 test_when_finished "git reset --hard" &&
267 git add -u &&
268 echo "dirty worktree" >file &&
270 GIT_PS1_SHOWDIRTYSTATE=y &&
271 __git_ps1 >"$actual"
272 ) &&
273 test_cmp expected "$actual"
276 test_expect_success 'prompt - dirty status indicator - before root commit' '
277 printf " (master #)" >expected &&
279 GIT_PS1_SHOWDIRTYSTATE=y &&
280 cd otherrepo &&
281 __git_ps1 >"$actual"
282 ) &&
283 test_cmp expected "$actual"
286 test_expect_success 'prompt - dirty status indicator - shell variable unset with config disabled' '
287 printf " (master)" >expected &&
288 echo "dirty" >file &&
289 test_when_finished "git reset --hard" &&
290 test_config bash.showDirtyState false &&
292 sane_unset GIT_PS1_SHOWDIRTYSTATE &&
293 __git_ps1 >"$actual"
294 ) &&
295 test_cmp expected "$actual"
298 test_expect_success 'prompt - dirty status indicator - shell variable unset with config enabled' '
299 printf " (master)" >expected &&
300 echo "dirty" >file &&
301 test_when_finished "git reset --hard" &&
302 test_config bash.showDirtyState true &&
304 sane_unset GIT_PS1_SHOWDIRTYSTATE &&
305 __git_ps1 >"$actual"
306 ) &&
307 test_cmp expected "$actual"
310 test_expect_success 'prompt - dirty status indicator - shell variable set with config disabled' '
311 printf " (master)" >expected &&
312 echo "dirty" >file &&
313 test_when_finished "git reset --hard" &&
314 test_config bash.showDirtyState false &&
316 GIT_PS1_SHOWDIRTYSTATE=y &&
317 __git_ps1 >"$actual"
318 ) &&
319 test_cmp expected "$actual"
322 test_expect_success 'prompt - dirty status indicator - shell variable set with config enabled' '
323 printf " (master *)" >expected &&
324 echo "dirty" >file &&
325 test_when_finished "git reset --hard" &&
326 test_config bash.showDirtyState true &&
328 GIT_PS1_SHOWDIRTYSTATE=y &&
329 __git_ps1 >"$actual"
330 ) &&
331 test_cmp expected "$actual"
334 test_expect_success 'prompt - dirty status indicator - not shown inside .git directory' '
335 printf " (GIT_DIR!)" >expected &&
336 echo "dirty" >file &&
337 test_when_finished "git reset --hard" &&
339 GIT_PS1_SHOWDIRTYSTATE=y &&
340 cd .git &&
341 __git_ps1 >"$actual"
342 ) &&
343 test_cmp expected "$actual"
346 test_expect_success 'prompt - stash status indicator - no stash' '
347 printf " (master)" >expected &&
349 GIT_PS1_SHOWSTASHSTATE=y &&
350 __git_ps1 >"$actual"
351 ) &&
352 test_cmp expected "$actual"
355 test_expect_success 'prompt - stash status indicator - stash' '
356 printf " (master $)" >expected &&
357 echo 2 >file &&
358 git stash &&
359 test_when_finished "git stash drop" &&
360 git pack-refs --all &&
362 GIT_PS1_SHOWSTASHSTATE=y &&
363 __git_ps1 >"$actual"
364 ) &&
365 test_cmp expected "$actual"
368 test_expect_success 'prompt - stash status indicator - not shown inside .git directory' '
369 printf " (GIT_DIR!)" >expected &&
370 echo 2 >file &&
371 git stash &&
372 test_when_finished "git stash drop" &&
374 GIT_PS1_SHOWSTASHSTATE=y &&
375 cd .git &&
376 __git_ps1 >"$actual"
377 ) &&
378 test_cmp expected "$actual"
381 test_expect_success 'prompt - untracked files status indicator - no untracked files' '
382 printf " (master)" >expected &&
384 GIT_PS1_SHOWUNTRACKEDFILES=y &&
385 cd otherrepo &&
386 __git_ps1 >"$actual"
387 ) &&
388 test_cmp expected "$actual"
391 test_expect_success 'prompt - untracked files status indicator - untracked files' '
392 printf " (master %%)" >expected &&
394 GIT_PS1_SHOWUNTRACKEDFILES=y &&
395 __git_ps1 >"$actual"
396 ) &&
397 test_cmp expected "$actual"
400 test_expect_success 'prompt - untracked files status indicator - empty untracked dir' '
401 printf " (master)" >expected &&
402 mkdir otherrepo/untracked-dir &&
403 test_when_finished "rm -rf otherrepo/untracked-dir" &&
405 GIT_PS1_SHOWUNTRACKEDFILES=y &&
406 cd otherrepo &&
407 __git_ps1 >"$actual"
408 ) &&
409 test_cmp expected "$actual"
412 test_expect_success 'prompt - untracked files status indicator - non-empty untracked dir' '
413 printf " (master %%)" >expected &&
414 mkdir otherrepo/untracked-dir &&
415 test_when_finished "rm -rf otherrepo/untracked-dir" &&
416 >otherrepo/untracked-dir/untracked-file &&
418 GIT_PS1_SHOWUNTRACKEDFILES=y &&
419 cd otherrepo &&
420 __git_ps1 >"$actual"
421 ) &&
422 test_cmp expected "$actual"
425 test_expect_success 'prompt - untracked files status indicator - untracked files outside cwd' '
426 printf " (master %%)" >expected &&
428 mkdir -p ignored_dir &&
429 cd ignored_dir &&
430 GIT_PS1_SHOWUNTRACKEDFILES=y &&
431 __git_ps1 >"$actual"
432 ) &&
433 test_cmp expected "$actual"
436 test_expect_success 'prompt - untracked files status indicator - shell variable unset with config disabled' '
437 printf " (master)" >expected &&
438 test_config bash.showUntrackedFiles false &&
440 sane_unset GIT_PS1_SHOWUNTRACKEDFILES &&
441 __git_ps1 >"$actual"
442 ) &&
443 test_cmp expected "$actual"
446 test_expect_success 'prompt - untracked files status indicator - shell variable unset with config enabled' '
447 printf " (master)" >expected &&
448 test_config bash.showUntrackedFiles true &&
450 sane_unset GIT_PS1_SHOWUNTRACKEDFILES &&
451 __git_ps1 >"$actual"
452 ) &&
453 test_cmp expected "$actual"
456 test_expect_success 'prompt - untracked files status indicator - shell variable set with config disabled' '
457 printf " (master)" >expected &&
458 test_config bash.showUntrackedFiles false &&
460 GIT_PS1_SHOWUNTRACKEDFILES=y &&
461 __git_ps1 >"$actual"
462 ) &&
463 test_cmp expected "$actual"
466 test_expect_success 'prompt - untracked files status indicator - shell variable set with config enabled' '
467 printf " (master %%)" >expected &&
468 test_config bash.showUntrackedFiles true &&
470 GIT_PS1_SHOWUNTRACKEDFILES=y &&
471 __git_ps1 >"$actual"
472 ) &&
473 test_cmp expected "$actual"
476 test_expect_success 'prompt - untracked files status indicator - not shown inside .git directory' '
477 printf " (GIT_DIR!)" >expected &&
479 GIT_PS1_SHOWUNTRACKEDFILES=y &&
480 cd .git &&
481 __git_ps1 >"$actual"
482 ) &&
483 test_cmp expected "$actual"
486 test_expect_success 'prompt - format string starting with dash' '
487 printf -- "-master" >expected &&
488 __git_ps1 "-%s" >"$actual" &&
489 test_cmp expected "$actual"
492 test_expect_success 'prompt - pc mode' '
493 printf "BEFORE: (\${__git_ps1_branch_name}):AFTER\\nmaster" >expected &&
494 printf "" >expected_output &&
496 __git_ps1 "BEFORE:" ":AFTER" >"$actual" &&
497 test_cmp expected_output "$actual" &&
498 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
499 ) &&
500 test_cmp expected "$actual"
503 test_expect_success 'prompt - bash color pc mode - branch name' '
504 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nmaster" >expected &&
506 GIT_PS1_SHOWCOLORHINTS=y &&
507 __git_ps1 "BEFORE:" ":AFTER" >"$actual"
508 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
509 ) &&
510 test_cmp expected "$actual"
513 test_expect_success 'prompt - bash color pc mode - detached head' '
514 printf "BEFORE: (${c_red}\${__git_ps1_branch_name}${c_clear}):AFTER\\n(%s...)" $(git log -1 --format="%h" b1^) >expected &&
515 git checkout b1^ &&
516 test_when_finished "git checkout master" &&
518 GIT_PS1_SHOWCOLORHINTS=y &&
519 __git_ps1 "BEFORE:" ":AFTER" &&
520 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
521 ) &&
522 test_cmp expected "$actual"
525 test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty worktree' '
526 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_clear}):AFTER\\nmaster" >expected &&
527 echo "dirty" >file &&
528 test_when_finished "git reset --hard" &&
530 GIT_PS1_SHOWDIRTYSTATE=y &&
531 GIT_PS1_SHOWCOLORHINTS=y &&
532 __git_ps1 "BEFORE:" ":AFTER" &&
533 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
534 ) &&
535 test_cmp expected "$actual"
538 test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index' '
539 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}+${c_clear}):AFTER\\nmaster" >expected &&
540 echo "dirty" >file &&
541 test_when_finished "git reset --hard" &&
542 git add -u &&
544 GIT_PS1_SHOWDIRTYSTATE=y &&
545 GIT_PS1_SHOWCOLORHINTS=y &&
546 __git_ps1 "BEFORE:" ":AFTER" &&
547 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
548 ) &&
549 test_cmp expected "$actual"
552 test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index and worktree' '
553 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_green}+${c_clear}):AFTER\\nmaster" >expected &&
554 echo "dirty index" >file &&
555 test_when_finished "git reset --hard" &&
556 git add -u &&
557 echo "dirty worktree" >file &&
559 GIT_PS1_SHOWCOLORHINTS=y &&
560 GIT_PS1_SHOWDIRTYSTATE=y &&
561 __git_ps1 "BEFORE:" ":AFTER" &&
562 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
563 ) &&
564 test_cmp expected "$actual"
567 test_expect_success 'prompt - bash color pc mode - dirty status indicator - before root commit' '
568 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}#${c_clear}):AFTER\\nmaster" >expected &&
570 GIT_PS1_SHOWDIRTYSTATE=y &&
571 GIT_PS1_SHOWCOLORHINTS=y &&
572 cd otherrepo &&
573 __git_ps1 "BEFORE:" ":AFTER" &&
574 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
575 ) &&
576 test_cmp expected "$actual"
579 test_expect_success 'prompt - bash color pc mode - inside .git directory' '
580 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nGIT_DIR!" >expected &&
581 echo "dirty" >file &&
582 test_when_finished "git reset --hard" &&
584 GIT_PS1_SHOWDIRTYSTATE=y &&
585 GIT_PS1_SHOWCOLORHINTS=y &&
586 cd .git &&
587 __git_ps1 "BEFORE:" ":AFTER" &&
588 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
589 ) &&
590 test_cmp expected "$actual"
593 test_expect_success 'prompt - bash color pc mode - stash status indicator' '
594 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_lblue}\$${c_clear}):AFTER\\nmaster" >expected &&
595 echo 2 >file &&
596 git stash &&
597 test_when_finished "git stash drop" &&
599 GIT_PS1_SHOWSTASHSTATE=y &&
600 GIT_PS1_SHOWCOLORHINTS=y &&
601 __git_ps1 "BEFORE:" ":AFTER" &&
602 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
603 ) &&
604 test_cmp expected "$actual"
607 test_expect_success 'prompt - bash color pc mode - untracked files status indicator' '
608 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}%%${c_clear}):AFTER\\nmaster" >expected &&
610 GIT_PS1_SHOWUNTRACKEDFILES=y &&
611 GIT_PS1_SHOWCOLORHINTS=y &&
612 __git_ps1 "BEFORE:" ":AFTER" &&
613 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
614 ) &&
615 test_cmp expected "$actual"
618 test_expect_success 'prompt - zsh color pc mode' '
619 printf "BEFORE: (%%F{green}master%%f):AFTER" >expected &&
621 ZSH_VERSION=5.0.0 &&
622 GIT_PS1_SHOWCOLORHINTS=y &&
623 __git_ps1 "BEFORE:" ":AFTER" &&
624 printf "%s" "$PS1" >"$actual"
625 ) &&
626 test_cmp expected "$actual"
629 test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled' '
630 printf " (master)" >expected &&
631 test_config bash.hideIfPwdIgnored false &&
633 cd ignored_dir &&
634 __git_ps1 >"$actual"
635 ) &&
636 test_cmp expected "$actual"
639 test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled, pc mode' '
640 printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected &&
641 test_config bash.hideIfPwdIgnored false &&
643 cd ignored_dir &&
644 __git_ps1 "BEFORE:" ":AFTER" &&
645 printf "%s" "$PS1" >"$actual"
646 ) &&
647 test_cmp expected "$actual"
650 test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset' '
651 printf " (master)" >expected &&
653 cd ignored_dir &&
654 __git_ps1 >"$actual"
655 ) &&
656 test_cmp expected "$actual"
659 test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset, pc mode' '
660 printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected &&
662 cd ignored_dir &&
663 __git_ps1 "BEFORE:" ":AFTER" &&
664 printf "%s" "$PS1" >"$actual"
665 ) &&
666 test_cmp expected "$actual"
669 test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled' '
670 printf " (master)" >expected &&
671 test_config bash.hideIfPwdIgnored false &&
673 cd ignored_dir &&
674 GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
675 __git_ps1 >"$actual"
676 ) &&
677 test_cmp expected "$actual"
680 test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled, pc mode' '
681 printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected &&
682 test_config bash.hideIfPwdIgnored false &&
684 cd ignored_dir &&
685 GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
686 __git_ps1 "BEFORE:" ":AFTER" &&
687 printf "%s" "$PS1" >"$actual"
688 ) &&
689 test_cmp expected "$actual"
692 test_expect_success 'prompt - hide if pwd ignored - env var set, config unset' '
693 printf "" >expected &&
695 cd ignored_dir &&
696 GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
697 __git_ps1 >"$actual"
698 ) &&
699 test_cmp expected "$actual"
702 test_expect_success 'prompt - hide if pwd ignored - env var set, config unset, pc mode' '
703 printf "BEFORE::AFTER" >expected &&
705 cd ignored_dir &&
706 GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
707 __git_ps1 "BEFORE:" ":AFTER" &&
708 printf "%s" "$PS1" >"$actual"
709 ) &&
710 test_cmp expected "$actual"
713 test_expect_success 'prompt - hide if pwd ignored - inside gitdir (stdout)' '
714 printf " (GIT_DIR!)" >expected &&
716 GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
717 cd .git &&
718 __git_ps1 >"$actual" 2>/dev/null
719 ) &&
720 test_cmp expected "$actual"
723 test_expect_success 'prompt - hide if pwd ignored - inside gitdir (stderr)' '
724 printf "" >expected &&
726 GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
727 cd .git &&
728 __git_ps1 >/dev/null 2>"$actual"
729 ) &&
730 test_cmp expected "$actual"
733 test_done