Merge branch 'sg/bash-prompt-untracked-optim'

Optimize computation of untracked status indicator by bash prompt
script (in contrib/).

* sg/bash-prompt-untracked-optim:
  bash prompt: faster untracked status indicator with untracked directories
  bash prompt: test untracked files status indicator with untracked dirs
This commit is contained in:
Junio C Hamano 2015-08-03 11:01:26 -07:00
commit 461c119739
2 changed files with 26 additions and 1 deletions

View file

@ -491,7 +491,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 --directory --no-empty-directory --error-unmatch -- ':/*' >/dev/null 2>/dev/null
then
u="%${ZSH_VERSION+%}"
fi

View file

@ -397,6 +397,31 @@ test_expect_success 'prompt - untracked files status indicator - untracked files
test_cmp expected "$actual"
'
test_expect_success 'prompt - untracked files status indicator - empty untracked dir' '
printf " (master)" >expected &&
mkdir otherrepo/untracked-dir &&
test_when_finished "rm -rf otherrepo/untracked-dir" &&
(
GIT_PS1_SHOWUNTRACKEDFILES=y &&
cd otherrepo &&
__git_ps1 >"$actual"
) &&
test_cmp expected "$actual"
'
test_expect_success 'prompt - untracked files status indicator - non-empty untracked dir' '
printf " (master %%)" >expected &&
mkdir otherrepo/untracked-dir &&
test_when_finished "rm -rf otherrepo/untracked-dir" &&
>otherrepo/untracked-dir/untracked-file &&
(
GIT_PS1_SHOWUNTRACKEDFILES=y &&
cd otherrepo &&
__git_ps1 >"$actual"
) &&
test_cmp expected "$actual"
'
test_expect_success 'prompt - untracked files status indicator - untracked files outside cwd' '
printf " (master %%)" >expected &&
(