@@ -452,67 +452,67 @@ test_expect_success 'prompt - format string starting with dash' '
452
452
'
453
453
454
454
test_expect_success ' prompt - pc mode' '
455
- printf "BEFORE: (master ):AFTER" >expected &&
455
+ printf "BEFORE: (\${__git_ps1_branch_name} ):AFTER\\nmaster " >expected &&
456
456
printf "" >expected_output &&
457
457
(
458
458
__git_ps1 "BEFORE:" ":AFTER" >"$actual" &&
459
459
test_cmp expected_output "$actual" &&
460
- printf "%s" "$PS1" >"$actual"
460
+ printf "%s\\n%s " "$PS1" "${__git_ps1_branch_name} " >"$actual"
461
461
) &&
462
462
test_cmp expected "$actual"
463
463
'
464
464
465
465
test_expect_success ' prompt - bash color pc mode - branch name' '
466
- printf "BEFORE: (${c_green}master${ c_clear}):AFTER" >expected &&
466
+ printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${ c_clear}):AFTER\\nmaster " >expected &&
467
467
(
468
468
GIT_PS1_SHOWCOLORHINTS=y &&
469
469
__git_ps1 "BEFORE:" ":AFTER" >"$actual"
470
- printf "%s" "$PS1" >"$actual"
470
+ printf "%s\\n%s " "$PS1" "${__git_ps1_branch_name} " >"$actual"
471
471
) &&
472
472
test_cmp expected "$actual"
473
473
'
474
474
475
475
test_expect_success ' prompt - bash color pc mode - detached head' '
476
- printf "BEFORE: (${c_red}(%s...)${ c_clear}):AFTER" $(git log -1 --format="%h" b1^) >expected &&
476
+ printf "BEFORE: (${c_red}\${__git_ps1_branch_name}${ c_clear}):AFTER\\n(%s...) " $(git log -1 --format="%h" b1^) >expected &&
477
477
git checkout b1^ &&
478
478
test_when_finished "git checkout master" &&
479
479
(
480
480
GIT_PS1_SHOWCOLORHINTS=y &&
481
481
__git_ps1 "BEFORE:" ":AFTER" &&
482
- printf "%s" "$PS1" >"$actual"
482
+ printf "%s\\n%s " "$PS1" "${__git_ps1_branch_name} " >"$actual"
483
483
) &&
484
484
test_cmp expected "$actual"
485
485
'
486
486
487
487
test_expect_success ' prompt - bash color pc mode - dirty status indicator - dirty worktree' '
488
- printf "BEFORE: (${c_green}master${ c_clear} ${c_red}*${c_clear}):AFTER" >expected &&
488
+ printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${ c_clear} ${c_red}*${c_clear}):AFTER\\nmaster " >expected &&
489
489
echo "dirty" >file &&
490
490
test_when_finished "git reset --hard" &&
491
491
(
492
492
GIT_PS1_SHOWDIRTYSTATE=y &&
493
493
GIT_PS1_SHOWCOLORHINTS=y &&
494
494
__git_ps1 "BEFORE:" ":AFTER" &&
495
- printf "%s" "$PS1" >"$actual"
495
+ printf "%s\\n%s " "$PS1" "${__git_ps1_branch_name} " >"$actual"
496
496
) &&
497
497
test_cmp expected "$actual"
498
498
'
499
499
500
500
test_expect_success ' prompt - bash color pc mode - dirty status indicator - dirty index' '
501
- printf "BEFORE: (${c_green}master${ c_clear} ${c_green}+${c_clear}):AFTER" >expected &&
501
+ printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${ c_clear} ${c_green}+${c_clear}):AFTER\\nmaster " >expected &&
502
502
echo "dirty" >file &&
503
503
test_when_finished "git reset --hard" &&
504
504
git add -u &&
505
505
(
506
506
GIT_PS1_SHOWDIRTYSTATE=y &&
507
507
GIT_PS1_SHOWCOLORHINTS=y &&
508
508
__git_ps1 "BEFORE:" ":AFTER" &&
509
- printf "%s" "$PS1" >"$actual"
509
+ printf "%s\\n%s " "$PS1" "${__git_ps1_branch_name} " >"$actual"
510
510
) &&
511
511
test_cmp expected "$actual"
512
512
'
513
513
514
514
test_expect_success ' prompt - bash color pc mode - dirty status indicator - dirty index and worktree' '
515
- printf "BEFORE: (${c_green}master${ c_clear} ${c_red}*${c_green}+${c_clear}):AFTER" >expected &&
515
+ printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${ c_clear} ${c_red}*${c_green}+${c_clear}):AFTER\\nmaster " >expected &&
516
516
echo "dirty index" >file &&
517
517
test_when_finished "git reset --hard" &&
518
518
git add -u &&
@@ -521,69 +521,69 @@ test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirt
521
521
GIT_PS1_SHOWCOLORHINTS=y &&
522
522
GIT_PS1_SHOWDIRTYSTATE=y &&
523
523
__git_ps1 "BEFORE:" ":AFTER" &&
524
- printf "%s" "$PS1" >"$actual"
524
+ printf "%s\\n%s " "$PS1" "${__git_ps1_branch_name} " >"$actual"
525
525
) &&
526
526
test_cmp expected "$actual"
527
527
'
528
528
529
529
test_expect_success ' prompt - bash color pc mode - dirty status indicator - before root commit' '
530
- printf "BEFORE: (${c_green}master${ c_clear} ${c_green}#${c_clear}):AFTER" >expected &&
530
+ printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${ c_clear} ${c_green}#${c_clear}):AFTER\\nmaster " >expected &&
531
531
(
532
532
GIT_PS1_SHOWDIRTYSTATE=y &&
533
533
GIT_PS1_SHOWCOLORHINTS=y &&
534
534
cd otherrepo &&
535
535
__git_ps1 "BEFORE:" ":AFTER" &&
536
- printf "%s" "$PS1" >"$actual"
536
+ printf "%s\\n%s " "$PS1" "${__git_ps1_branch_name} " >"$actual"
537
537
) &&
538
538
test_cmp expected "$actual"
539
539
'
540
540
541
541
test_expect_success ' prompt - bash color pc mode - inside .git directory' '
542
- printf "BEFORE: (${c_green}GIT_DIR!${ c_clear}):AFTER" >expected &&
542
+ printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${ c_clear}):AFTER\\nGIT_DIR! " >expected &&
543
543
echo "dirty" >file &&
544
544
test_when_finished "git reset --hard" &&
545
545
(
546
546
GIT_PS1_SHOWDIRTYSTATE=y &&
547
547
GIT_PS1_SHOWCOLORHINTS=y &&
548
548
cd .git &&
549
549
__git_ps1 "BEFORE:" ":AFTER" &&
550
- printf "%s" "$PS1" >"$actual"
550
+ printf "%s\\n%s " "$PS1" "${__git_ps1_branch_name} " >"$actual"
551
551
) &&
552
552
test_cmp expected "$actual"
553
553
'
554
554
555
555
test_expect_success ' prompt - bash color pc mode - stash status indicator' '
556
- printf "BEFORE: (${c_green}master${ c_clear} ${c_lblue}\$${c_clear}):AFTER" >expected &&
556
+ printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${ c_clear} ${c_lblue}\$${c_clear}):AFTER\\nmaster " >expected &&
557
557
echo 2 >file &&
558
558
git stash &&
559
559
test_when_finished "git stash drop" &&
560
560
(
561
561
GIT_PS1_SHOWSTASHSTATE=y &&
562
562
GIT_PS1_SHOWCOLORHINTS=y &&
563
563
__git_ps1 "BEFORE:" ":AFTER" &&
564
- printf "%s" "$PS1" >"$actual"
564
+ printf "%s\\n%s " "$PS1" "${__git_ps1_branch_name} " >"$actual"
565
565
) &&
566
566
test_cmp expected "$actual"
567
567
'
568
568
569
569
test_expect_success ' prompt - bash color pc mode - untracked files status indicator' '
570
- printf "BEFORE: (${c_green}master${ c_clear} ${c_red}%%${c_clear}):AFTER" >expected &&
570
+ printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${ c_clear} ${c_red}%%${c_clear}):AFTER\\nmaster " >expected &&
571
571
(
572
572
GIT_PS1_SHOWUNTRACKEDFILES=y &&
573
573
GIT_PS1_SHOWCOLORHINTS=y &&
574
574
__git_ps1 "BEFORE:" ":AFTER" &&
575
- printf "%s" "$PS1" >"$actual"
575
+ printf "%s\\n%s " "$PS1" "${__git_ps1_branch_name} " >"$actual"
576
576
) &&
577
577
test_cmp expected "$actual"
578
578
'
579
579
580
580
test_expect_success ' prompt - zsh color pc mode' '
581
- printf "BEFORE: (%%F{green}master %%f):AFTER" >expected &&
581
+ printf "BEFORE: (%%F{green}\${__git_ps1_branch_name} %%f):AFTER\\nmaster " >expected &&
582
582
(
583
583
ZSH_VERSION=5.0.0 &&
584
584
GIT_PS1_SHOWCOLORHINTS=y &&
585
585
__git_ps1 "BEFORE:" ":AFTER" >"$actual"
586
- printf "%s" "$PS1" >"$actual"
586
+ printf "%s\\n%s " "$PS1" "${__git_ps1_branch_name} " >"$actual"
587
587
) &&
588
588
test_cmp expected "$actual"
589
589
'
0 commit comments