shell prompt: add bash.showUntrackedFiles option
authorMartin Erik Werner <martinerikwerner@gmail.com>
Wed, 13 Feb 2013 11:01:58 +0000 (12:01 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 13 Feb 2013 16:06:57 +0000 (08:06 -0800)
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>
contrib/completion/git-prompt.sh

index 9bef0531c5d9358e906bb7872f0775e165caac2c..9b2eec21e9a83f4a01733d5209b8a2a0e21c4799 100644 (file)
 #
 # 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
-# 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,
 # set GIT_PS1_SHOWUPSTREAM="auto".  A "<" indicates you are behind, ">"
@@ -332,8 +335,10 @@ __git_ps1 ()
                        fi
 
                        if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
-                               if [ -n "$(git ls-files --others --exclude-standard)" ]; then
-                                       u="%"
+                               if [ "$(git config --bool bash.showUntrackedFiles)" != "false" ]; then
+                                       if [ -n "$(git ls-files --others --exclude-standard)" ]; then
+                                               u="%"
+                                       fi
                                fi
                        fi