{"thread":{"id":"34234","subject":"[PATCH 1/4] t9903: add tests for git-prompt pcmode","startedAt":"2013-06-21T02:25:25Z","lastAt":"2013-06-25T01:21:52Z","messageCount":15,"participants":["Eduardo R. D'Avila","SZEDER Gábor","Øystein Walle","Eduardo D'Avila","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"221547","messageId":"cover.1371780085.git.erdavila@gmail.com","threadId":"34234","inReplyTo":null,"subject":"[PATCH 0/4] git-prompt: cleaning and improvement","fromName":"Eduardo R. D'Avila","fromEmail":"erdavila@gmail.com","sentAt":"2013-06-21T02:25:25Z","receivedAt":"2013-06-21T02:25:25Z","isPatch":true,"sender":{"key":"erdavila@gmail.com","avatar":"https://avatars.githubusercontent.com/u/341488?v=4"},"body":"The previously proposed patch set to enable color\nprompt in non-PROMPT_COMMAND mode\n(http://article.gmane.org/gmane.comp.version-control.git/228017)\nintroduce some problems with command line editing/browsing/completion,\nas explained by Simon Oosthoek, in\nhttp://article.gmane.org/gmane.comp.version-control.git/228308 .\n\nSome of the patches could still be used, so I'm\nreposting them with an additional one to add some\nmissing information in usage comments.\n\n\nEduardo R. D'Avila (4):\n  t9903: add tests for git-prompt pcmode\n  git-prompt.sh: refactor colored prompt code\n  git-prompt.sh: do not print duplicate clean color code\n  git-prompt.sh: add missing information in comments\n\n contrib/completion/git-prompt.sh |  94 +++++----------\n t/t9903-bash-prompt.sh           | 254 +++++++++++++++++++++++++++++++++++++++\n 2 files changed, 285 insertions(+), 63 deletions(-)\n\n-- \n1.8.3.1.487.g28387b2\n"},{"id":"221544","messageId":"3dd104f19a995081d8c8bf89bc9e33052077e052.1371780085.git.erdavila@gmail.com","threadId":"34234","inReplyTo":"cover.1371780085.git.erdavila@gmail.com","subject":"[PATCH 1/4] t9903: add tests for git-prompt pcmode","fromName":"Eduardo R. D'Avila","fromEmail":"erdavila@gmail.com","sentAt":"2013-06-21T02:25:26Z","receivedAt":"2013-06-21T02:25:26Z","isPatch":true,"sender":{"key":"erdavila@gmail.com","avatar":"https://avatars.githubusercontent.com/u/341488?v=4"},"body":"git-prompt.sh lacks tests for PROMPT_COMMAND mode.\n\nAdd tests for:\n* pcmode prompt without colors\n* pcmode prompt with colors for bash\n* pcmode prompt with colors for zsh\n\nHaving these tests enables an upcoming refactor in\na safe way.\n\nSigned-off-by: Eduardo R. D'Avila <erdavila@gmail.com>\n---\n254\t0\tt/t9903-bash-prompt.sh\n t/t9903-bash-prompt.sh | 254 +++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 254 insertions(+)\n\ndiff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh\nindex 15521cc..6a88778 100755\n--- a/t/t9903-bash-prompt.sh\n+++ b/t/t9903-bash-prompt.sh\n@@ -10,6 +10,10 @@ test_description='test git-specific bash prompt functions'\n . \"$GIT_BUILD_DIR/contrib/completion/git-prompt.sh\"\n \n actual=\"$TRASH_DIRECTORY/actual\"\n+c_red='\\\\[\\\\e[31m\\\\]'\n+c_green='\\\\[\\\\e[32m\\\\]'\n+c_lblue='\\\\[\\\\e[1;34m\\\\]'\n+c_clear='\\\\[\\\\e[0m\\\\]'\n \n test_expect_success 'setup for prompt tests' '\n \tmkdir -p subdir/subsubdir &&\n@@ -535,4 +539,254 @@ test_expect_success 'prompt - format string starting with dash' '\n \ttest_cmp expected \"$actual\"\n '\n \n+test_expect_success 'prompt - pc mode' '\n+\tprintf \"BEFORE: (master):AFTER\" >expected &&\n+\tprintf \"\" >expected_output &&\n+\t(\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" >\"$actual\" &&\n+\t\ttest_cmp expected_output \"$actual\" &&\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - bash color pc mode - branch name' '\n+\tprintf \"BEFORE: (${c_green}master${c_clear}${c_clear}):AFTER\" >expected &&\n+\t(\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" >\"$actual\"\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - bash color pc mode - detached head' '\n+\tprintf \"BEFORE: (${c_red}(%s...)${c_clear}${c_clear}):AFTER\" $(git log -1 --format=\"%h\" b1^) >expected &&\n+\tgit checkout b1^ &&\n+\ttest_when_finished \"git checkout master\" &&\n+\t(\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" &&\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty worktree' '\n+\tprintf \"BEFORE: (${c_green}master${c_clear} ${c_red}*${c_clear}):AFTER\" >expected &&\n+\techo \"dirty\" >file &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\t(\n+\t\tGIT_PS1_SHOWDIRTYSTATE=y &&\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" &&\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index' '\n+\tprintf \"BEFORE: (${c_green}master${c_clear} ${c_green}+${c_clear}):AFTER\" >expected &&\n+\techo \"dirty\" >file &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\tgit add -u &&\n+\t(\n+\t\tGIT_PS1_SHOWDIRTYSTATE=y &&\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" &&\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index and worktree' '\n+\tprintf \"BEFORE: (${c_green}master${c_clear} ${c_red}*${c_green}+${c_clear}):AFTER\" >expected &&\n+\techo \"dirty index\" >file &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\tgit add -u &&\n+\techo \"dirty worktree\" >file &&\n+\t(\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\tGIT_PS1_SHOWDIRTYSTATE=y &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" &&\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - bash color pc mode - dirty status indicator - before root commit' '\n+\tprintf \"BEFORE: (${c_green}master${c_clear} ${c_green}#${c_clear}):AFTER\" >expected &&\n+\t(\n+\t\tGIT_PS1_SHOWDIRTYSTATE=y &&\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\tcd otherrepo &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" &&\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - bash color pc mode - inside .git directory' '\n+\tprintf \"BEFORE: (${c_green}GIT_DIR!${c_clear}${c_clear}):AFTER\" >expected &&\n+\techo \"dirty\" >file &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\t(\n+\t\tGIT_PS1_SHOWDIRTYSTATE=y &&\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\tcd .git &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" &&\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - bash color pc mode - stash status indicator' '\n+\tprintf \"BEFORE: (${c_green}master${c_clear} ${c_lblue}\\$${c_clear}):AFTER\" >expected &&\n+\techo 2 >file &&\n+\tgit stash &&\n+\ttest_when_finished \"git stash drop\" &&\n+\t(\n+\t\tGIT_PS1_SHOWSTASHSTATE=y &&\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" &&\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - bash color pc mode - untracked files status indicator' '\n+\tprintf \"BEFORE: (${c_green}master${c_clear} ${c_red}%%${c_clear}):AFTER\" >expected &&\n+\t(\n+\t\tGIT_PS1_SHOWUNTRACKEDFILES=y &&\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" &&\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - zsh color pc mode - branch name' '\n+\tprintf \"BEFORE: (%%F{green}master%%f%%f):AFTER\" >expected &&\n+\t(\n+\t\tZSH_VERSION=5.0.0 &&\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" >\"$actual\"\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - zsh color pc mode - detached head' '\n+\tprintf \"BEFORE: (%%F{red}(%s...)%%f%%f):AFTER\" $(git log -1 --format=\"%h\" b1^) >expected &&\n+\tgit checkout b1^ &&\n+\ttest_when_finished \"git checkout master\" &&\n+\t(\n+\t\tZSH_VERSION=5.0.0 &&\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" &&\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - zsh color pc mode - dirty status indicator - dirty worktree' '\n+\tprintf \"BEFORE: (%%F{green}master%%f %%F{red}*%%f):AFTER\" >expected &&\n+\techo \"dirty\" >file &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\t(\n+\t\tZSH_VERSION=5.0.0 &&\n+\t\tGIT_PS1_SHOWDIRTYSTATE=y &&\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" &&\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - zsh color pc mode - dirty status indicator - dirty index' '\n+\tprintf \"BEFORE: (%%F{green}master%%f %%F{green}+%%f):AFTER\" >expected &&\n+\techo \"dirty\" >file &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\tgit add -u &&\n+\t(\n+\t\tZSH_VERSION=5.0.0 &&\n+\t\tGIT_PS1_SHOWDIRTYSTATE=y &&\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" &&\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - zsh color pc mode - dirty status indicator - dirty index and worktree' '\n+\tprintf \"BEFORE: (%%F{green}master%%f %%F{red}*%%F{green}+%%f):AFTER\" >expected &&\n+\techo \"dirty index\" >file &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\tgit add -u &&\n+\techo \"dirty worktree\" >file &&\n+\t(\n+\t\tZSH_VERSION=5.0.0 &&\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\tGIT_PS1_SHOWDIRTYSTATE=y &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" &&\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - zsh color pc mode - dirty status indicator - before root commit' '\n+\tprintf \"BEFORE: (%%F{green}master%%f %%F{green}#%%f):AFTER\" >expected &&\n+\t(\n+\t\tZSH_VERSION=5.0.0 &&\n+\t\tGIT_PS1_SHOWDIRTYSTATE=y &&\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\tcd otherrepo &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" &&\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - zsh color pc mode - inside .git directory' '\n+\tprintf \"BEFORE: (%%F{green}GIT_DIR!%%f%%f):AFTER\" >expected &&\n+\techo \"dirty\" >file &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\t(\n+\t\tZSH_VERSION=5.0.0 &&\n+\t\tGIT_PS1_SHOWDIRTYSTATE=y &&\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\tcd .git &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" &&\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - zsh color pc mode - stash status indicator' '\n+\tprintf \"BEFORE: (%%F{green}master%%f %%F{blue}$%%f):AFTER\" >expected &&\n+\techo 2 >file &&\n+\tgit stash &&\n+\ttest_when_finished \"git stash drop\" &&\n+\t(\n+\t\tZSH_VERSION=5.0.0 &&\n+\t\tGIT_PS1_SHOWSTASHSTATE=y &&\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" &&\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - zsh color pc mode - untracked files status indicator' '\n+\tprintf \"BEFORE: (%%F{green}master%%f %%F{red}%%%%%%f):AFTER\" >expected &&\n+\t(\n+\t\tZSH_VERSION=5.0.0 &&\n+\t\tGIT_PS1_SHOWUNTRACKEDFILES=y &&\n+\t\tGIT_PS1_SHOWCOLORHINTS=y &&\n+\t\t__git_ps1 \"BEFORE:\" \":AFTER\" &&\n+\t\tprintf \"%s\" \"$PS1\" >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n test_done\n-- \n1.8.3.1.487.g28387b2\n"},{"id":"221545","messageId":"354a860e12a3463ce5d031c0dc46d095841f717d.1371780085.git.erdavila@gmail.com","threadId":"34234","inReplyTo":"cover.1371780085.git.erdavila@gmail.com","subject":"[PATCH 2/4] git-prompt.sh: refactor colored prompt code","fromName":"Eduardo R. D'Avila","fromEmail":"erdavila@gmail.com","sentAt":"2013-06-21T02:25:27Z","receivedAt":"2013-06-21T02:25:27Z","isPatch":true,"sender":{"key":"erdavila@gmail.com","avatar":"https://avatars.githubusercontent.com/u/341488?v=4"},"body":"__git_ps1_colorize_gitstring() sets color codes and\nbuilds the prompt gitstring. It has duplicated code\nto handle color codes for bash and zsh shells.\n__git_ps1() also has duplicated logic to build the\nprompt gitstring.\n\nRemove duplication of logic to build gitstring in\n__git_ps1_colorize_gitstring() and __git_ps1().\n\nLeave in __git_ps1_colorize_gitstring() only logic\nto set color codes.\n\nSigned-off-by: Eduardo R. D'Avila <erdavila@gmail.com>\n---\n26\t59\tcontrib/completion/git-prompt.sh\n contrib/completion/git-prompt.sh | 85 ++++++++++++----------------------------\n 1 file changed, 26 insertions(+), 59 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex 86a4f3f..b02b7b2 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -225,8 +225,8 @@ __git_ps1_show_upstream ()\n }\n \n # Helper function that is meant to be called from __git_ps1.  It\n-# builds up a gitstring injecting color codes into the appropriate\n-# places.\n+# injects color codes into the appropriate gitstring variables used\n+# to build a gitstring.\n __git_ps1_colorize_gitstring ()\n {\n \tif [[ -n ${ZSH_VERSION-} ]]; then\n@@ -234,74 +234,40 @@ __git_ps1_colorize_gitstring ()\n \t\tlocal c_green='%F{green}'\n \t\tlocal c_lblue='%F{blue}'\n \t\tlocal c_clear='%f'\n-\t\tlocal bad_color=$c_red\n-\t\tlocal ok_color=$c_green\n-\t\tlocal branch_color=\"$c_clear\"\n-\t\tlocal flags_color=\"$c_lblue\"\n-\t\tlocal branchstring=\"$c${b##refs/heads/}\"\n-\n-\t\tif [ $detached = no ]; then\n-\t\t\tbranch_color=\"$ok_color\"\n-\t\telse\n-\t\t\tbranch_color=\"$bad_color\"\n-\t\tfi\n-\n-\t\tgitstring=\"$branch_color$branchstring$c_clear\"\n-\n-\t\tif [ -n \"$w$i$s$u$r$p\" ]; then\n-\t\t\tgitstring=\"$gitstring$z\"\n-\t\tfi\n-\t\tif [ \"$w\" = \"*\" ]; then\n-\t\t\tgitstring=\"$gitstring$bad_color$w\"\n-\t\tfi\n-\t\tif [ -n \"$i\" ]; then\n-\t\t\tgitstring=\"$gitstring$ok_color$i\"\n-\t\tfi\n-\t\tif [ -n \"$s\" ]; then\n-\t\t\tgitstring=\"$gitstring$flags_color$s\"\n-\t\tfi\n-\t\tif [ -n \"$u\" ]; then\n-\t\t\tgitstring=\"$gitstring$bad_color$u\"\n-\t\tfi\n-\t\tgitstring=\"$gitstring$c_clear$r$p\"\n-\t\treturn\n+\telse\n+\t\t# Using \\[ and \\] around colors\n+\t\t# is necessary to prevent wrapping issues!\n+\t\tlocal c_red='\\[\\e[31m\\]'\n+\t\tlocal c_green='\\[\\e[32m\\]'\n+\t\tlocal c_lblue='\\[\\e[1;34m\\]'\n+\t\tlocal c_clear='\\[\\e[0m\\]'\n \tfi\n-\tlocal c_red='\\e[31m'\n-\tlocal c_green='\\e[32m'\n-\tlocal c_lblue='\\e[1;34m'\n-\tlocal c_clear='\\e[0m'\n \tlocal bad_color=$c_red\n \tlocal ok_color=$c_green\n-\tlocal branch_color=\"$c_clear\"\n \tlocal flags_color=\"$c_lblue\"\n-\tlocal branchstring=\"$c${b##refs/heads/}\"\n \n+\tlocal branch_color=\"\"\n \tif [ $detached = no ]; then\n \t\tbranch_color=\"$ok_color\"\n \telse\n \t\tbranch_color=\"$bad_color\"\n \tfi\n+\tc=\"$branch_color$c\"\n+\tb=\"$b$c_clear\"\n \n-\t# Setting gitstring directly with \\[ and \\] around colors\n-\t# is necessary to prevent wrapping issues!\n-\tgitstring=\"\\[$branch_color\\]$branchstring\\[$c_clear\\]\"\n-\n-\tif [ -n \"$w$i$s$u$r$p\" ]; then\n-\t\tgitstring=\"$gitstring$z\"\n-\tfi\n \tif [ \"$w\" = \"*\" ]; then\n-\t\tgitstring=\"$gitstring\\[$bad_color\\]$w\"\n+\t\tw=\"$bad_color$w\"\n \tfi\n \tif [ -n \"$i\" ]; then\n-\t\tgitstring=\"$gitstring\\[$ok_color\\]$i\"\n+\t\ti=\"$ok_color$i\"\n \tfi\n \tif [ -n \"$s\" ]; then\n-\t\tgitstring=\"$gitstring\\[$flags_color\\]$s\"\n+\t\ts=\"$flags_color$s\"\n \tfi\n \tif [ -n \"$u\" ]; then\n-\t\tgitstring=\"$gitstring\\[$bad_color\\]$u\"\n+\t\tu=\"$bad_color$u\"\n \tfi\n-\tgitstring=\"$gitstring\\[$c_clear\\]$r$p\"\n+\tr=\"$c_clear$r\"\n }\n \n # __git_ps1 accepts 0 or 1 arguments (i.e., format string)\n@@ -443,19 +409,20 @@ __git_ps1 ()\n \t\tfi\n \n \t\tlocal z=\"${GIT_PS1_STATESEPARATOR-\" \"}\"\n+\n+\t\t# NO color option unless in PROMPT_COMMAND mode\n+\t\tif [ $pcmode = yes ] && [ -n \"${GIT_PS1_SHOWCOLORHINTS-}\" ]; then\n+\t\t\t__git_ps1_colorize_gitstring\n+\t\tfi\n+\n \t\tlocal f=\"$w$i$s$u\"\n+\t\tlocal gitstring=\"$c${b##refs/heads/}${f:+$z$f}$r$p\"\n+\n \t\tif [ $pcmode = yes ]; then\n-\t\t\tlocal gitstring=\n-\t\t\tif [ -n \"${GIT_PS1_SHOWCOLORHINTS-}\" ]; then\n-\t\t\t\t__git_ps1_colorize_gitstring\n-\t\t\telse\n-\t\t\t\tgitstring=\"$c${b##refs/heads/}${f:+$z$f}$r$p\"\n-\t\t\tfi\n \t\t\tgitstring=$(printf -- \"$printf_format\" \"$gitstring\")\n \t\t\tPS1=\"$ps1pc_start$gitstring$ps1pc_end\"\n \t\telse\n-\t\t\t# NO color option unless in PROMPT_COMMAND mode\n-\t\t\tprintf -- \"$printf_format\" \"$c${b##refs/heads/}${f:+$z$f}$r$p\"\n+\t\t\tprintf -- \"$printf_format\" \"$gitstring\"\n \t\tfi\n \tfi\n }\n-- \n1.8.3.1.487.g28387b2\n"},{"id":"221546","messageId":"a44fecc0b75c3eacc24675aa4ec4e3a3c95c84ad.1371780085.git.erdavila@gmail.com","threadId":"34234","inReplyTo":"cover.1371780085.git.erdavila@gmail.com","subject":"[PATCH 3/4] git-prompt.sh: do not print duplicate clean color code","fromName":"Eduardo R. D'Avila","fromEmail":"erdavila@gmail.com","sentAt":"2013-06-21T02:25:28Z","receivedAt":"2013-06-21T02:25:28Z","isPatch":true,"sender":{"key":"erdavila@gmail.com","avatar":"https://avatars.githubusercontent.com/u/341488?v=4"},"body":"Do not print a duplicate clean color code when there\nis no other indicators other than the current branch\nin colored prompt.\n\nSigned-off-by: Eduardo R. D'Avila <erdavila@gmail.com>\n---\n1\t1\tcontrib/completion/git-prompt.sh\n6\t6\tt/t9903-bash-prompt.sh\n contrib/completion/git-prompt.sh |  2 +-\n t/t9903-bash-prompt.sh           | 12 ++++++------\n 2 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex b02b7b2..70515cc 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -253,8 +253,8 @@ __git_ps1_colorize_gitstring ()\n \t\tbranch_color=\"$bad_color\"\n \tfi\n \tc=\"$branch_color$c\"\n-\tb=\"$b$c_clear\"\n \n+\tz=\"$c_clear$z\"\n \tif [ \"$w\" = \"*\" ]; then\n \t\tw=\"$bad_color$w\"\n \tfi\ndiff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh\nindex 6a88778..1101adf 100755\n--- a/t/t9903-bash-prompt.sh\n+++ b/t/t9903-bash-prompt.sh\n@@ -551,7 +551,7 @@ test_expect_success 'prompt - pc mode' '\n '\n \n test_expect_success 'prompt - bash color pc mode - branch name' '\n-\tprintf \"BEFORE: (${c_green}master${c_clear}${c_clear}):AFTER\" >expected &&\n+\tprintf \"BEFORE: (${c_green}master${c_clear}):AFTER\" >expected &&\n \t(\n \t\tGIT_PS1_SHOWCOLORHINTS=y &&\n \t\t__git_ps1 \"BEFORE:\" \":AFTER\" >\"$actual\"\n@@ -561,7 +561,7 @@ test_expect_success 'prompt - bash color pc mode - branch name' '\n '\n \n test_expect_success 'prompt - bash color pc mode - detached head' '\n-\tprintf \"BEFORE: (${c_red}(%s...)${c_clear}${c_clear}):AFTER\" $(git log -1 --format=\"%h\" b1^) >expected &&\n+\tprintf \"BEFORE: (${c_red}(%s...)${c_clear}):AFTER\" $(git log -1 --format=\"%h\" b1^) >expected &&\n \tgit checkout b1^ &&\n \ttest_when_finished \"git checkout master\" &&\n \t(\n@@ -627,7 +627,7 @@ test_expect_success 'prompt - bash color pc mode - dirty status indicator - befo\n '\n \n test_expect_success 'prompt - bash color pc mode - inside .git directory' '\n-\tprintf \"BEFORE: (${c_green}GIT_DIR!${c_clear}${c_clear}):AFTER\" >expected &&\n+\tprintf \"BEFORE: (${c_green}GIT_DIR!${c_clear}):AFTER\" >expected &&\n \techo \"dirty\" >file &&\n \ttest_when_finished \"git reset --hard\" &&\n \t(\n@@ -666,7 +666,7 @@ test_expect_success 'prompt - bash color pc mode - untracked files status indica\n '\n \n test_expect_success 'prompt - zsh color pc mode - branch name' '\n-\tprintf \"BEFORE: (%%F{green}master%%f%%f):AFTER\" >expected &&\n+\tprintf \"BEFORE: (%%F{green}master%%f):AFTER\" >expected &&\n \t(\n \t\tZSH_VERSION=5.0.0 &&\n \t\tGIT_PS1_SHOWCOLORHINTS=y &&\n@@ -677,7 +677,7 @@ test_expect_success 'prompt - zsh color pc mode - branch name' '\n '\n \n test_expect_success 'prompt - zsh color pc mode - detached head' '\n-\tprintf \"BEFORE: (%%F{red}(%s...)%%f%%f):AFTER\" $(git log -1 --format=\"%h\" b1^) >expected &&\n+\tprintf \"BEFORE: (%%F{red}(%s...)%%f):AFTER\" $(git log -1 --format=\"%h\" b1^) >expected &&\n \tgit checkout b1^ &&\n \ttest_when_finished \"git checkout master\" &&\n \t(\n@@ -748,7 +748,7 @@ test_expect_success 'prompt - zsh color pc mode - dirty status indicator - befor\n '\n \n test_expect_success 'prompt - zsh color pc mode - inside .git directory' '\n-\tprintf \"BEFORE: (%%F{green}GIT_DIR!%%f%%f):AFTER\" >expected &&\n+\tprintf \"BEFORE: (%%F{green}GIT_DIR!%%f):AFTER\" >expected &&\n \techo \"dirty\" >file &&\n \ttest_when_finished \"git reset --hard\" &&\n \t(\n-- \n1.8.3.1.487.g28387b2\n"},{"id":"221548","messageId":"8fcf64a70e63761f3982e1be05be0a2bb1fb68bf.1371780085.git.erdavila@gmail.com","threadId":"34234","inReplyTo":"cover.1371780085.git.erdavila@gmail.com","subject":"[PATCH 4/4] git-prompt.sh: add missing information in comments","fromName":"Eduardo R. D'Avila","fromEmail":"erdavila@gmail.com","sentAt":"2013-06-21T02:25:29Z","receivedAt":"2013-06-21T02:25:29Z","isPatch":true,"sender":{"key":"erdavila@gmail.com","avatar":"https://avatars.githubusercontent.com/u/341488?v=4"},"body":"Mention that the command below is needed for prompt\nin ZSH with PS1:\n  setopt PROMPT_SUBST\n\nMake it clear that colored prompt is only available\nin PROMPT_COMMAND mode.\n\nSigned-off-by: Eduardo R. D'Avila <erdavila@gmail.com>\n---\n5\t4\tcontrib/completion/git-prompt.sh\n contrib/completion/git-prompt.sh | 9 +++++----\n 1 file changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex 70515cc..3ab2a69 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -13,10 +13,10 @@\n #    3a) Change your PS1 to call __git_ps1 as\n #        command-substitution:\n #        Bash: PS1='[\\u@\\h \\W$(__git_ps1 \" (%s)\")]\\$ '\n-#        ZSH:  PS1='[%n@%m %c$(__git_ps1 \" (%s)\")]\\$ '\n+#        ZSH:  setopt PROMPT_SUBST ; PS1='[%n@%m %c$(__git_ps1 \" (%s)\")]\\$ '\n #        the optional argument will be used as format string.\n-#    3b) Alternatively, if you are using bash, __git_ps1 can be\n-#        used for PROMPT_COMMAND with two parameters, <pre> and\n+#    3b) Alternatively, if you are using Bash or ZSH, __git_ps1 can\n+#        be used for PROMPT_COMMAND with two parameters, <pre> and\n #        <post>, which are strings you would put in $PS1 before\n #        and after the status string generated by the git-prompt\n #        machinery.  e.g.\n@@ -78,7 +78,8 @@\n #\n # If you would like a colored hint about the current dirty state, set\n # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on\n-# the colored output of \"git status -sb\".\n+# the colored output of \"git status -sb\" and are available only when\n+# using __git_ps1 for PROMPT_COMMAND.\n \n # __gitdir accepts 0 or 1 arguments (i.e., location)\n # returns location of .git repo\n-- \n1.8.3.1.487.g28387b2\n"},{"id":"221686","messageId":"20130622130604.GK20052@goldbirke","threadId":"34234","inReplyTo":"3dd104f19a995081d8c8bf89bc9e33052077e052.1371780085.git.erdavila@gmail.com","subject":"Re: [PATCH 1/4] t9903: add tests for git-prompt pcmode","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-06-22T13:06:04Z","receivedAt":"2013-06-22T13:06:04Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi,\n\nOn Thu, Jun 20, 2013 at 11:25:26PM -0300, Eduardo R. D'Avila wrote:\n> git-prompt.sh lacks tests for PROMPT_COMMAND mode.\n> \n> Add tests for:\n> * pcmode prompt without colors\n> * pcmode prompt with colors for bash\n> * pcmode prompt with colors for zsh\n> \n> Having these tests enables an upcoming refactor in\n> a safe way.\n> \n> Signed-off-by: Eduardo R. D'Avila <erdavila@gmail.com>\n\nI doubt the value of separate tests for zsh.  They might make sense as\nlong as there are different code paths for doing coloring for the two\nshells, but after your refactorization in 2/4 there is only one common\nblock of if statements, which is already thoroughly excercised by your\ntests for bash, making the separate tests for zsh redundant.\n\n\nGábor\n"},{"id":"221687","messageId":"20130622132640.GL20052@goldbirke","threadId":"34234","inReplyTo":"a44fecc0b75c3eacc24675aa4ec4e3a3c95c84ad.1371780085.git.erdavila@gmail.com","subject":"Re: [PATCH 3/4] git-prompt.sh: do not print duplicate clean color code","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-06-22T13:26:40Z","receivedAt":"2013-06-22T13:26:40Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Thu, Jun 20, 2013 at 11:25:28PM -0300, Eduardo R. D'Avila wrote:\n> Do not print a duplicate clean color code when there\n> is no other indicators other than the current branch\n> in colored prompt.\n> \n> Signed-off-by: Eduardo R. D'Avila <erdavila@gmail.com>\n\nGreat.  I wanted to point out in the previous versions of this series\nthat the patch claiming to refactor coloring actually touches the test\nscript because it silently fixes the clean color code duplication.\nThanks for splitting that patch before I even managed to find the time\nto mention it ;)\n"},{"id":"221688","messageId":"20130622134026.GM20052@goldbirke","threadId":"34234","inReplyTo":"8fcf64a70e63761f3982e1be05be0a2bb1fb68bf.1371780085.git.erdavila@gmail.com","subject":"Re: [PATCH 4/4] git-prompt.sh: add missing information in comments","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-06-22T13:40:26Z","receivedAt":"2013-06-22T13:40:26Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Thu, Jun 20, 2013 at 11:25:29PM -0300, Eduardo R. D'Avila wrote:\n> Mention that the command below is needed for prompt\n> in ZSH with PS1:\n>   setopt PROMPT_SUBST\n> \n> Make it clear that colored prompt is only available\n> in PROMPT_COMMAND mode.\n> \n> Signed-off-by: Eduardo R. D'Avila <erdavila@gmail.com>\n> ---\n> 5\t4\tcontrib/completion/git-prompt.sh\n>  contrib/completion/git-prompt.sh | 9 +++++----\n>  1 file changed, 5 insertions(+), 4 deletions(-)\n> \n> diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\n> index 70515cc..3ab2a69 100644\n> --- a/contrib/completion/git-prompt.sh\n> +++ b/contrib/completion/git-prompt.sh\n> @@ -13,10 +13,10 @@\n>  #    3a) Change your PS1 to call __git_ps1 as\n>  #        command-substitution:\n>  #        Bash: PS1='[\\u@\\h \\W$(__git_ps1 \" (%s)\")]\\$ '\n> -#        ZSH:  PS1='[%n@%m %c$(__git_ps1 \" (%s)\")]\\$ '\n> +#        ZSH:  setopt PROMPT_SUBST ; PS1='[%n@%m %c$(__git_ps1 \" (%s)\")]\\$ '\n>  #        the optional argument will be used as format string.\n> -#    3b) Alternatively, if you are using bash, __git_ps1 can be\n> -#        used for PROMPT_COMMAND with two parameters, <pre> and\n> +#    3b) Alternatively, if you are using Bash or ZSH, __git_ps1 can\n> +#        be used for PROMPT_COMMAND with two parameters, <pre> and\n\nThe git-prompt script only supports bash and zsh, so that \"if you are\nusing Bash or ZSH\" part doesn't say much, does it?  Furthermore, zsh\ndoesn't have PROMPT_COMMAND but a similar facility.  So how about\nsomething like this instead?\n\n#    3b) Alternatively, __git_ps1 can be used for PROMPT_COMMAND in\n#        Bash or for precmd in ZSH with two parameters, <pre> and\n\n\n>  #        <post>, which are strings you would put in $PS1 before\n>  #        and after the status string generated by the git-prompt\n>  #        machinery.  e.g.\n> @@ -78,7 +78,8 @@\n>  #\n>  # If you would like a colored hint about the current dirty state, set\n>  # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on\n> -# the colored output of \"git status -sb\".\n> +# the colored output of \"git status -sb\" and are available only when\n> +# using __git_ps1 for PROMPT_COMMAND.\n\nLikewise:\n\n# using __git_ps1 for PROMPT_COMMAND or precmd.\n\n>  \n>  # __gitdir accepts 0 or 1 arguments (i.e., location)\n>  # returns location of .git repo\n> -- \n> 1.8.3.1.487.g28387b2\n> \n"},{"id":"221689","messageId":"loom.20130622T162818-125@post.gmane.org","threadId":"34234","inReplyTo":"354a860e12a3463ce5d031c0dc46d095841f717d.1371780085.git.erdavila@gmail.com","subject":"Re: [PATCH 2/4] git-prompt.sh: refactor colored prompt code","fromName":"Øystein Walle","fromEmail":"oystwa@gmail.com","sentAt":"2013-06-22T14:37:03Z","receivedAt":"2013-06-22T14:37:03Z","isPatch":true,"sender":{"key":"oystwa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/794585?v=4"},"body":"Eduardo R. D'Avila <erdavila <at> gmail.com> writes:\n\n> +\t\tlocal c_red='\\[\\e[31m\\]'\n> +\t\tlocal c_green='\\[\\e[32m\\]'\n> +\t\tlocal c_lblue='\\[\\e[1;34m\\]'\n> +\t\tlocal c_clear='\\[\\e[0m\\]'\n>  \tfi\n> -\tlocal c_red='\\e[31m'\n> -\tlocal c_green='\\e[32m'\n> -\tlocal c_lblue='\\e[1;34m'\n> -\tlocal c_clear='\\e[0m'\n\nI've gotten the impression it's better to use tput to generate the escape \nsequences instead of hardcoding them. So something like:\n\n\tlocal c_red='\\['\"$(tput setaf 1)\"'\\]'\n\tlocal c_green='\\['\"$(tput setaf 2)\"'\\]'\n\tlocal c_green='\\['\"$(tput setaf 4)\"'\\]'\n\tlocal c_clear='\\['\"$(tput sgr0)\"'\\]'\n\nwhich is technically cleaner, if not visually.\n \nThe problem with that approach is that tput will be run several times for \neach prompt, so it would be best if the color variables were global. Another \nthing is that you rely on tput being available.\n\nØsse\n"},{"id":"221695","messageId":"CAOz-D1L3mrqTKwpnRVEEfZayFNX+eKVNC1-Ewy45tmf9MPQhtQ@mail.gmail.com","threadId":"34234","inReplyTo":"20130622130604.GK20052@goldbirke","subject":"Re: [PATCH 1/4] t9903: add tests for git-prompt pcmode","fromName":"Eduardo D'Avila","fromEmail":"erdavila@gmail.com","sentAt":"2013-06-22T16:32:38Z","receivedAt":"2013-06-22T16:32:38Z","isPatch":true,"sender":{"key":"erdavila@gmail.com","avatar":"https://avatars.githubusercontent.com/u/341488?v=4"},"body":"2013/6/22 SZEDER Gábor <szeder@ira.uka.de>:\n> On Thu, Jun 20, 2013 at 11:25:26PM -0300, Eduardo R. D'Avila wrote:\n>> git-prompt.sh lacks tests for PROMPT_COMMAND mode.\n>>\n>> Add tests for:\n>> * pcmode prompt without colors\n>> * pcmode prompt with colors for bash\n>> * pcmode prompt with colors for zsh\n>>\n>> Having these tests enables an upcoming refactor in\n>> a safe way.\n>>\n>> Signed-off-by: Eduardo R. D'Avila <erdavila@gmail.com>\n>\n> I doubt the value of separate tests for zsh.  They might make sense as\n> long as there are different code paths for doing coloring for the two\n> shells, but after your refactorization in 2/4 there is only one common\n> block of if statements, which is already thoroughly excercised by your\n> tests for bash, making the separate tests for zsh redundant.\n\nThese tests where important to make sure that I wouldn't break anything during\nthe refactorization. Having them pass before *and* after refactorization\nguarantees that nothing was broken (except for some subtle case that might have\nnot be included in the tests).\n\nHowever, I agree that they became redundant.\n\nWould it make sense to include a patch that only removes the zsh\ntests, after the\nrefactorization? I'm considering that *1* simple zsh test must be kept during\nthis removal, to make sure the code path for zsh is run.\n\n\nEduardo\n"},{"id":"221696","messageId":"CAOz-D1+LoAnoRLgnyRYtq5LQR32RyXp4RR2M5pPTaxaGcXM4yg@mail.gmail.com","threadId":"34234","inReplyTo":"354a860e12a3463ce5d031c0dc46d095841f717d.1371780085.git.erdavila@gmail.com","subject":"Re: [PATCH 2/4] git-prompt.sh: refactor colored prompt code","fromName":"Eduardo D'Avila","fromEmail":"erdavila@gmail.com","sentAt":"2013-06-22T16:45:38Z","receivedAt":"2013-06-22T16:45:38Z","isPatch":true,"sender":{"key":"erdavila@gmail.com","avatar":"https://avatars.githubusercontent.com/u/341488?v=4"},"body":"2013/6/22 Øystein Walle <oystwa@gmail.com>:\n> I've gotten the impression it's better to use tput to generate the escape\n> sequences instead of hardcoding them. So something like:\n>\n> local c_red='\\['\"$(tput setaf 1)\"'\\]'\n> local c_green='\\['\"$(tput setaf 2)\"'\\]'\n> local c_green='\\['\"$(tput setaf 4)\"'\\]'\n> local c_clear='\\['\"$(tput sgr0)\"'\\]'\n>\n> which is technically cleaner, if not visually.\n>\n> The problem with that approach is that tput will be run several times for\n> each prompt, so it would be best if the color variables were global. Another\n> thing is that you rely on tput being available.\n\nAre there any guidelines regarding global shell script variables?\n\nI'm considering doing this:\n   __git_c_red=\"\\[$(tput setaf 1 || echo -e '\\e[31m')\\]\"\nwhich handles the case where tput is not available.\n\n\nEduardo\n"},{"id":"221705","messageId":"7vobaxgtt6.fsf@alter.siamese.dyndns.org","threadId":"34234","inReplyTo":"CAOz-D1L3mrqTKwpnRVEEfZayFNX+eKVNC1-Ewy45tmf9MPQhtQ@mail.gmail.com","subject":"Re: [PATCH 1/4] t9903: add tests for git-prompt pcmode","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-23T07:39:01Z","receivedAt":"2013-06-23T07:39:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Eduardo D'Avila\" <erdavila@gmail.com> writes:\n\n> However, I agree that they became redundant.\n>\n> Would it make sense to include a patch that only removes the zsh\n> tests, after the refactorization?\n\nI think that would be a sensible thing to do.\n\nIn any case, Szeder seems to be giving a good guidance on patches in\nthe completion area (not just this series), and completion is not\nsomething I am deeply interested in, so I'll watch from the sidelines\nand wait until you two to figure out the best solution ;-)\n\nThanks for working on this topic.\n"},{"id":"221720","messageId":"20130623145157.GN20052@goldbirke","threadId":"34234","inReplyTo":"CAOz-D1+LoAnoRLgnyRYtq5LQR32RyXp4RR2M5pPTaxaGcXM4yg@mail.gmail.com","subject":"Re: [PATCH 2/4] git-prompt.sh: refactor colored prompt code","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-06-23T14:51:57Z","receivedAt":"2013-06-23T14:51:57Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Sat, Jun 22, 2013 at 01:45:38PM -0300, Eduardo D'Avila wrote:\n> 2013/6/22 Øystein Walle <oystwa@gmail.com>:\n> > I've gotten the impression it's better to use tput to generate the escape\n> > sequences instead of hardcoding them. So something like:\n> >\n> > local c_red='\\['\"$(tput setaf 1)\"'\\]'\n> > local c_green='\\['\"$(tput setaf 2)\"'\\]'\n> > local c_green='\\['\"$(tput setaf 4)\"'\\]'\n> > local c_clear='\\['\"$(tput sgr0)\"'\\]'\n> >\n> > which is technically cleaner, if not visually.\n> >\n> > The problem with that approach is that tput will be run several times for\n> > each prompt, so it would be best if the color variables were global. Another\n> > thing is that you rely on tput being available.\n> \n> Are there any guidelines regarding global shell script variables?\n\nThere are a couple of global variables in the completion script, they\nare all prefixed with \"__git_\", e.g. $__git_porcelain_commands.  In\nthe prompt script we don't have any global variables at the moment,\nbut if we were to create some, then they should be prefixed similarly.\nOr perhaps with \"__git_ps1_\".  Anyway, in case of a global variable\nI'd spell out \"color\" completely instead of abbreviating it as \"c\".\n\n> I'm considering doing this:\n>    __git_c_red=\"\\[$(tput setaf 1 || echo -e '\\e[31m')\\]\"\n> which handles the case where tput is not available.\n\nTo me 'tput setaf 1' is just a little bit less greek than '\\e[31m'.\n\nI'm wary of relying on tput's availability.  It's part of ncurses,\nwhich is an essential package in many (most? all?) linux distros, but\nI don't know how it is with other supported platforms.  So I think\nwe'd have to stick to the hard-coded escape sequences as a fallback\nanyway.  And if we can't get rid of these escape sequences completely,\nthen I don't really see the point of using tput, especially\nconsidering the additional delay that would be caused by fork()ing\nfour subshells and fork()+exec()ing four external commands on Windows.\n\nHowever, I don't know much about the caveats of terminals, so I can't\njudge the benefits of using tput instead of the escape sequences.  \n\n\nGábor\n"},{"id":"221825","messageId":"20130624162134.GA2136@goldbirke","threadId":"34234","inReplyTo":"CAOz-D1L3mrqTKwpnRVEEfZayFNX+eKVNC1-Ewy45tmf9MPQhtQ@mail.gmail.com","subject":"Re: [PATCH 1/4] t9903: add tests for git-prompt pcmode","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-06-24T16:21:34Z","receivedAt":"2013-06-24T16:21:34Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Sat, Jun 22, 2013 at 01:32:38PM -0300, Eduardo D'Avila wrote:\n> These tests where important to make sure that I wouldn't break anything during\n> the refactorization. Having them pass before *and* after refactorization\n> guarantees that nothing was broken (except for some subtle case that might have\n> not be included in the tests).\n> \n> However, I agree that they became redundant.\n> \n> Would it make sense to include a patch that only removes the zsh\n> tests, after the\n> refactorization?\n\nThat would be fine with me.\n\n\nThanks,\nGábor\n"},{"id":"221918","messageId":"CAOz-D1Lfh5tnjMriQNQtNYeMUHb=jLbjzxt0=Nru8gPYwVk79A@mail.gmail.com","threadId":"34234","inReplyTo":"20130623145157.GN20052@goldbirke","subject":"Re: [PATCH 2/4] git-prompt.sh: refactor colored prompt code","fromName":"Eduardo R. D'Avila","fromEmail":"erdavila@gmail.com","sentAt":"2013-06-25T01:21:52Z","receivedAt":"2013-06-25T01:21:52Z","isPatch":true,"sender":{"key":"erdavila@gmail.com","avatar":"https://avatars.githubusercontent.com/u/341488?v=4"},"body":"2013/6/23 SZEDER Gábor <szeder@ira.uka.de>:\n> I'm wary of relying on tput's availability.  It's part of ncurses,\n> which is an essential package in many (most? all?) linux distros, but\n> I don't know how it is with other supported platforms.  So I think\n> we'd have to stick to the hard-coded escape sequences as a fallback\n> anyway. (...)\n>\n> However, I don't know much about the caveats of terminals, so I can't\n> judge the benefits of using tput instead of the escape sequences.\n\nI'm exactly in the same situation...\n\n> considering the additional delay that would be caused by fork()ing\n> four subshells and fork()+exec()ing four external commands on Windows.\n\nWell... That would be only once, during script loading.\n\n\nGiven the concerns raised by Gábor (edited and quoted above) and that\nthere is no known issue (afaik) with the current implementation, I'm\ntending to revert to the escape sequences.\n"}]}