Git fork
at reftables-rust 774 lines 21 kB view raw
1#!/bin/sh 2# 3# Copyright (c) 2012 SZEDER Gábor 4# 5 6test_description='test git-specific bash prompt functions' 7 8GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 9export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 10 11. ./lib-bash.sh 12 13. "$GIT_BUILD_DIR/contrib/completion/git-prompt.sh" 14 15actual="$TRASH_DIRECTORY/actual" 16c_red='\001\e[31m\002' 17c_green='\001\e[32m\002' 18c_lblue='\001\e[1;34m\002' 19c_clear='\001\e[0m\002' 20 21test_expect_success 'setup for prompt tests' ' 22 git init otherrepo && 23 echo 1 >file && 24 git add file && 25 test_tick && 26 git commit -m initial && 27 git tag -a -m msg1 t1 && 28 git checkout -b b1 && 29 echo 2 >file && 30 git commit -m "second b1" file && 31 echo 3 >file && 32 git commit -m "third b1" file && 33 git tag -a -m msg2 t2 && 34 git checkout -b b2 main && 35 echo 0 >file && 36 git commit -m "second b2" file && 37 echo 00 >file && 38 git commit -m "another b2" file && 39 echo 000 >file && 40 git commit -m "yet another b2" file && 41 mkdir ignored_dir && 42 echo "ignored_dir/" >>.gitignore && 43 git checkout main 44' 45 46test_expect_success 'prompt - branch name' ' 47 printf " (main)" >expected && 48 __git_ps1 >"$actual" && 49 test_cmp expected "$actual" 50' 51 52test_expect_success SYMLINKS 'prompt - branch name - symlink symref' ' 53 printf " (main)" >expected && 54 test_when_finished "git checkout main" && 55 test_config core.preferSymlinkRefs true && 56 git checkout main && 57 __git_ps1 >"$actual" && 58 test_cmp expected "$actual" 59' 60 61test_expect_success 'prompt - unborn branch' ' 62 printf " (unborn)" >expected && 63 git checkout --orphan unborn && 64 test_when_finished "git checkout main" && 65 __git_ps1 >"$actual" && 66 test_cmp expected "$actual" 67' 68 69test_expect_success FUNNYNAMES 'prompt - with newline in path' ' 70 repo_with_newline="repo 71with 72newline" && 73 mkdir "$repo_with_newline" && 74 printf " (main)" >expected && 75 git init "$repo_with_newline" && 76 test_when_finished "rm -rf \"$repo_with_newline\"" && 77 mkdir "$repo_with_newline"/subdir && 78 ( 79 cd "$repo_with_newline/subdir" && 80 __git_ps1 >"$actual" 81 ) && 82 test_cmp expected "$actual" 83' 84 85test_expect_success 'prompt - detached head' ' 86 printf " ((%s...))" $(git log -1 --format="%h" --abbrev=13 b1^) >expected && 87 test_config core.abbrev 13 && 88 git checkout b1^ && 89 test_when_finished "git checkout main" && 90 __git_ps1 >"$actual" && 91 test_cmp expected "$actual" 92' 93 94test_expect_success 'prompt - describe detached head - contains' ' 95 printf " ((t2~1))" >expected && 96 git checkout b1^ && 97 test_when_finished "git checkout main" && 98 ( 99 GIT_PS1_DESCRIBE_STYLE=contains && 100 __git_ps1 >"$actual" 101 ) && 102 test_cmp expected "$actual" 103' 104 105test_expect_success 'prompt - describe detached head - branch' ' 106 printf " ((tags/t2~1))" >expected && 107 git checkout b1^ && 108 test_when_finished "git checkout main" && 109 ( 110 GIT_PS1_DESCRIBE_STYLE=branch && 111 __git_ps1 >"$actual" 112 ) && 113 test_cmp expected "$actual" 114' 115 116test_expect_success 'prompt - describe detached head - describe' ' 117 printf " ((t1-1-g%s))" $(git log -1 --format="%h" b1^) >expected && 118 git checkout b1^ && 119 test_when_finished "git checkout main" && 120 ( 121 GIT_PS1_DESCRIBE_STYLE=describe && 122 __git_ps1 >"$actual" 123 ) && 124 test_cmp expected "$actual" 125' 126 127test_expect_success 'prompt - describe detached head - default' ' 128 printf " ((t2))" >expected && 129 git checkout --detach b1 && 130 test_when_finished "git checkout main" && 131 __git_ps1 >"$actual" && 132 test_cmp expected "$actual" 133' 134 135test_expect_success 'prompt - inside .git directory' ' 136 printf " (GIT_DIR!)" >expected && 137 ( 138 cd .git && 139 __git_ps1 >"$actual" 140 ) && 141 test_cmp expected "$actual" 142' 143 144test_expect_success 'prompt - deep inside .git directory' ' 145 printf " (GIT_DIR!)" >expected && 146 ( 147 cd .git/objects && 148 __git_ps1 >"$actual" 149 ) && 150 test_cmp expected "$actual" 151' 152 153test_expect_success 'prompt - inside bare repository' ' 154 printf " (BARE:main)" >expected && 155 git init --bare bare.git && 156 test_when_finished "rm -rf bare.git" && 157 ( 158 cd bare.git && 159 __git_ps1 >"$actual" 160 ) && 161 test_cmp expected "$actual" 162' 163 164test_expect_success 'prompt - interactive rebase' ' 165 printf " (b1|REBASE 2/3)" >expected && 166 write_script fake_editor.sh <<-\EOF && 167 echo "exec echo" >"$1" 168 echo "edit $(git log -1 --format="%h")" >>"$1" 169 echo "exec echo" >>"$1" 170 EOF 171 test_when_finished "rm -f fake_editor.sh" && 172 test_set_editor "$TRASH_DIRECTORY/fake_editor.sh" && 173 git checkout b1 && 174 test_when_finished "git checkout main" && 175 git rebase -i HEAD^ && 176 test_when_finished "git rebase --abort" && 177 __git_ps1 >"$actual" && 178 test_cmp expected "$actual" 179' 180 181test_expect_success 'prompt - rebase merge' ' 182 printf " (b2|REBASE 1/3)" >expected && 183 git checkout b2 && 184 test_when_finished "git checkout main" && 185 test_must_fail git rebase --merge b1 b2 && 186 test_when_finished "git rebase --abort" && 187 __git_ps1 >"$actual" && 188 test_cmp expected "$actual" 189' 190 191test_expect_success 'prompt - rebase am' ' 192 printf " (b2|REBASE 1/3)" >expected && 193 git checkout b2 && 194 test_when_finished "git checkout main" && 195 test_must_fail git rebase --apply b1 b2 && 196 test_when_finished "git rebase --abort" && 197 __git_ps1 >"$actual" && 198 test_cmp expected "$actual" 199' 200 201test_expect_success 'prompt - merge' ' 202 printf " (b1|MERGING)" >expected && 203 git checkout b1 && 204 test_when_finished "git checkout main" && 205 test_must_fail git merge b2 && 206 test_when_finished "git reset --hard" && 207 __git_ps1 >"$actual" && 208 test_cmp expected "$actual" 209' 210 211test_expect_success 'prompt - cherry-pick' ' 212 printf " (main|CHERRY-PICKING)" >expected && 213 test_must_fail git cherry-pick b1 b1^ && 214 test_when_finished "git cherry-pick --abort" && 215 __git_ps1 >"$actual" && 216 test_cmp expected "$actual" && 217 git reset --merge && 218 test_must_fail git rev-parse CHERRY_PICK_HEAD && 219 __git_ps1 >"$actual" && 220 test_cmp expected "$actual" 221' 222 223test_expect_success 'prompt - revert' ' 224 printf " (main|REVERTING)" >expected && 225 test_must_fail git revert b1^ b1 && 226 test_when_finished "git revert --abort" && 227 __git_ps1 >"$actual" && 228 test_cmp expected "$actual" && 229 git reset --merge && 230 test_must_fail git rev-parse REVERT_HEAD && 231 __git_ps1 >"$actual" && 232 test_cmp expected "$actual" 233' 234 235test_expect_success 'prompt - bisect' ' 236 printf " (main|BISECTING)" >expected && 237 git bisect start && 238 test_when_finished "git bisect reset" && 239 __git_ps1 >"$actual" && 240 test_cmp expected "$actual" 241' 242 243test_expect_success 'prompt - dirty status indicator - clean' ' 244 printf " (main)" >expected && 245 ( 246 GIT_PS1_SHOWDIRTYSTATE=y && 247 __git_ps1 >"$actual" 248 ) && 249 test_cmp expected "$actual" 250' 251 252test_expect_success 'prompt - dirty status indicator - dirty worktree' ' 253 printf " (main *)" >expected && 254 echo "dirty" >file && 255 test_when_finished "git reset --hard" && 256 ( 257 GIT_PS1_SHOWDIRTYSTATE=y && 258 __git_ps1 >"$actual" 259 ) && 260 test_cmp expected "$actual" 261' 262 263test_expect_success 'prompt - dirty status indicator - dirty index' ' 264 printf " (main +)" >expected && 265 echo "dirty" >file && 266 test_when_finished "git reset --hard" && 267 git add -u && 268 ( 269 GIT_PS1_SHOWDIRTYSTATE=y && 270 __git_ps1 >"$actual" 271 ) && 272 test_cmp expected "$actual" 273' 274 275test_expect_success 'prompt - dirty status indicator - dirty index and worktree' ' 276 printf " (main *+)" >expected && 277 echo "dirty index" >file && 278 test_when_finished "git reset --hard" && 279 git add -u && 280 echo "dirty worktree" >file && 281 ( 282 GIT_PS1_SHOWDIRTYSTATE=y && 283 __git_ps1 >"$actual" 284 ) && 285 test_cmp expected "$actual" 286' 287 288test_expect_success 'prompt - dirty status indicator - orphan branch - clean' ' 289 printf " (orphan #)" >expected && 290 test_when_finished "git checkout main" && 291 git checkout --orphan orphan && 292 git reset --hard && 293 ( 294 GIT_PS1_SHOWDIRTYSTATE=y && 295 __git_ps1 >"$actual" 296 ) && 297 test_cmp expected "$actual" 298' 299 300test_expect_success 'prompt - dirty status indicator - orphan branch - dirty index' ' 301 printf " (orphan +)" >expected && 302 test_when_finished "git checkout main" && 303 git checkout --orphan orphan && 304 ( 305 GIT_PS1_SHOWDIRTYSTATE=y && 306 __git_ps1 >"$actual" 307 ) && 308 test_cmp expected "$actual" 309' 310 311test_expect_success 'prompt - dirty status indicator - orphan branch - dirty index and worktree' ' 312 printf " (orphan *+)" >expected && 313 test_when_finished "git checkout main" && 314 git checkout --orphan orphan && 315 >file && 316 ( 317 GIT_PS1_SHOWDIRTYSTATE=y && 318 __git_ps1 >"$actual" 319 ) && 320 test_cmp expected "$actual" 321' 322 323test_expect_success 'prompt - dirty status indicator - shell variable unset with config disabled' ' 324 printf " (main)" >expected && 325 echo "dirty" >file && 326 test_when_finished "git reset --hard" && 327 test_config bash.showDirtyState false && 328 ( 329 sane_unset GIT_PS1_SHOWDIRTYSTATE && 330 __git_ps1 >"$actual" 331 ) && 332 test_cmp expected "$actual" 333' 334 335test_expect_success 'prompt - dirty status indicator - shell variable unset with config enabled' ' 336 printf " (main)" >expected && 337 echo "dirty" >file && 338 test_when_finished "git reset --hard" && 339 test_config bash.showDirtyState true && 340 ( 341 sane_unset GIT_PS1_SHOWDIRTYSTATE && 342 __git_ps1 >"$actual" 343 ) && 344 test_cmp expected "$actual" 345' 346 347test_expect_success 'prompt - dirty status indicator - shell variable set with config disabled' ' 348 printf " (main)" >expected && 349 echo "dirty" >file && 350 test_when_finished "git reset --hard" && 351 test_config bash.showDirtyState false && 352 ( 353 GIT_PS1_SHOWDIRTYSTATE=y && 354 __git_ps1 >"$actual" 355 ) && 356 test_cmp expected "$actual" 357' 358 359test_expect_success 'prompt - dirty status indicator - shell variable set with config enabled' ' 360 printf " (main *)" >expected && 361 echo "dirty" >file && 362 test_when_finished "git reset --hard" && 363 test_config bash.showDirtyState true && 364 ( 365 GIT_PS1_SHOWDIRTYSTATE=y && 366 __git_ps1 >"$actual" 367 ) && 368 test_cmp expected "$actual" 369' 370 371test_expect_success 'prompt - dirty status indicator - not shown inside .git directory' ' 372 printf " (GIT_DIR!)" >expected && 373 echo "dirty" >file && 374 test_when_finished "git reset --hard" && 375 ( 376 GIT_PS1_SHOWDIRTYSTATE=y && 377 cd .git && 378 __git_ps1 >"$actual" 379 ) && 380 test_cmp expected "$actual" 381' 382 383test_expect_success 'prompt - stash status indicator - no stash' ' 384 printf " (main)" >expected && 385 ( 386 GIT_PS1_SHOWSTASHSTATE=y && 387 __git_ps1 >"$actual" 388 ) && 389 test_cmp expected "$actual" 390' 391 392test_expect_success 'prompt - stash status indicator - stash' ' 393 printf " (main $)" >expected && 394 echo 2 >file && 395 git stash && 396 test_when_finished "git stash drop" && 397 git pack-refs --all && 398 ( 399 GIT_PS1_SHOWSTASHSTATE=y && 400 __git_ps1 >"$actual" 401 ) && 402 test_cmp expected "$actual" 403' 404 405test_expect_success 'prompt - stash status indicator - not shown inside .git directory' ' 406 printf " (GIT_DIR!)" >expected && 407 echo 2 >file && 408 git stash && 409 test_when_finished "git stash drop" && 410 ( 411 GIT_PS1_SHOWSTASHSTATE=y && 412 cd .git && 413 __git_ps1 >"$actual" 414 ) && 415 test_cmp expected "$actual" 416' 417 418test_expect_success 'prompt - untracked files status indicator - no untracked files' ' 419 printf " (main)" >expected && 420 ( 421 GIT_PS1_SHOWUNTRACKEDFILES=y && 422 cd otherrepo && 423 __git_ps1 >"$actual" 424 ) && 425 test_cmp expected "$actual" 426' 427 428test_expect_success 'prompt - untracked files status indicator - untracked files' ' 429 printf " (main %%)" >expected && 430 ( 431 GIT_PS1_SHOWUNTRACKEDFILES=y && 432 __git_ps1 >"$actual" 433 ) && 434 test_cmp expected "$actual" 435' 436 437test_expect_success 'prompt - untracked files status indicator - empty untracked dir' ' 438 printf " (main)" >expected && 439 mkdir otherrepo/untracked-dir && 440 test_when_finished "rm -rf otherrepo/untracked-dir" && 441 ( 442 GIT_PS1_SHOWUNTRACKEDFILES=y && 443 cd otherrepo && 444 __git_ps1 >"$actual" 445 ) && 446 test_cmp expected "$actual" 447' 448 449test_expect_success 'prompt - untracked files status indicator - non-empty untracked dir' ' 450 printf " (main %%)" >expected && 451 mkdir otherrepo/untracked-dir && 452 test_when_finished "rm -rf otherrepo/untracked-dir" && 453 >otherrepo/untracked-dir/untracked-file && 454 ( 455 GIT_PS1_SHOWUNTRACKEDFILES=y && 456 cd otherrepo && 457 __git_ps1 >"$actual" 458 ) && 459 test_cmp expected "$actual" 460' 461 462test_expect_success 'prompt - untracked files status indicator - untracked files outside cwd' ' 463 printf " (main %%)" >expected && 464 ( 465 mkdir -p ignored_dir && 466 cd ignored_dir && 467 GIT_PS1_SHOWUNTRACKEDFILES=y && 468 __git_ps1 >"$actual" 469 ) && 470 test_cmp expected "$actual" 471' 472 473test_expect_success 'prompt - untracked files status indicator - shell variable unset with config disabled' ' 474 printf " (main)" >expected && 475 test_config bash.showUntrackedFiles false && 476 ( 477 sane_unset GIT_PS1_SHOWUNTRACKEDFILES && 478 __git_ps1 >"$actual" 479 ) && 480 test_cmp expected "$actual" 481' 482 483test_expect_success 'prompt - untracked files status indicator - shell variable unset with config enabled' ' 484 printf " (main)" >expected && 485 test_config bash.showUntrackedFiles true && 486 ( 487 sane_unset GIT_PS1_SHOWUNTRACKEDFILES && 488 __git_ps1 >"$actual" 489 ) && 490 test_cmp expected "$actual" 491' 492 493test_expect_success 'prompt - untracked files status indicator - shell variable set with config disabled' ' 494 printf " (main)" >expected && 495 test_config bash.showUntrackedFiles false && 496 ( 497 GIT_PS1_SHOWUNTRACKEDFILES=y && 498 __git_ps1 >"$actual" 499 ) && 500 test_cmp expected "$actual" 501' 502 503test_expect_success 'prompt - untracked files status indicator - shell variable set with config enabled' ' 504 printf " (main %%)" >expected && 505 test_config bash.showUntrackedFiles true && 506 ( 507 GIT_PS1_SHOWUNTRACKEDFILES=y && 508 __git_ps1 >"$actual" 509 ) && 510 test_cmp expected "$actual" 511' 512 513test_expect_success 'prompt - untracked files status indicator - not shown inside .git directory' ' 514 printf " (GIT_DIR!)" >expected && 515 ( 516 GIT_PS1_SHOWUNTRACKEDFILES=y && 517 cd .git && 518 __git_ps1 >"$actual" 519 ) && 520 test_cmp expected "$actual" 521' 522 523test_expect_success 'prompt - format string starting with dash' ' 524 printf -- "-main" >expected && 525 __git_ps1 "-%s" >"$actual" && 526 test_cmp expected "$actual" 527' 528 529test_expect_success 'prompt - pc mode' ' 530 printf "BEFORE: (\${__git_ps1_branch_name}):AFTER\\nmain" >expected && 531 ( 532 __git_ps1 "BEFORE:" ":AFTER" >"$actual" && 533 test_must_be_empty "$actual" && 534 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual" 535 ) && 536 test_cmp expected "$actual" 537' 538 539test_expect_success 'prompt - bash color pc mode - branch name' ' 540 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nmain" >expected && 541 ( 542 GIT_PS1_SHOWCOLORHINTS=y && 543 __git_ps1 "BEFORE:" ":AFTER" >"$actual" && 544 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual" 545 ) && 546 test_cmp expected "$actual" 547' 548 549test_expect_success 'prompt - bash color pc mode - detached head' ' 550 printf "BEFORE: (${c_red}\${__git_ps1_branch_name}${c_clear}):AFTER\\n(%s...)" $(git log -1 --format="%h" b1^) >expected && 551 git checkout b1^ && 552 test_when_finished "git checkout main" && 553 ( 554 GIT_PS1_SHOWCOLORHINTS=y && 555 __git_ps1 "BEFORE:" ":AFTER" && 556 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual" 557 ) && 558 test_cmp expected "$actual" 559' 560 561test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty worktree' ' 562 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_clear}):AFTER\\nmain" >expected && 563 echo "dirty" >file && 564 test_when_finished "git reset --hard" && 565 ( 566 GIT_PS1_SHOWDIRTYSTATE=y && 567 GIT_PS1_SHOWCOLORHINTS=y && 568 __git_ps1 "BEFORE:" ":AFTER" && 569 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual" 570 ) && 571 test_cmp expected "$actual" 572' 573 574test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index' ' 575 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}+${c_clear}):AFTER\\nmain" >expected && 576 echo "dirty" >file && 577 test_when_finished "git reset --hard" && 578 git add -u && 579 ( 580 GIT_PS1_SHOWDIRTYSTATE=y && 581 GIT_PS1_SHOWCOLORHINTS=y && 582 __git_ps1 "BEFORE:" ":AFTER" && 583 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual" 584 ) && 585 test_cmp expected "$actual" 586' 587 588test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index and worktree' ' 589 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_clear}${c_green}+${c_clear}):AFTER\\nmain" >expected && 590 echo "dirty index" >file && 591 test_when_finished "git reset --hard" && 592 git add -u && 593 echo "dirty worktree" >file && 594 ( 595 GIT_PS1_SHOWCOLORHINTS=y && 596 GIT_PS1_SHOWDIRTYSTATE=y && 597 __git_ps1 "BEFORE:" ":AFTER" && 598 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual" 599 ) && 600 test_cmp expected "$actual" 601' 602 603test_expect_success 'prompt - bash color pc mode - dirty status indicator - before root commit' ' 604 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}#${c_clear}):AFTER\\nmain" >expected && 605 ( 606 GIT_PS1_SHOWDIRTYSTATE=y && 607 GIT_PS1_SHOWCOLORHINTS=y && 608 cd otherrepo && 609 __git_ps1 "BEFORE:" ":AFTER" && 610 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual" 611 ) && 612 test_cmp expected "$actual" 613' 614 615test_expect_success 'prompt - bash color pc mode - inside .git directory' ' 616 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nGIT_DIR!" >expected && 617 echo "dirty" >file && 618 test_when_finished "git reset --hard" && 619 ( 620 GIT_PS1_SHOWDIRTYSTATE=y && 621 GIT_PS1_SHOWCOLORHINTS=y && 622 cd .git && 623 __git_ps1 "BEFORE:" ":AFTER" && 624 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual" 625 ) && 626 test_cmp expected "$actual" 627' 628 629test_expect_success 'prompt - bash color pc mode - stash status indicator' ' 630 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_lblue}\$${c_clear}):AFTER\\nmain" >expected && 631 echo 2 >file && 632 git stash && 633 test_when_finished "git stash drop" && 634 ( 635 GIT_PS1_SHOWSTASHSTATE=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" 641' 642 643test_expect_success 'prompt - bash color pc mode - untracked files status indicator' ' 644 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}%%${c_clear}):AFTER\\nmain" >expected && 645 ( 646 GIT_PS1_SHOWUNTRACKEDFILES=y && 647 GIT_PS1_SHOWCOLORHINTS=y && 648 __git_ps1 "BEFORE:" ":AFTER" && 649 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual" 650 ) && 651 test_cmp expected "$actual" 652' 653 654test_expect_success 'prompt - zsh color pc mode' ' 655 printf "BEFORE: (%%F{green}main%%f):AFTER" >expected && 656 ( 657 ZSH_VERSION=5.0.0 && 658 GIT_PS1_SHOWCOLORHINTS=y && 659 __git_ps1 "BEFORE:" ":AFTER" && 660 printf "%s" "$PS1" >"$actual" 661 ) && 662 test_cmp expected "$actual" 663' 664 665test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled' ' 666 printf " (main)" >expected && 667 test_config bash.hideIfPwdIgnored false && 668 ( 669 cd ignored_dir && 670 __git_ps1 >"$actual" 671 ) && 672 test_cmp expected "$actual" 673' 674 675test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled, pc mode' ' 676 printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected && 677 test_config bash.hideIfPwdIgnored false && 678 ( 679 cd ignored_dir && 680 __git_ps1 "BEFORE:" ":AFTER" && 681 printf "%s" "$PS1" >"$actual" 682 ) && 683 test_cmp expected "$actual" 684' 685 686test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset' ' 687 printf " (main)" >expected && 688 ( 689 cd ignored_dir && 690 __git_ps1 >"$actual" 691 ) && 692 test_cmp expected "$actual" 693' 694 695test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset, pc mode' ' 696 printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected && 697 ( 698 cd ignored_dir && 699 __git_ps1 "BEFORE:" ":AFTER" && 700 printf "%s" "$PS1" >"$actual" 701 ) && 702 test_cmp expected "$actual" 703' 704 705test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled' ' 706 printf " (main)" >expected && 707 test_config bash.hideIfPwdIgnored false && 708 ( 709 cd ignored_dir && 710 GIT_PS1_HIDE_IF_PWD_IGNORED=y && 711 __git_ps1 >"$actual" 712 ) && 713 test_cmp expected "$actual" 714' 715 716test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled, pc mode' ' 717 printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected && 718 test_config bash.hideIfPwdIgnored false && 719 ( 720 cd ignored_dir && 721 GIT_PS1_HIDE_IF_PWD_IGNORED=y && 722 __git_ps1 "BEFORE:" ":AFTER" && 723 printf "%s" "$PS1" >"$actual" 724 ) && 725 test_cmp expected "$actual" 726' 727 728test_expect_success 'prompt - hide if pwd ignored - env var set, config unset' ' 729 ( 730 cd ignored_dir && 731 GIT_PS1_HIDE_IF_PWD_IGNORED=y && 732 __git_ps1 >"$actual" 733 ) && 734 test_must_be_empty "$actual" 735' 736 737test_expect_success 'prompt - hide if pwd ignored - env var set, config unset, pc mode' ' 738 printf "BEFORE::AFTER" >expected && 739 ( 740 cd ignored_dir && 741 GIT_PS1_HIDE_IF_PWD_IGNORED=y && 742 __git_ps1 "BEFORE:" ":AFTER" && 743 printf "%s" "$PS1" >"$actual" 744 ) && 745 test_cmp expected "$actual" 746' 747 748test_expect_success 'prompt - hide if pwd ignored - inside gitdir' ' 749 printf " (GIT_DIR!)" >expected && 750 ( 751 GIT_PS1_HIDE_IF_PWD_IGNORED=y && 752 cd .git && 753 __git_ps1 >"$actual" 754 ) && 755 test_cmp expected "$actual" 756' 757 758test_expect_success 'prompt - conflict indicator' ' 759 printf " (main|CONFLICT)" >expected && 760 echo "stash" >file && 761 git stash && 762 test_when_finished "git stash drop" && 763 echo "commit" >file && 764 git commit -m "commit" file && 765 test_when_finished "git reset --hard HEAD~" && 766 test_must_fail git stash apply && 767 ( 768 GIT_PS1_SHOWCONFLICTSTATE="yes" && 769 __git_ps1 >"$actual" 770 ) && 771 test_cmp expected "$actual" 772' 773 774test_done