Merge branch 'jk/utf-8-can-be-spelled-differently'
[gitweb.git] / contrib / completion / git-prompt.sh
index 9bef0531c5d9358e906bb7872f0775e165caac2c..341422a766efe70580817d98a574d95bd9ddebf9 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, ">"
@@ -317,24 +320,25 @@ __git_ps1 ()
                                b="GIT_DIR!"
                        fi
                elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
-                       if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
-                               if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
-                                       git diff --no-ext-diff --quiet --exit-code || w="*"
-                                       if git rev-parse --quiet --verify HEAD >/dev/null; then
-                                               git diff-index --cached --quiet HEAD -- || i="+"
-                                       else
-                                               i="#"
-                                       fi
+                       if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] &&
+                          [ "$(git config --bool bash.showDirtyState)" != "false" ]
+                       then
+                               git diff --no-ext-diff --quiet --exit-code || w="*"
+                               if git rev-parse --quiet --verify HEAD >/dev/null; then
+                                       git diff-index --cached --quiet HEAD -- || i="+"
+                               else
+                                       i="#"
                                fi
                        fi
                        if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
                                git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$"
                        fi
 
-                       if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
-                               if [ -n "$(git ls-files --others --exclude-standard)" ]; then
-                                       u="%"
-                               fi
+                       if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
+                          [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
+                          [ -n "$(git ls-files --others --exclude-standard)" ]
+                       then
+                               u="%"
                        fi
 
                        if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then