git prompt: use toplevel to find untracked files
authorCody A Taylor <codemister99@yahoo.com>
Fri, 13 Mar 2015 02:24:50 +0000 (19:24 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 15 Mar 2015 21:23:22 +0000 (14:23 -0700)
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>
contrib/completion/git-prompt.sh
t/t9903-bash-prompt.sh
index 9d684b10a67ea663410db3ba68482c1a52bbc367..10c4d0ad74bc072afc86440c8810e2c3faae00ba 100644 (file)
@@ -474,7 +474,7 @@ __git_ps1 ()
 
                if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
                   [ "$(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
                        u="%${ZSH_VERSION+%}"
                fi
index 915098418495b488b748db9e610c79f81223a960..43cfefd2f8f12b835ff1b755af16ef5886721e24 100755 (executable)
@@ -395,6 +395,17 @@ test_expect_success 'prompt - untracked files status indicator - untracked files
        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' '
        printf " (master)" >expected &&
        test_config bash.showUntrackedFiles false &&