mirror of
https://github.com/git/git
synced 2024-08-26 19:19:18 +00:00
git-prompt: show presence of unresolved conflicts at command prompt
If GIT_PS1_SHOWCONFLICTSTATE is set to "yes", show the word "CONFLICT" on the command prompt when there are unresolved conflicts. Example prompt: (main|CONFLICT) Signed-off-by: Justin Donnelly <justinrdonnelly@gmail.com> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
795ea8776b
commit
e03acd0d4a
|
@ -84,6 +84,10 @@
|
||||||
# single '?' character by setting GIT_PS1_COMPRESSSPARSESTATE, or omitted
|
# single '?' character by setting GIT_PS1_COMPRESSSPARSESTATE, or omitted
|
||||||
# by setting GIT_PS1_OMITSPARSESTATE.
|
# by setting GIT_PS1_OMITSPARSESTATE.
|
||||||
#
|
#
|
||||||
|
# If you would like to see a notification on the prompt when there are
|
||||||
|
# unresolved conflicts, set GIT_PS1_SHOWCONFLICTSTATE to "yes". The
|
||||||
|
# prompt will include "|CONFLICT".
|
||||||
|
#
|
||||||
# If you would like to see more information about the identity of
|
# If you would like to see more information about the identity of
|
||||||
# commits checked out as a detached HEAD, set GIT_PS1_DESCRIBE_STYLE
|
# commits checked out as a detached HEAD, set GIT_PS1_DESCRIBE_STYLE
|
||||||
# to one of these values:
|
# to one of these values:
|
||||||
|
@ -508,6 +512,12 @@ __git_ps1 ()
|
||||||
r="$r $step/$total"
|
r="$r $step/$total"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local conflict="" # state indicator for unresolved conflicts
|
||||||
|
if [[ "${GIT_PS1_SHOWCONFLICTSTATE}" == "yes" ]] &&
|
||||||
|
[[ $(git ls-files --unmerged 2>/dev/null) ]]; then
|
||||||
|
conflict="|CONFLICT"
|
||||||
|
fi
|
||||||
|
|
||||||
local w=""
|
local w=""
|
||||||
local i=""
|
local i=""
|
||||||
local s=""
|
local s=""
|
||||||
|
@ -572,7 +582,7 @@ __git_ps1 ()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local f="$h$w$i$s$u$p"
|
local f="$h$w$i$s$u$p"
|
||||||
local gitstring="$c$b${f:+$z$f}${sparse}$r${upstream}"
|
local gitstring="$c$b${f:+$z$f}${sparse}$r${upstream}${conflict}"
|
||||||
|
|
||||||
if [ $pcmode = yes ]; then
|
if [ $pcmode = yes ]; then
|
||||||
if [ "${__git_printf_supports_v-}" != yes ]; then
|
if [ "${__git_printf_supports_v-}" != yes ]; then
|
||||||
|
|
|
@ -759,4 +759,20 @@ test_expect_success 'prompt - hide if pwd ignored - inside gitdir' '
|
||||||
test_cmp expected "$actual"
|
test_cmp expected "$actual"
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'prompt - conflict indicator' '
|
||||||
|
printf " (main|CONFLICT)" >expected &&
|
||||||
|
echo "stash" >file &&
|
||||||
|
git stash &&
|
||||||
|
test_when_finished "git stash drop" &&
|
||||||
|
echo "commit" >file &&
|
||||||
|
git commit -m "commit" file &&
|
||||||
|
test_when_finished "git reset --hard HEAD~" &&
|
||||||
|
test_must_fail git stash apply &&
|
||||||
|
(
|
||||||
|
GIT_PS1_SHOWCONFLICTSTATE="yes" &&
|
||||||
|
__git_ps1 >"$actual"
|
||||||
|
) &&
|
||||||
|
test_cmp expected "$actual"
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in a new issue