File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 84
84
# single '?' character by setting GIT_PS1_COMPRESSSPARSESTATE, or omitted
85
85
# by setting GIT_PS1_OMITSPARSESTATE.
86
86
#
87
+ # If you would like to see a notification on the prompt when there are
88
+ # unresolved conflicts, set GIT_PS1_SHOWCONFLICTSTATE to "yes". The
89
+ # prompt will include "|CONFLICT".
90
+ #
87
91
# If you would like to see more information about the identity of
88
92
# commits checked out as a detached HEAD, set GIT_PS1_DESCRIBE_STYLE
89
93
# to one of these values:
@@ -508,6 +512,12 @@ __git_ps1 ()
508
512
r=" $r $step /$total "
509
513
fi
510
514
515
+ local conflict=" " # state indicator for unresolved conflicts
516
+ if [[ " ${GIT_PS1_SHOWCONFLICTSTATE} " == " yes" ]] &&
517
+ [[ $( git ls-files --unmerged 2> /dev/null) ]]; then
518
+ conflict=" |CONFLICT"
519
+ fi
520
+
511
521
local w=" "
512
522
local i=" "
513
523
local s=" "
@@ -572,7 +582,7 @@ __git_ps1 ()
572
582
fi
573
583
574
584
local f=" $h$w$i$s$u$p "
575
- local gitstring=" $c$b ${f: +$z$f }${sparse} $r ${upstream} "
585
+ local gitstring=" $c$b ${f: +$z$f }${sparse} $r ${upstream}${conflict} "
576
586
577
587
if [ $pcmode = yes ]; then
578
588
if [ " ${__git_printf_supports_v-} " != yes ]; then
Original file line number Diff line number Diff line change @@ -759,4 +759,20 @@ test_expect_success 'prompt - hide if pwd ignored - inside gitdir' '
759
759
test_cmp expected "$actual"
760
760
'
761
761
762
+ test_expect_success ' prompt - conflict indicator' '
763
+ printf " (main|CONFLICT)" >expected &&
764
+ echo "stash" >file &&
765
+ git stash &&
766
+ test_when_finished "git stash drop" &&
767
+ echo "commit" >file &&
768
+ git commit -m "commit" file &&
769
+ test_when_finished "git reset --hard HEAD~" &&
770
+ test_must_fail git stash apply &&
771
+ (
772
+ GIT_PS1_SHOWCONFLICTSTATE="yes" &&
773
+ __git_ps1 >"$actual"
774
+ ) &&
775
+ test_cmp expected "$actual"
776
+ '
777
+
762
778
test_done
You can’t perform that action at this time.
0 commit comments