{"thread":{"id":"39890","subject":"[PATCH 1/2] bash prompt: test untracked files status indicator with untracked dirs","startedAt":"2015-07-19T11:28:05Z","lastAt":"2015-07-19T11:28:06Z","messageCount":2,"participants":["SZEDER Gábor"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"266373","messageId":"1437305286-23587-1-git-send-email-szeder@ira.uka.de","threadId":"39890","inReplyTo":null,"subject":"[PATCH 1/2] bash prompt: test untracked files status indicator with untracked dirs","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2015-07-19T11:28:05Z","receivedAt":"2015-07-19T11:28:05Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"The next commit will tweak the way __git_ps1() decides whether to display\nthe untracked files status indicator in the presence of untracked\ndirectories.  Add tests to make sure it doesn't change current behavior,\nin particular that an empty untracked directory doesn't trigger the\nuntracked files status indicator.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n t/t9903-bash-prompt.sh | 25 +++++++++++++++++++++++++\n 1 file changed, 25 insertions(+)\n\ndiff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh\nindex 49d58e6726..6b68777b98 100755\n--- a/t/t9903-bash-prompt.sh\n+++ b/t/t9903-bash-prompt.sh\n@@ -397,6 +397,31 @@ test_expect_success 'prompt - untracked files status indicator - untracked files\n \ttest_cmp expected \"$actual\"\n '\n \n+test_expect_success 'prompt - untracked files status indicator - empty untracked dir' '\n+\tprintf \" (master)\" >expected &&\n+\tmkdir otherrepo/untracked-dir &&\n+\ttest_when_finished \"rm -rf otherrepo/untracked-dir\" &&\n+\t(\n+\t\tGIT_PS1_SHOWUNTRACKEDFILES=y &&\n+\t\tcd otherrepo &&\n+\t\t__git_ps1 >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - untracked files status indicator - non-empty untracked dir' '\n+\tprintf \" (master %%)\" >expected &&\n+\tmkdir otherrepo/untracked-dir &&\n+\ttest_when_finished \"rm -rf otherrepo/untracked-dir\" &&\n+\t>otherrepo/untracked-dir/untracked-file &&\n+\t(\n+\t\tGIT_PS1_SHOWUNTRACKEDFILES=y &&\n+\t\tcd otherrepo &&\n+\t\t__git_ps1 >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n test_expect_success 'prompt - untracked files status indicator - untracked files outside cwd' '\n \tprintf \" (master %%)\" >expected &&\n \t(\n-- \n2.5.0.rc2.15.gd82f7f6\n"},{"id":"266374","messageId":"1437305286-23587-2-git-send-email-szeder@ira.uka.de","threadId":"39890","inReplyTo":"1437305286-23587-1-git-send-email-szeder@ira.uka.de","subject":"[PATCH 2/2] bash prompt: faster untracked status indicator with untracked directories","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2015-07-19T11:28:06Z","receivedAt":"2015-07-19T11:28:06Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"If the untracked status indicator is enabled, __git_ps1() looks for\nuntracked files by running 'git ls-files'.  This can be perceptibly slow\nin case of an untracked directory containing lot of files, because it\nlists all files found in the untracked directory only to be redirected\ninto /dev/null right away (this is the actual command run by __git_ps1()):\n\n  $ ls untracked-dir/ |wc -l\n  100000\n  $ time git ls-files --others --exclude-standard --error-unmatch \\\n    -- ':/*' >/dev/null 2>/dev/null\n\n  real\t0m0.955s\n  user\t0m0.936s\n  sys\t0m0.016s\n\nEliminate this delay by additionally passing the '--directory\n--no-empty-directory' options to 'git ls-files' to show only the name of\nnon-empty untracked directories instead of all their content:\n\n  $ time git ls-files --others --exclude-standard --directory \\\n    --no-empty-directory --error-unmatch -- ':/*' >/dev/null 2>/dev/null\n\n  real\t0m0.010s\n  user\t0m0.008s\n  sys\t0m0.000s\n\nThis follows suit of ea95c7b8f5 (completion: improve untracked directory\nfiltering for filename completion, 2013-09-18).\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n contrib/completion/git-prompt.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex 366f0bc1e9..07b52bedf1 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -491,7 +491,7 @@ __git_ps1 ()\n \n \t\tif [ -n \"${GIT_PS1_SHOWUNTRACKEDFILES-}\" ] &&\n \t\t   [ \"$(git config --bool bash.showUntrackedFiles)\" != \"false\" ] &&\n-\t\t   git ls-files --others --exclude-standard --error-unmatch -- ':/*' >/dev/null 2>/dev/null\n+\t\t   git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- ':/*' >/dev/null 2>/dev/null\n \t\tthen\n \t\t\tu=\"%${ZSH_VERSION+%}\"\n \t\tfi\n-- \n2.5.0.rc2.15.gd82f7f6\n"}]}