packed-backend: rip out some now-unused code
[git.git] / t / t9903-bash-prompt.sh
blob97c9b32c2ecfa608f1e9c37c1c6402a1772e4187
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 test_have_prereq !MINGW && 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 " ((tags/t2~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 - orphan branch - clean' '
277 printf " (orphan #)" >expected &&
278 test_when_finished "git checkout master" &&
279 git checkout --orphan orphan &&
280 git reset --hard &&
282 GIT_PS1_SHOWDIRTYSTATE=y &&
283 __git_ps1 >"$actual"
284 ) &&
285 test_cmp expected "$actual"
288 test_expect_success 'prompt - dirty status indicator - orphan branch - dirty index' '
289 printf " (orphan +)" >expected &&
290 test_when_finished "git checkout master" &&
291 git checkout --orphan orphan &&
293 GIT_PS1_SHOWDIRTYSTATE=y &&
294 __git_ps1 >"$actual"
295 ) &&
296 test_cmp expected "$actual"
299 test_expect_success 'prompt - dirty status indicator - orphan branch - dirty index and worktree' '
300 printf " (orphan *+)" >expected &&
301 test_when_finished "git checkout master" &&
302 git checkout --orphan orphan &&
303 >file &&
305 GIT_PS1_SHOWDIRTYSTATE=y &&
306 __git_ps1 >"$actual"
307 ) &&
308 test_cmp expected "$actual"
311 test_expect_success 'prompt - dirty status indicator - shell variable unset with config disabled' '
312 printf " (master)" >expected &&
313 echo "dirty" >file &&
314 test_when_finished "git reset --hard" &&
315 test_config bash.showDirtyState false &&
317 sane_unset GIT_PS1_SHOWDIRTYSTATE &&
318 __git_ps1 >"$actual"
319 ) &&
320 test_cmp expected "$actual"
323 test_expect_success 'prompt - dirty status indicator - shell variable unset with config enabled' '
324 printf " (master)" >expected &&
325 echo "dirty" >file &&
326 test_when_finished "git reset --hard" &&
327 test_config bash.showDirtyState true &&
329 sane_unset GIT_PS1_SHOWDIRTYSTATE &&
330 __git_ps1 >"$actual"
331 ) &&
332 test_cmp expected "$actual"
335 test_expect_success 'prompt - dirty status indicator - shell variable set with config disabled' '
336 printf " (master)" >expected &&
337 echo "dirty" >file &&
338 test_when_finished "git reset --hard" &&
339 test_config bash.showDirtyState false &&
341 GIT_PS1_SHOWDIRTYSTATE=y &&
342 __git_ps1 >"$actual"
343 ) &&
344 test_cmp expected "$actual"
347 test_expect_success 'prompt - dirty status indicator - shell variable set with config enabled' '
348 printf " (master *)" >expected &&
349 echo "dirty" >file &&
350 test_when_finished "git reset --hard" &&
351 test_config bash.showDirtyState true &&
353 GIT_PS1_SHOWDIRTYSTATE=y &&
354 __git_ps1 >"$actual"
355 ) &&
356 test_cmp expected "$actual"
359 test_expect_success 'prompt - dirty status indicator - not shown inside .git directory' '
360 printf " (GIT_DIR!)" >expected &&
361 echo "dirty" >file &&
362 test_when_finished "git reset --hard" &&
364 GIT_PS1_SHOWDIRTYSTATE=y &&
365 cd .git &&
366 __git_ps1 >"$actual"
367 ) &&
368 test_cmp expected "$actual"
371 test_expect_success 'prompt - stash status indicator - no stash' '
372 printf " (master)" >expected &&
374 GIT_PS1_SHOWSTASHSTATE=y &&
375 __git_ps1 >"$actual"
376 ) &&
377 test_cmp expected "$actual"
380 test_expect_success 'prompt - stash status indicator - stash' '
381 printf " (master $)" >expected &&
382 echo 2 >file &&
383 git stash &&
384 test_when_finished "git stash drop" &&
385 git pack-refs --all &&
387 GIT_PS1_SHOWSTASHSTATE=y &&
388 __git_ps1 >"$actual"
389 ) &&
390 test_cmp expected "$actual"
393 test_expect_success 'prompt - stash status indicator - not shown inside .git directory' '
394 printf " (GIT_DIR!)" >expected &&
395 echo 2 >file &&
396 git stash &&
397 test_when_finished "git stash drop" &&
399 GIT_PS1_SHOWSTASHSTATE=y &&
400 cd .git &&
401 __git_ps1 >"$actual"
402 ) &&
403 test_cmp expected "$actual"
406 test_expect_success 'prompt - untracked files status indicator - no untracked files' '
407 printf " (master)" >expected &&
409 GIT_PS1_SHOWUNTRACKEDFILES=y &&
410 cd otherrepo &&
411 __git_ps1 >"$actual"
412 ) &&
413 test_cmp expected "$actual"
416 test_expect_success 'prompt - untracked files status indicator - untracked files' '
417 printf " (master %%)" >expected &&
419 GIT_PS1_SHOWUNTRACKEDFILES=y &&
420 __git_ps1 >"$actual"
421 ) &&
422 test_cmp expected "$actual"
425 test_expect_success 'prompt - untracked files status indicator - empty untracked dir' '
426 printf " (master)" >expected &&
427 mkdir otherrepo/untracked-dir &&
428 test_when_finished "rm -rf otherrepo/untracked-dir" &&
430 GIT_PS1_SHOWUNTRACKEDFILES=y &&
431 cd otherrepo &&
432 __git_ps1 >"$actual"
433 ) &&
434 test_cmp expected "$actual"
437 test_expect_success 'prompt - untracked files status indicator - non-empty untracked dir' '
438 printf " (master %%)" >expected &&
439 mkdir otherrepo/untracked-dir &&
440 test_when_finished "rm -rf otherrepo/untracked-dir" &&
441 >otherrepo/untracked-dir/untracked-file &&
443 GIT_PS1_SHOWUNTRACKEDFILES=y &&
444 cd otherrepo &&
445 __git_ps1 >"$actual"
446 ) &&
447 test_cmp expected "$actual"
450 test_expect_success 'prompt - untracked files status indicator - untracked files outside cwd' '
451 printf " (master %%)" >expected &&
453 mkdir -p ignored_dir &&
454 cd ignored_dir &&
455 GIT_PS1_SHOWUNTRACKEDFILES=y &&
456 __git_ps1 >"$actual"
457 ) &&
458 test_cmp expected "$actual"
461 test_expect_success 'prompt - untracked files status indicator - shell variable unset with config disabled' '
462 printf " (master)" >expected &&
463 test_config bash.showUntrackedFiles false &&
465 sane_unset GIT_PS1_SHOWUNTRACKEDFILES &&
466 __git_ps1 >"$actual"
467 ) &&
468 test_cmp expected "$actual"
471 test_expect_success 'prompt - untracked files status indicator - shell variable unset with config enabled' '
472 printf " (master)" >expected &&
473 test_config bash.showUntrackedFiles true &&
475 sane_unset GIT_PS1_SHOWUNTRACKEDFILES &&
476 __git_ps1 >"$actual"
477 ) &&
478 test_cmp expected "$actual"
481 test_expect_success 'prompt - untracked files status indicator - shell variable set with config disabled' '
482 printf " (master)" >expected &&
483 test_config bash.showUntrackedFiles false &&
485 GIT_PS1_SHOWUNTRACKEDFILES=y &&
486 __git_ps1 >"$actual"
487 ) &&
488 test_cmp expected "$actual"
491 test_expect_success 'prompt - untracked files status indicator - shell variable set with config enabled' '
492 printf " (master %%)" >expected &&
493 test_config bash.showUntrackedFiles true &&
495 GIT_PS1_SHOWUNTRACKEDFILES=y &&
496 __git_ps1 >"$actual"
497 ) &&
498 test_cmp expected "$actual"
501 test_expect_success 'prompt - untracked files status indicator - not shown inside .git directory' '
502 printf " (GIT_DIR!)" >expected &&
504 GIT_PS1_SHOWUNTRACKEDFILES=y &&
505 cd .git &&
506 __git_ps1 >"$actual"
507 ) &&
508 test_cmp expected "$actual"
511 test_expect_success 'prompt - format string starting with dash' '
512 printf -- "-master" >expected &&
513 __git_ps1 "-%s" >"$actual" &&
514 test_cmp expected "$actual"
517 test_expect_success 'prompt - pc mode' '
518 printf "BEFORE: (\${__git_ps1_branch_name}):AFTER\\nmaster" >expected &&
519 printf "" >expected_output &&
521 __git_ps1 "BEFORE:" ":AFTER" >"$actual" &&
522 test_cmp expected_output "$actual" &&
523 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
524 ) &&
525 test_cmp expected "$actual"
528 test_expect_success 'prompt - bash color pc mode - branch name' '
529 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nmaster" >expected &&
531 GIT_PS1_SHOWCOLORHINTS=y &&
532 __git_ps1 "BEFORE:" ":AFTER" >"$actual"
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 - detached head' '
539 printf "BEFORE: (${c_red}\${__git_ps1_branch_name}${c_clear}):AFTER\\n(%s...)" $(git log -1 --format="%h" b1^) >expected &&
540 git checkout b1^ &&
541 test_when_finished "git checkout master" &&
543 GIT_PS1_SHOWCOLORHINTS=y &&
544 __git_ps1 "BEFORE:" ":AFTER" &&
545 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
546 ) &&
547 test_cmp expected "$actual"
550 test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty worktree' '
551 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_clear}):AFTER\\nmaster" >expected &&
552 echo "dirty" >file &&
553 test_when_finished "git reset --hard" &&
555 GIT_PS1_SHOWDIRTYSTATE=y &&
556 GIT_PS1_SHOWCOLORHINTS=y &&
557 __git_ps1 "BEFORE:" ":AFTER" &&
558 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
559 ) &&
560 test_cmp expected "$actual"
563 test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index' '
564 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}+${c_clear}):AFTER\\nmaster" >expected &&
565 echo "dirty" >file &&
566 test_when_finished "git reset --hard" &&
567 git add -u &&
569 GIT_PS1_SHOWDIRTYSTATE=y &&
570 GIT_PS1_SHOWCOLORHINTS=y &&
571 __git_ps1 "BEFORE:" ":AFTER" &&
572 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
573 ) &&
574 test_cmp expected "$actual"
577 test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index and worktree' '
578 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_green}+${c_clear}):AFTER\\nmaster" >expected &&
579 echo "dirty index" >file &&
580 test_when_finished "git reset --hard" &&
581 git add -u &&
582 echo "dirty worktree" >file &&
584 GIT_PS1_SHOWCOLORHINTS=y &&
585 GIT_PS1_SHOWDIRTYSTATE=y &&
586 __git_ps1 "BEFORE:" ":AFTER" &&
587 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
588 ) &&
589 test_cmp expected "$actual"
592 test_expect_success 'prompt - bash color pc mode - dirty status indicator - before root commit' '
593 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}#${c_clear}):AFTER\\nmaster" >expected &&
595 GIT_PS1_SHOWDIRTYSTATE=y &&
596 GIT_PS1_SHOWCOLORHINTS=y &&
597 cd otherrepo &&
598 __git_ps1 "BEFORE:" ":AFTER" &&
599 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
600 ) &&
601 test_cmp expected "$actual"
604 test_expect_success 'prompt - bash color pc mode - inside .git directory' '
605 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nGIT_DIR!" >expected &&
606 echo "dirty" >file &&
607 test_when_finished "git reset --hard" &&
609 GIT_PS1_SHOWDIRTYSTATE=y &&
610 GIT_PS1_SHOWCOLORHINTS=y &&
611 cd .git &&
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 - bash color pc mode - stash status indicator' '
619 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_lblue}\$${c_clear}):AFTER\\nmaster" >expected &&
620 echo 2 >file &&
621 git stash &&
622 test_when_finished "git stash drop" &&
624 GIT_PS1_SHOWSTASHSTATE=y &&
625 GIT_PS1_SHOWCOLORHINTS=y &&
626 __git_ps1 "BEFORE:" ":AFTER" &&
627 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
628 ) &&
629 test_cmp expected "$actual"
632 test_expect_success 'prompt - bash color pc mode - untracked files status indicator' '
633 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}%%${c_clear}):AFTER\\nmaster" >expected &&
635 GIT_PS1_SHOWUNTRACKEDFILES=y &&
636 GIT_PS1_SHOWCOLORHINTS=y &&
637 __git_ps1 "BEFORE:" ":AFTER" &&
638 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
639 ) &&
640 test_cmp expected "$actual"
643 test_expect_success 'prompt - zsh color pc mode' '
644 printf "BEFORE: (%%F{green}master%%f):AFTER" >expected &&
646 ZSH_VERSION=5.0.0 &&
647 GIT_PS1_SHOWCOLORHINTS=y &&
648 __git_ps1 "BEFORE:" ":AFTER" &&
649 printf "%s" "$PS1" >"$actual"
650 ) &&
651 test_cmp expected "$actual"
654 test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled' '
655 printf " (master)" >expected &&
656 test_config bash.hideIfPwdIgnored false &&
658 cd ignored_dir &&
659 __git_ps1 >"$actual"
660 ) &&
661 test_cmp expected "$actual"
664 test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled, pc mode' '
665 printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected &&
666 test_config bash.hideIfPwdIgnored false &&
668 cd ignored_dir &&
669 __git_ps1 "BEFORE:" ":AFTER" &&
670 printf "%s" "$PS1" >"$actual"
671 ) &&
672 test_cmp expected "$actual"
675 test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset' '
676 printf " (master)" >expected &&
678 cd ignored_dir &&
679 __git_ps1 >"$actual"
680 ) &&
681 test_cmp expected "$actual"
684 test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset, pc mode' '
685 printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected &&
687 cd ignored_dir &&
688 __git_ps1 "BEFORE:" ":AFTER" &&
689 printf "%s" "$PS1" >"$actual"
690 ) &&
691 test_cmp expected "$actual"
694 test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled' '
695 printf " (master)" >expected &&
696 test_config bash.hideIfPwdIgnored false &&
698 cd ignored_dir &&
699 GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
700 __git_ps1 >"$actual"
701 ) &&
702 test_cmp expected "$actual"
705 test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled, pc mode' '
706 printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected &&
707 test_config bash.hideIfPwdIgnored false &&
709 cd ignored_dir &&
710 GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
711 __git_ps1 "BEFORE:" ":AFTER" &&
712 printf "%s" "$PS1" >"$actual"
713 ) &&
714 test_cmp expected "$actual"
717 test_expect_success 'prompt - hide if pwd ignored - env var set, config unset' '
718 printf "" >expected &&
720 cd ignored_dir &&
721 GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
722 __git_ps1 >"$actual"
723 ) &&
724 test_cmp expected "$actual"
727 test_expect_success 'prompt - hide if pwd ignored - env var set, config unset, pc mode' '
728 printf "BEFORE::AFTER" >expected &&
730 cd ignored_dir &&
731 GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
732 __git_ps1 "BEFORE:" ":AFTER" &&
733 printf "%s" "$PS1" >"$actual"
734 ) &&
735 test_cmp expected "$actual"
738 test_expect_success 'prompt - hide if pwd ignored - inside gitdir (stdout)' '
739 printf " (GIT_DIR!)" >expected &&
741 GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
742 cd .git &&
743 __git_ps1 >"$actual" 2>/dev/null
744 ) &&
745 test_cmp expected "$actual"
748 test_expect_success 'prompt - hide if pwd ignored - inside gitdir (stderr)' '
749 printf "" >expected &&
751 GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
752 cd .git &&
753 __git_ps1 >/dev/null 2>"$actual"
754 ) &&
755 test_cmp expected "$actual"
758 test_done