git prompt: use toplevel to find untracked files

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>

Cody A Taylor committed Mar 12, 2015 at 19:24 UTC 9bdc5173f0bc514d0b76165d45729622b2ad4d89
2 files changed +12 -1
contrib/completion/git-prompt.sh
+1 -1
@@ -474,7 +474,7 @@ __git_ps1 ()
474
475 if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
476 [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
477 - git ls-files --others --exclude-standard --error-unmatch -- '*' >/dev/null 2>/dev/null
477 + git ls-files --others --exclude-standard --error-unmatch -- ':/*' >/dev/null 2>/dev/null
478 then
479 u="%${ZSH_VERSION+%}"
480 fi
t/t9903-bash-prompt.sh
+11
@@ -395,6 +395,17 @@ test_expect_success 'prompt - untracked files status indicator - untracked files
395 test_cmp expected "$actual"
396 '
397
398 +test_expect_success 'prompt - untracked files status indicator - untracked files outside cwd' '
399 + printf " (master %%)" >expected &&
400 + (
401 + mkdir -p ignored_dir &&
402 + cd ignored_dir &&
403 + GIT_PS1_SHOWUNTRACKEDFILES=y &&
404 + __git_ps1 >"$actual"
405 + ) &&
406 + test_cmp expected "$actual"
407 +'
408 +
409 test_expect_success 'prompt - untracked files status indicator - shell variable unset with config disabled' '
410 printf " (master)" >expected &&
411 test_config bash.showUntrackedFiles false &&