shell prompt: add bash.showUntrackedFiles option

Add a config option 'bash.showUntrackedFiles' which allows enabling
the prompt showing untracked files on a per-repository basis. This is
useful for some repositories where the 'git ls-files ...' command may
take a long time.

Signed-off-by: Martin Erik Werner <martinerikwerner@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Martin Erik Werner
2013-02-13 12:01:58 +01:00
committed by Junio C Hamano
parent 5bf72ed2e7
commit 66cb5d4420

View File

@ -43,7 +43,10 @@
# #
# If you would like to see if there're untracked files, then you can set # If you would like to see if there're untracked files, then you can set
# GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're untracked # GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're untracked
# files, then a '%' will be shown next to the branch name. # files, then a '%' will be shown next to the branch name. You can
# configure this per-repository with the bash.showUntrackedFiles
# variable, which defaults to true once GIT_PS1_SHOWUNTRACKEDFILES is
# enabled.
# #
# If you would like to see the difference between HEAD and its upstream, # If you would like to see the difference between HEAD and its upstream,
# set GIT_PS1_SHOWUPSTREAM="auto". A "<" indicates you are behind, ">" # set GIT_PS1_SHOWUPSTREAM="auto". A "<" indicates you are behind, ">"
@ -332,8 +335,10 @@ __git_ps1 ()
fi fi
if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
if [ -n "$(git ls-files --others --exclude-standard)" ]; then if [ "$(git config --bool bash.showUntrackedFiles)" != "false" ]; then
u="%" if [ -n "$(git ls-files --others --exclude-standard)" ]; then
u="%"
fi
fi fi
fi fi