git prompt: use toplevel to find untracked files
The __git_ps1() prompt function would not show an untracked state when all the untracked files are outside the current working directory. Signed-off-by: Cody A Taylor <codemister99@yahoo.com> Helped-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
282616c72d
commit
9bdc5173f0
@ -474,7 +474,7 @@ __git_ps1 ()
|
|||||||
|
|
||||||
if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
|
if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
|
||||||
[ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
|
[ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
|
||||||
git ls-files --others --exclude-standard --error-unmatch -- '*' >/dev/null 2>/dev/null
|
git ls-files --others --exclude-standard --error-unmatch -- ':/*' >/dev/null 2>/dev/null
|
||||||
then
|
then
|
||||||
u="%${ZSH_VERSION+%}"
|
u="%${ZSH_VERSION+%}"
|
||||||
fi
|
fi
|
||||||
|
@ -395,6 +395,17 @@ test_expect_success 'prompt - untracked files status indicator - untracked files
|
|||||||
test_cmp expected "$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' '
|
test_expect_success 'prompt - untracked files status indicator - shell variable unset with config disabled' '
|
||||||
printf " (master)" >expected &&
|
printf " (master)" >expected &&
|
||||||
test_config bash.showUntrackedFiles false &&
|
test_config bash.showUntrackedFiles false &&
|
||||||
|
Loading…
Reference in New Issue
Block a user