diff options
Diffstat (limited to 't/t9903-bash-prompt.sh')
-rwxr-xr-x | t/t9903-bash-prompt.sh | 144 |
1 files changed, 143 insertions, 1 deletions
diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh index 9150984184..6b68777b98 100755 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@ -35,6 +35,8 @@ test_expect_success 'setup for prompt tests' ' git commit -m "another b2" file && echo 000 >file && git commit -m "yet another b2" file && + mkdir ignored_dir && + echo "ignored_dir/" >>.gitignore && git checkout master ' @@ -164,7 +166,7 @@ test_expect_success 'prompt - inside bare repository' ' ' test_expect_success 'prompt - interactive rebase' ' - printf " (b1|REBASE-i 2/3)" >expected + printf " (b1|REBASE-i 2/3)" >expected && write_script fake_editor.sh <<-\EOF && echo "exec echo" >"$1" echo "edit $(git log -1 --format="%h")" >>"$1" @@ -395,6 +397,42 @@ test_expect_success 'prompt - untracked files status indicator - untracked files test_cmp expected "$actual" ' +test_expect_success 'prompt - untracked files status indicator - empty untracked dir' ' + printf " (master)" >expected && + mkdir otherrepo/untracked-dir && + test_when_finished "rm -rf otherrepo/untracked-dir" && + ( + GIT_PS1_SHOWUNTRACKEDFILES=y && + cd otherrepo && + __git_ps1 >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - untracked files status indicator - non-empty untracked dir' ' + printf " (master %%)" >expected && + mkdir otherrepo/untracked-dir && + test_when_finished "rm -rf otherrepo/untracked-dir" && + >otherrepo/untracked-dir/untracked-file && + ( + GIT_PS1_SHOWUNTRACKEDFILES=y && + cd otherrepo && + __git_ps1 >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - untracked files status indicator - untracked files outside cwd' ' + printf " (master %%)" >expected && + ( + mkdir -p ignored_dir && + cd ignored_dir && + GIT_PS1_SHOWUNTRACKEDFILES=y && + __git_ps1 >"$actual" + ) && + test_cmp expected "$actual" +' + test_expect_success 'prompt - untracked files status indicator - shell variable unset with config disabled' ' printf " (master)" >expected && test_config bash.showUntrackedFiles false && @@ -588,4 +626,108 @@ test_expect_success 'prompt - zsh color pc mode' ' test_cmp expected "$actual" ' +test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled' ' + printf " (master)" >expected && + test_config bash.hideIfPwdIgnored false && + ( + cd ignored_dir && + __git_ps1 >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled, pc mode' ' + printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected && + test_config bash.hideIfPwdIgnored false && + ( + cd ignored_dir && + __git_ps1 "BEFORE:" ":AFTER" && + printf "%s" "$PS1" >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset' ' + printf " (master)" >expected && + ( + cd ignored_dir && + __git_ps1 >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset, pc mode' ' + printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected && + ( + cd ignored_dir && + __git_ps1 "BEFORE:" ":AFTER" && + printf "%s" "$PS1" >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled' ' + printf " (master)" >expected && + test_config bash.hideIfPwdIgnored false && + ( + cd ignored_dir && + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + __git_ps1 >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled, pc mode' ' + printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected && + test_config bash.hideIfPwdIgnored false && + ( + cd ignored_dir && + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + __git_ps1 "BEFORE:" ":AFTER" && + printf "%s" "$PS1" >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var set, config unset' ' + printf "" >expected && + ( + cd ignored_dir && + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + __git_ps1 >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var set, config unset, pc mode' ' + printf "BEFORE::AFTER" >expected && + ( + cd ignored_dir && + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + __git_ps1 "BEFORE:" ":AFTER" && + printf "%s" "$PS1" >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - inside gitdir (stdout)' ' + printf " (GIT_DIR!)" >expected && + ( + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + cd .git && + __git_ps1 >"$actual" 2>/dev/null + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - inside gitdir (stderr)' ' + printf "" >expected && + ( + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + cd .git && + __git_ps1 >/dev/null 2>"$actual" + ) && + test_cmp expected "$actual" +' + test_done |