{"thread":{"id":"40849","subject":"[PATCH 2/3] bash prompt: remove a redundant command line option","startedAt":"2015-11-21T11:30:07Z","lastAt":"2015-11-21T14:46:40Z","messageCount":4,"participants":["SZEDER Gábor"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"273578","messageId":"1448105409-4494-1-git-send-email-szeder@ira.uka.de","threadId":"40849","inReplyTo":null,"subject":"[PATCH 1/3] bash prompt: test dirty index and worktree while on an orphan branch","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2015-11-21T11:30:07Z","receivedAt":"2015-11-21T11:30:07Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"There is only a single test exercising the dirty state indicator on an\norphan branch, and in that test neither the index nor the worktree are\ndirty.\n\nAdd two failing tests to check the dirty state indicator while either\nthe index is dirty or while both the index and the worktree are dirty\non an orphan branch, and to show that the dirtiness of the index is\nnot displayed in these cases (the forth combination, i.e. clean index\nand dirty worktree are impossible on an orphan branch).  Update the\nexisting dirty state indicator on clean orphan branch test to match\nthe style of the two new tests, most importantly to use 'git checkout\n--orphan' instead of cd-ing into a repository that just happens to be\nempty and clean.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n t/t9903-bash-prompt.sh | 31 ++++++++++++++++++++++++++++---\n 1 file changed, 28 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh\nindex 6b68777b98..2c9d1f928a 100755\n--- a/t/t9903-bash-prompt.sh\n+++ b/t/t9903-bash-prompt.sh\n@@ -273,11 +273,36 @@ test_expect_success 'prompt - dirty status indicator - dirty index and worktree'\n \ttest_cmp expected \"$actual\"\n '\n \n-test_expect_success 'prompt - dirty status indicator - before root commit' '\n-\tprintf \" (master #)\" >expected &&\n+test_expect_success 'prompt - dirty status indicator - orphan branch - clean' '\n+\tprintf \" (orphan #)\" >expected &&\n+\ttest_when_finished \"git checkout master\" &&\n+\tgit checkout --orphan orphan &&\n+\tgit reset --hard &&\n+\t(\n+\t\tGIT_PS1_SHOWDIRTYSTATE=y &&\n+\t\t__git_ps1 >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_failure 'prompt - dirty status indicator - orphan branch - dirty index' '\n+\tprintf \" (orphan +)\" >expected &&\n+\ttest_when_finished \"git checkout master\" &&\n+\tgit checkout --orphan orphan &&\n+\t(\n+\t\tGIT_PS1_SHOWDIRTYSTATE=y &&\n+\t\t__git_ps1 >\"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_failure 'prompt - dirty status indicator - orphan branch - dirty index and worktree' '\n+\tprintf \" (orphan *+)\" >expected &&\n+\ttest_when_finished \"git checkout master\" &&\n+\tgit checkout --orphan orphan &&\n+\t>file &&\n \t(\n \t\tGIT_PS1_SHOWDIRTYSTATE=y &&\n-\t\tcd otherrepo &&\n \t\t__git_ps1 >\"$actual\"\n \t) &&\n \ttest_cmp expected \"$actual\"\n-- \n2.6.3.402.geb6a0f7\n"},{"id":"273576","messageId":"1448105409-4494-2-git-send-email-szeder@ira.uka.de","threadId":"40849","inReplyTo":"1448105409-4494-1-git-send-email-szeder@ira.uka.de","subject":"[PATCH 2/3] bash prompt: remove a redundant command line option","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2015-11-21T11:30:08Z","receivedAt":"2015-11-21T11:30:08Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"To get the dirty state indicator __git_ps1() runs 'git diff' with\n'--quiet --exit-code' options.  '--quiet' already implies\n'--exit-code', so the latter is unnecessary and can be removed.\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 07b52bedf1..7a95fbdcfd 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -476,7 +476,7 @@ __git_ps1 ()\n \t\tif [ -n \"${GIT_PS1_SHOWDIRTYSTATE-}\" ] &&\n \t\t   [ \"$(git config --bool bash.showDirtyState)\" != \"false\" ]\n \t\tthen\n-\t\t\tgit diff --no-ext-diff --quiet --exit-code || w=\"*\"\n+\t\t\tgit diff --no-ext-diff --quiet || w=\"*\"\n \t\t\tif [ -n \"$short_sha\" ]; then\n \t\t\t\tgit diff-index --cached --quiet HEAD -- || i=\"+\"\n \t\t\telse\n-- \n2.6.3.402.geb6a0f7\n"},{"id":"273577","messageId":"1448105409-4494-3-git-send-email-szeder@ira.uka.de","threadId":"40849","inReplyTo":"1448105409-4494-1-git-send-email-szeder@ira.uka.de","subject":"[PATCH 3/3] bash prompt: indicate dirty index even on orphan branches","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2015-11-21T11:30:09Z","receivedAt":"2015-11-21T11:30:09Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"__git_ps1() doesn't indicate dirty index while on an orphan branch.\n\nTo check the dirtiness of the index, __git_ps1() runs 'git diff-index\n--cached ... HEAD', which doesn't work on an orphan branch,\nbecause HEAD doesn't point to a valid commit.\n\nRun 'git diff ... --cached' instead, as it does the right thing both\non valid and invalid HEAD, i.e. compares the index to the existing\nHEAD in the former case and to the empty tree in the latter.  This\nfixes the two failing tests added in the first commit of this series.\n\nThe dirtiness of the worktree is already checked with 'git diff' and\nis displayed correctly even on an orphan branch.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n contrib/completion/git-prompt.sh | 5 ++---\n t/t9903-bash-prompt.sh           | 4 ++--\n 2 files changed, 4 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex 7a95fbdcfd..64219e631a 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -477,9 +477,8 @@ __git_ps1 ()\n \t\t   [ \"$(git config --bool bash.showDirtyState)\" != \"false\" ]\n \t\tthen\n \t\t\tgit diff --no-ext-diff --quiet || w=\"*\"\n-\t\t\tif [ -n \"$short_sha\" ]; then\n-\t\t\t\tgit diff-index --cached --quiet HEAD -- || i=\"+\"\n-\t\t\telse\n+\t\t\tgit diff --no-ext-diff --cached --quiet || i=\"+\"\n+\t\t\tif [ -z \"$short_sha\" ] && [ -z \"$i\" ]; then\n \t\t\t\ti=\"#\"\n \t\t\tfi\n \t\tfi\ndiff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh\nindex 2c9d1f928a..af82049f82 100755\n--- a/t/t9903-bash-prompt.sh\n+++ b/t/t9903-bash-prompt.sh\n@@ -285,7 +285,7 @@ test_expect_success 'prompt - dirty status indicator - orphan branch - clean' '\n \ttest_cmp expected \"$actual\"\n '\n \n-test_expect_failure 'prompt - dirty status indicator - orphan branch - dirty index' '\n+test_expect_success 'prompt - dirty status indicator - orphan branch - dirty index' '\n \tprintf \" (orphan +)\" >expected &&\n \ttest_when_finished \"git checkout master\" &&\n \tgit checkout --orphan orphan &&\n@@ -296,7 +296,7 @@ test_expect_failure 'prompt - dirty status indicator - orphan branch - dirty ind\n \ttest_cmp expected \"$actual\"\n '\n \n-test_expect_failure 'prompt - dirty status indicator - orphan branch - dirty index and worktree' '\n+test_expect_success 'prompt - dirty status indicator - orphan branch - dirty index and worktree' '\n \tprintf \" (orphan *+)\" >expected &&\n \ttest_when_finished \"git checkout master\" &&\n \tgit checkout --orphan orphan &&\n-- \n2.6.3.402.geb6a0f7\n"},{"id":"273579","messageId":"1448117200-7299-1-git-send-email-szeder@ira.uka.de","threadId":"40849","inReplyTo":"1448105409-4494-2-git-send-email-szeder@ira.uka.de","subject":"[PATCH v1.5 2/3] bash prompt: remove a redundant 'git diff' option","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2015-11-21T14:46:40Z","receivedAt":"2015-11-21T14:46:40Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"To get the dirty state indicator __git_ps1() runs 'git diff' with\n'--quiet --exit-code' options.  '--quiet' already implies\n'--exit-code', so the latter is unnecessary and can be removed.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\nReworded the Subject: line, because it sounded as if the patch were to\nremove a command line option of the bash prompt script.\n\nThe rest is unchanged.\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 07b52bedf1..7a95fbdcfd 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -476,7 +476,7 @@ __git_ps1 ()\n \t\tif [ -n \"${GIT_PS1_SHOWDIRTYSTATE-}\" ] &&\n \t\t   [ \"$(git config --bool bash.showDirtyState)\" != \"false\" ]\n \t\tthen\n-\t\t\tgit diff --no-ext-diff --quiet --exit-code || w=\"*\"\n+\t\t\tgit diff --no-ext-diff --quiet || w=\"*\"\n \t\t\tif [ -n \"$short_sha\" ]; then\n \t\t\t\tgit diff-index --cached --quiet HEAD -- || i=\"+\"\n \t\t\telse\n-- \n2.6.3.402.geb6a0f7\n"}]}