Merge branch 'ct/prompt-untracked-fix' into maint
authorJunio C Hamano <gitster@pobox.com>
Sat, 28 Mar 2015 16:33:12 +0000 (09:33 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 28 Mar 2015 16:33:12 +0000 (09:33 -0700)
The prompt script (in contrib/) did not show the untracked sign
when working in a subdirectory without any untracked files.

* ct/prompt-untracked-fix:
git prompt: use toplevel to find untracked files

contrib/completion/git-prompt.sh
t/t9903-bash-prompt.sh
index 214e859f99e7d896a6fa45a737b5b3e2a629176f..f18aedc73be9daf4aab564beecb7bae29ea759c9 100644 (file)
@@ -487,7 +487,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 51ecd3e4c157ea267557a4484d574748b9757bd4..46d7d37a51023296033eae2e5576bb36f9c38f7b 100755 (executable)
@@ -397,6 +397,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 &&