Skip to content

Commit

Permalink
Merge branch 'sg/bash-prompt-untracked-optim'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gitster committed Aug 3, 2015
2 parents 8e699cd + dd160d7 commit 461c119
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contrib/completion/git-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions t/t9903-bash-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
(
Expand Down

0 comments on commit 461c119

Please sign in to comment.