{"thread":{"id":"30252","subject":"[PATCH] tests: add tests for the bash prompt functions in the completion script","startedAt":"2012-04-15T20:31:49Z","lastAt":"2012-04-17T07:37:18Z","messageCount":14,"participants":["SZEDER Gábor","Felipe Contreras","Jonathan Nieder","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"189357","messageId":"1334521909-32581-1-git-send-email-szeder@ira.uka.de","threadId":"30252","inReplyTo":null,"subject":"[PATCH] tests: add tests for the bash prompt functions in the completion script","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-15T20:31:49Z","receivedAt":"2012-04-15T20:31:49Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"The tests cover the discovery of the .git directory in the __gitdir()\nfunction in different scenarios, and the prompt itself, i.e. branch\nname, detached heads, operations (rebase, merge, cherry-pick, bisect),\nand status indicators (dirty, stash, untracked files; but not the\nupstream status).\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n\nGoes on top of fc/completion-tests (b8574ba7).\n\n t/t9902-completion.sh |  436 +++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 436 insertions(+)\n\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 3bbec79b..6edbaa72 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -114,4 +114,440 @@ test_expect_success 'double dash \"git checkout\"' '\n \ttest_completion \"git checkout --\"\n '\n \n+actual=\"$TRASH_DIRECTORY/actual\"\n+\n+test_expect_success 'setup for prompt tests' '\n+\tmkdir -p subdir/subsubdir &&\n+\tgit init otherrepo &&\n+\techo 1 > file &&\n+\tgit add file &&\n+\ttest_tick &&\n+\tgit commit -m initial &&\n+\tgit tag -a -m msg1 t1 &&\n+\tgit checkout -b b1 &&\n+\techo 2 > file &&\n+\tgit commit -m \"second b1\" file &&\n+\techo 3 > file &&\n+\tgit commit -m \"third b1\" file &&\n+\tgit tag -a -m msg2 t2 &&\n+\tgit checkout -b b2 master &&\n+\techo 0 > file &&\n+\tgit commit -m \"second b2\" file &&\n+\tgit checkout master\n+'\n+\n+test_expect_success 'gitdir - from command line (through $__git_dir)' '\n+\techo \"$TRASH_DIRECTORY/otherrepo/.git\" > expected &&\n+\t(\n+\t\t__git_dir=\"$TRASH_DIRECTORY/otherrepo/.git\" &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - repo as argument' '\n+\techo \"otherrepo/.git\" > expected &&\n+\t__gitdir \"otherrepo\" > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - remote as argument' '\n+\techo \"remote\" > expected &&\n+\t__gitdir \"remote\" > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - .git directory in cwd' '\n+\techo \".git\" > expected &&\n+\t__gitdir > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - .git directory in parent' '\n+\techo \"$TRASH_DIRECTORY/.git\" > expected &&\n+\t(\n+\t\tcd subdir &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - cwd is a .git directory' '\n+\techo \".\" > expected &&\n+\t(\n+\t\tcd .git &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - parent is a .git directory' '\n+\techo \"$TRASH_DIRECTORY/.git\" > expected &&\n+\t(\n+\t\tcd .git/refs &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_failure 'gitdir - $GIT_DIR set while .git directory in cwd' '\n+\techo \"$TRASH_DIRECTORY/otherrepo/.git\" > expected &&\n+\t(\n+\t\tGIT_DIR=\"$TRASH_DIRECTORY/otherrepo/.git\" &&\n+\t\texport GIT_DIR &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - $GIT_DIR set while .git directory in parent' '\n+\techo \"$TRASH_DIRECTORY/otherrepo/.git\" > expected &&\n+\t(\n+\t\tGIT_DIR=\"$TRASH_DIRECTORY/otherrepo/.git\" &&\n+\t\texport GIT_DIR &&\n+\t\tcd subdir &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - gitfile in cwd' '\n+\techo \"$TRASH_DIRECTORY/otherrepo/.git\" > expected &&\n+\techo \"gitdir: $TRASH_DIRECTORY/otherrepo/.git\" > subdir/.git &&\n+\ttest_when_finished \"rm -f subdir/.git\" &&\n+\t(\n+\t\tcd subdir &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - gitfile in parent' '\n+\techo \"$TRASH_DIRECTORY/otherrepo/.git\" > expected &&\n+\techo \"gitdir: $TRASH_DIRECTORY/otherrepo/.git\" > subdir/.git &&\n+\ttest_when_finished \"rm -f subdir/.git\" &&\n+\t(\n+\t\tcd subdir/subsubdir &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success SYMLINKS 'gitdir - resulting path avoids symlinks' '\n+\techo \"$TRASH_DIRECTORY/otherrepo/.git\" >expected &&\n+\tmkdir otherrepo/dir &&\n+\ttest_when_finished \"rm -rf otherrepo/dir\" &&\n+\tln -s otherrepo/dir link &&\n+\ttest_when_finished \"rm -f link\" &&\n+\t(\n+\t\tcd link &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'gitdir - not a git repository' '\n+\t(\n+\t\tcd subdir/subsubdir &&\n+\t\tGIT_CEILING_DIRECTORIES=\"$TRASH_DIRECTORY\" &&\n+\t\texport GIT_CEILING_DIRECTORIES &&\n+\t\ttest_must_fail __gitdir\n+\t)\n+'\n+\n+test_expect_success 'prompt - branch name' '\n+\tprintf \" (master)\" > expected &&\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - detached head' '\n+\tprintf \" ((%s...))\" $(git log -1 --format=\"%h\" b1^) > expected &&\n+\tgit checkout b1^ &&\n+\ttest_when_finished \"git checkout master\" &&\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - describe detached head - contains' '\n+\tprintf \" ((t2~1))\" > expected &&\n+\tgit checkout b1^ &&\n+\ttest_when_finished \"git checkout master\" &&\n+\t(\n+\t\tGIT_PS1_DESCRIBE_STYLE=contains &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - describe detached head - branch' '\n+\tprintf \" ((b1~1))\" > expected &&\n+\tgit checkout b1^ &&\n+\ttest_when_finished \"git checkout master\" &&\n+\t(\n+\t\tGIT_PS1_DESCRIBE_STYLE=branch &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - describe detached head - describe' '\n+\tprintf \" ((t1-1-g%s))\" $(git log -1 --format=\"%h\" b1^) > expected &&\n+\tgit checkout b1^ &&\n+\ttest_when_finished \"git checkout master\" &&\n+\t(\n+\t\tGIT_PS1_DESCRIBE_STYLE=describe &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - describe detached head - default' '\n+\tprintf \" ((t2))\" > expected &&\n+\tgit checkout --detach b1 &&\n+\ttest_when_finished \"git checkout master\" &&\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - inside .git directory' '\n+\tprintf \" (GIT_DIR!)\" > expected &&\n+\t(\n+\t\tcd .git &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - deep inside .git directory' '\n+\tprintf \" (GIT_DIR!)\" > expected &&\n+\t(\n+\t\tcd .git/refs &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - inside bare repository' '\n+\tprintf \" (BARE:master)\" > expected &&\n+\tgit init --bare bare.git &&\n+\ttest_when_finished \"rm -rf bare.git\" &&\n+\t(\n+\t\tcd bare.git &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - interactive rebase' '\n+\tprintf \" (b1|REBASE-i)\" > expected\n+\techo \"#!$SHELL_PATH\" >fake_editor.sh &&\n+\tcat >>fake_editor.sh <<\\EOF &&\n+echo \"edit $(git log -1 --format=\"%h\")\" > \"$1\"\n+EOF\n+\ttest_when_finished \"rm -f fake_editor.sh\" &&\n+\tchmod a+x fake_editor.sh &&\n+\ttest_set_editor \"$TRASH_DIRECTORY/fake_editor.sh\" &&\n+\tgit checkout b1 &&\n+\ttest_when_finished \"git checkout master\" &&\n+\tgit rebase -i HEAD^ &&\n+\ttest_when_finished \"git rebase --abort\"\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - rebase merge' '\n+\tprintf \" (b2|REBASE-m)\" > expected &&\n+\tgit checkout b2 &&\n+\ttest_when_finished \"git checkout master\" &&\n+\ttest_must_fail git rebase --merge b1 b2 &&\n+\ttest_when_finished \"git rebase --abort\" &&\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - rebase' '\n+\tprintf \" ((t2)|REBASE)\" > expected &&\n+\tgit checkout b2 &&\n+\ttest_when_finished \"git checkout master\" &&\n+\ttest_must_fail git rebase b1 b2 &&\n+\ttest_when_finished \"git rebase --abort\" &&\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - merge' '\n+\tprintf \" (b1|MERGING)\" > expected &&\n+\tgit checkout b1 &&\n+\ttest_when_finished \"git checkout master\" &&\n+\ttest_must_fail git merge b2 &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - cherry-pick' '\n+\tprintf \" (master|CHERRY-PICKING)\" > expected &&\n+\ttest_must_fail git cherry-pick b1 &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - bisect' '\n+\tprintf \" (master|BISECTING)\" > expected &&\n+\tgit bisect start &&\n+\ttest_when_finished \"git bisect reset\" &&\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - dirty status indicator - clean' '\n+\tprintf \" (master)\" > expected &&\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_success 'prompt - dirty status indicator - dirty worktree' '\n+\tprintf \" (master *)\" > expected &&\n+\techo \"dirty\" > file &&\n+\ttest_when_finished \"git 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_success 'prompt - dirty status indicator - dirty index' '\n+\tprintf \" (master +)\" > 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\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - dirty status indicator - dirty index and worktree' '\n+\tprintf \" (master *+)\" > 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_SHOWDIRTYSTATE=y &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - dirty status indicator - before root commit' '\n+\tprintf \" (master #)\" > expected &&\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+'\n+\n+test_expect_success 'prompt - dirty status indicator - disabled by config' '\n+\tprintf \" (master)\" > expected &&\n+\techo \"dirty\" > file &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\ttest_config bash.showDirtyState false &&\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_success 'prompt - dirty status indicator - not shown inside .git directory' '\n+\tprintf \" (GIT_DIR!)\" > expected &&\n+\techo \"dirty\" > file &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\t(\n+\t\tGIT_PS1_SHOWDIRTYSTATE=y &&\n+\t\tcd .git &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - stash status indicator - no stash' '\n+\tprintf \" (master)\" > expected &&\n+\t(\n+\t\tGIT_PS1_SHOWSTASHSTATE=y &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - stash status indicator - stash' '\n+\tprintf \" (master $)\" > 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\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - stash status indicator - not shown inside .git directory' '\n+\tprintf \" (GIT_DIR!)\" > 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\tcd .git &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - untracked files status indicator - no untracked files' '\n+\tprintf \" (master)\" > expected &&\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' '\n+\tprintf \" (master %%)\" > expected &&\n+\t(\n+\t\tGIT_PS1_SHOWUNTRACKEDFILES=y &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - untracked files status indicator - not shown inside .git directory' '\n+\tprintf \" (GIT_DIR!)\" > expected &&\n+\t(\n+\t\tGIT_PS1_SHOWUNTRACKEDFILES=y &&\n+\t\tcd .git &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - format string starting with dash' '\n+\tprintf -- \"-master\" > expected &&\n+\t__git_ps1 \"-%s\" > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n test_done\n-- \n1.7.10.177.g26c39\n"},{"id":"189358","messageId":"CAMP44s3LJO_Ryc-ONjF+rEHCb1hB8+4Muar6pzjD3zrazYqK+A@mail.gmail.com","threadId":"30252","inReplyTo":"1334521909-32581-1-git-send-email-szeder@ira.uka.de","subject":"Re: [PATCH] tests: add tests for the bash prompt functions in the completion script","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-15T20:56:36Z","receivedAt":"2012-04-15T20:56:36Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Sun, Apr 15, 2012 at 11:31 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n> The tests cover the discovery of the .git directory in the __gitdir()\n> function in different scenarios, and the prompt itself, i.e. branch\n> name, detached heads, operations (rebase, merge, cherry-pick, bisect),\n> and status indicators (dirty, stash, untracked files; but not the\n> upstream status).\n>\n> Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>\n> ---\n>\n> Goes on top of fc/completion-tests (b8574ba7).\n>\n>  t/t9902-completion.sh |  436 +++++++++++++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 436 insertions(+)\n\nPerhaps it would make sense to create another file for these,\nspecially since there's the plan of splitting the prompt stuff to a\nseparate file.\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"189375","messageId":"20120416094938.GE2900@goldbirke","threadId":"30252","inReplyTo":"CAMP44s3LJO_Ryc-ONjF+rEHCb1hB8+4Muar6pzjD3zrazYqK+A@mail.gmail.com","subject":"Re: [PATCH] tests: add tests for the bash prompt functions in the completion script","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-16T09:49:38Z","receivedAt":"2012-04-16T09:49:38Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi,\n\nOn Sun, Apr 15, 2012 at 11:56:36PM +0300, Felipe Contreras wrote:\n> On Sun, Apr 15, 2012 at 11:31 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n> > The tests cover the discovery of the .git directory in the __gitdir()\n> > function in different scenarios, and the prompt itself, i.e. branch\n> > name, detached heads, operations (rebase, merge, cherry-pick, bisect),\n> > and status indicators (dirty, stash, untracked files; but not the\n> > upstream status).\n> >\n> > Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>\n> > ---\n> >\n> > Goes on top of fc/completion-tests (b8574ba7).\n> >\n> >  t/t9902-completion.sh |  436 +++++++++++++++++++++++++++++++++++++++++++++++++\n> >  1 file changed, 436 insertions(+)\n> \n> Perhaps it would make sense to create another file for these,\n\nI thought about that briefly but decided against it to avoid\nduplicating the bash-specific checks at the beginning, but I don't\ncare that much either way.\n\n> specially since there's the plan of splitting the prompt stuff to a\n> separate file.\n\nOh, I was not aware of such a plan.  What would be the benefits of\nsuch a move, why is it necessary?  Where would you split it up?  In\nparticular, what would happen with __gitdir(), which is used in many\ncompletion functions and in __git_ps1() as well?\n\n\nBest,\nGábor\n"},{"id":"189376","messageId":"CAMP44s0vkH9iE4MoV7HgGwOXna40pAL=h6be13qdreexp5_14w@mail.gmail.com","threadId":"30252","inReplyTo":"20120416094938.GE2900@goldbirke","subject":"Re: [PATCH] tests: add tests for the bash prompt functions in the completion script","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-16T10:04:41Z","receivedAt":"2012-04-16T10:04:41Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"2012/4/16 SZEDER Gábor <szeder@ira.uka.de>:\n> Hi,\n>\n> On Sun, Apr 15, 2012 at 11:56:36PM +0300, Felipe Contreras wrote:\n>> On Sun, Apr 15, 2012 at 11:31 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n>> > The tests cover the discovery of the .git directory in the __gitdir()\n>> > function in different scenarios, and the prompt itself, i.e. branch\n>> > name, detached heads, operations (rebase, merge, cherry-pick, bisect),\n>> > and status indicators (dirty, stash, untracked files; but not the\n>> > upstream status).\n>> >\n>> > Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>\n>> > ---\n>> >\n>> > Goes on top of fc/completion-tests (b8574ba7).\n>> >\n>> >  t/t9902-completion.sh |  436 +++++++++++++++++++++++++++++++++++++++++++++++++\n>> >  1 file changed, 436 insertions(+)\n>>\n>> Perhaps it would make sense to create another file for these,\n>\n> I thought about that briefly but decided against it to avoid\n> duplicating the bash-specific checks at the beginning, but I don't\n> care that much either way.\n>\n>> specially since there's the plan of splitting the prompt stuff to a\n>> separate file.\n>\n> Oh, I was not aware of such a plan.  What would be the benefits of\n> such a move, why is it necessary?  Where would you split it up?  In\n> particular, what would happen with __gitdir(), which is used in many\n> completion functions and in __git_ps1() as well?\n\nI guess __gitdir() would be duplicated, I don't think that has been discussed.\n\nhttp://thread.gmane.org/gmane.comp.version-control.git/194188\n\nBasically splitting helps for systems that use bash-completion, and\nalso helps for zsh users who don't want the bash completion, but still\nwant __git_ps1(). I split the file myself for this reason.\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"189378","messageId":"20120416102014.GF2900@goldbirke","threadId":"30252","inReplyTo":"CAMP44s0vkH9iE4MoV7HgGwOXna40pAL=h6be13qdreexp5_14w@mail.gmail.com","subject":"Re: [PATCH] tests: add tests for the bash prompt functions in the completion script","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-16T10:20:14Z","receivedAt":"2012-04-16T10:20:14Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Mon, Apr 16, 2012 at 01:04:41PM +0300, Felipe Contreras wrote:\n> >> specially since there's the plan of splitting the prompt stuff to a\n> >> separate file.\n> >\n> > Oh, I was not aware of such a plan.  What would be the benefits of\n> > such a move, why is it necessary?  Where would you split it up?  In\n> > particular, what would happen with __gitdir(), which is used in many\n> > completion functions and in __git_ps1() as well?\n> \n> I guess __gitdir() would be duplicated, I don't think that has been discussed.\n> \n> http://thread.gmane.org/gmane.comp.version-control.git/194188\n> \n> Basically splitting helps for systems that use bash-completion, and\n> also helps for zsh users who don't want the bash completion, but still\n> want __git_ps1(). I split the file myself for this reason.\n\nThanks for the pointer, those are valid reasons.  I'll wait a day or\ntwo for feedback, then resubmit as a different test script.\n\n\nGábor\n"},{"id":"189422","messageId":"20120416160124.GL5813@burratino","threadId":"30252","inReplyTo":"20120416094938.GE2900@goldbirke","subject":"Re: [PATCH] tests: add tests for the bash prompt functions in the completion script","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-16T16:01:24Z","receivedAt":"2012-04-16T16:01:24Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"SZEDER Gábor wrote:\n\n> I thought about that briefly but decided against it to avoid\n> duplicating the bash-specific checks at the beginning, but I don't\n> care that much either way.\n\nMaybe a t/lib-completion.sh would take care of that.  FWIW a clean\nsplit in the test script so it doesn't grow into something like the\ncurrent fast-import tests sounds like a good idea to me. :)\n"},{"id":"189479","messageId":"1334614176-2963-1-git-send-email-szeder@ira.uka.de","threadId":"30252","inReplyTo":"20120416160124.GL5813@burratino","subject":"[PATCH v2 1/2] tests: move code to run completion tests under bash into a helper library","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-16T22:09:35Z","receivedAt":"2012-04-16T22:09:35Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n\nOn Mon, Apr 16, 2012 at 11:01:24AM -0500, Jonathan Nieder wrote:\n> SZEDER Gábor wrote:\n> \n> > I thought about that briefly but decided against it to avoid\n> > duplicating the bash-specific checks at the beginning, but I don't\n> > care that much either way.\n> \n> Maybe a t/lib-completion.sh would take care of that.\n\nHere you go.  I put only the conditionals to run the test script under\nBash and the sourcing of test-lib.sh into t/lib-completion.sh, because\nthat's the common part that is required by the prompt tests, too.  So in\nthe end I'm not sure that t/lib-completion.sh is the right name for this\nfile.\n\nThis patch could probably be squashed into the first commit of\nfc/completion-tests, i.e. 5c293a6b (tests: add initial bash completion\ntests, 2012-04-12).\n\n t/lib-completion.sh   |   17 +++++++++++++++++\n t/t9902-completion.sh |   14 +-------------\n 2 files changed, 18 insertions(+), 13 deletions(-)\n create mode 100644 t/lib-completion.sh\n\ndiff --git a/t/lib-completion.sh b/t/lib-completion.sh\nnew file mode 100644\nindex 00000000..3d85feb2\n--- /dev/null\n+++ b/t/lib-completion.sh\n@@ -0,0 +1,17 @@\n+#!/bin/sh\n+#\n+# Ensures that tests of the completion script are run under Bash.\n+\n+if test -n \"$BASH\" && test -z \"$POSIXLY_CORRECT\"; then\n+\t# we are in full-on bash mode\n+\ttrue\n+elif type bash >/dev/null 2>&1; then\n+\t# execute in full-on bash mode\n+\tunset POSIXLY_CORRECT\n+\texec bash \"$0\" \"$@\"\n+else\n+\techo '1..0 #SKIP skipping bash completion tests; bash not available'\n+\texit 0\n+fi\n+\n+. ./test-lib.sh\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex a6eaa15c..90b2f22e 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -3,21 +3,9 @@\n # Copyright (c) 2012 Felipe Contreras\n #\n \n-if test -n \"$BASH\" && test -z \"$POSIXLY_CORRECT\"; then\n-\t# we are in full-on bash mode\n-\ttrue\n-elif type bash >/dev/null 2>&1; then\n-\t# execute in full-on bash mode\n-\tunset POSIXLY_CORRECT\n-\texec bash \"$0\" \"$@\"\n-else\n-\techo '1..0 #SKIP skipping bash completion tests; bash not available'\n-\texit 0\n-fi\n-\n test_description='test bash completion'\n \n-. ./test-lib.sh\n+. ./lib-completion.sh\n \n complete ()\n {\n-- \n1.7.10.216.gb52c0\n"},{"id":"189478","messageId":"1334614176-2963-2-git-send-email-szeder@ira.uka.de","threadId":"30252","inReplyTo":"1334614176-2963-1-git-send-email-szeder@ira.uka.de","subject":"[PATCH v2 2/2] tests: add tests for the bash prompt functions in the completion script","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-16T22:09:36Z","receivedAt":"2012-04-16T22:09:36Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"The tests cover the discovery of the .git directory in the __gitdir()\nfunction in different scenarios, and the prompt itself, i.e. branch\nname, detached heads, operations (rebase, merge, cherry-pick, bisect),\nand status indicators (dirty, stash, untracked files; but not the\nupstream status).\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n\nTests are the same as in the prvious round, but in a different test file.\n\n t/t9903-bash-prompt.sh |  448 ++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 448 insertions(+)\n create mode 100644 t/t9903-bash-prompt.sh\n\ndiff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh\nnew file mode 100644\nindex 00000000..41c183e6\n--- /dev/null\n+++ b/t/t9903-bash-prompt.sh\n@@ -0,0 +1,448 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2012 SZEDER Gábor\n+#\n+\n+test_description='test git-specific bash prompt functions'\n+\n+. ./lib-completion.sh\n+\n+. \"$GIT_BUILD_DIR/contrib/completion/git-completion.bash\"\n+\n+actual=\"$TRASH_DIRECTORY/actual\"\n+\n+test_expect_success 'setup for prompt tests' '\n+\tmkdir -p subdir/subsubdir &&\n+\tgit init otherrepo &&\n+\techo 1 > file &&\n+\tgit add file &&\n+\ttest_tick &&\n+\tgit commit -m initial &&\n+\tgit tag -a -m msg1 t1 &&\n+\tgit checkout -b b1 &&\n+\techo 2 > file &&\n+\tgit commit -m \"second b1\" file &&\n+\techo 3 > file &&\n+\tgit commit -m \"third b1\" file &&\n+\tgit tag -a -m msg2 t2 &&\n+\tgit checkout -b b2 master &&\n+\techo 0 > file &&\n+\tgit commit -m \"second b2\" file &&\n+\tgit checkout master\n+'\n+\n+test_expect_success 'gitdir - from command line (through $__git_dir)' '\n+\techo \"$TRASH_DIRECTORY/otherrepo/.git\" > expected &&\n+\t(\n+\t\t__git_dir=\"$TRASH_DIRECTORY/otherrepo/.git\" &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - repo as argument' '\n+\techo \"otherrepo/.git\" > expected &&\n+\t__gitdir \"otherrepo\" > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - remote as argument' '\n+\techo \"remote\" > expected &&\n+\t__gitdir \"remote\" > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - .git directory in cwd' '\n+\techo \".git\" > expected &&\n+\t__gitdir > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - .git directory in parent' '\n+\techo \"$TRASH_DIRECTORY/.git\" > expected &&\n+\t(\n+\t\tcd subdir &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - cwd is a .git directory' '\n+\techo \".\" > expected &&\n+\t(\n+\t\tcd .git &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - parent is a .git directory' '\n+\techo \"$TRASH_DIRECTORY/.git\" > expected &&\n+\t(\n+\t\tcd .git/refs &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_failure 'gitdir - $GIT_DIR set while .git directory in cwd' '\n+\techo \"$TRASH_DIRECTORY/otherrepo/.git\" > expected &&\n+\t(\n+\t\tGIT_DIR=\"$TRASH_DIRECTORY/otherrepo/.git\" &&\n+\t\texport GIT_DIR &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - $GIT_DIR set while .git directory in parent' '\n+\techo \"$TRASH_DIRECTORY/otherrepo/.git\" > expected &&\n+\t(\n+\t\tGIT_DIR=\"$TRASH_DIRECTORY/otherrepo/.git\" &&\n+\t\texport GIT_DIR &&\n+\t\tcd subdir &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - gitfile in cwd' '\n+\techo \"$TRASH_DIRECTORY/otherrepo/.git\" > expected &&\n+\techo \"gitdir: $TRASH_DIRECTORY/otherrepo/.git\" > subdir/.git &&\n+\ttest_when_finished \"rm -f subdir/.git\" &&\n+\t(\n+\t\tcd subdir &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'gitdir - gitfile in parent' '\n+\techo \"$TRASH_DIRECTORY/otherrepo/.git\" > expected &&\n+\techo \"gitdir: $TRASH_DIRECTORY/otherrepo/.git\" > subdir/.git &&\n+\ttest_when_finished \"rm -f subdir/.git\" &&\n+\t(\n+\t\tcd subdir/subsubdir &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success SYMLINKS 'gitdir - resulting path avoids symlinks' '\n+\techo \"$TRASH_DIRECTORY/otherrepo/.git\" >expected &&\n+\tmkdir otherrepo/dir &&\n+\ttest_when_finished \"rm -rf otherrepo/dir\" &&\n+\tln -s otherrepo/dir link &&\n+\ttest_when_finished \"rm -f link\" &&\n+\t(\n+\t\tcd link &&\n+\t\t__gitdir > \"$actual\"\n+\t) &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'gitdir - not a git repository' '\n+\t(\n+\t\tcd subdir/subsubdir &&\n+\t\tGIT_CEILING_DIRECTORIES=\"$TRASH_DIRECTORY\" &&\n+\t\texport GIT_CEILING_DIRECTORIES &&\n+\t\ttest_must_fail __gitdir\n+\t)\n+'\n+\n+test_expect_success 'prompt - branch name' '\n+\tprintf \" (master)\" > expected &&\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - detached head' '\n+\tprintf \" ((%s...))\" $(git log -1 --format=\"%h\" b1^) > expected &&\n+\tgit checkout b1^ &&\n+\ttest_when_finished \"git checkout master\" &&\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - describe detached head - contains' '\n+\tprintf \" ((t2~1))\" > expected &&\n+\tgit checkout b1^ &&\n+\ttest_when_finished \"git checkout master\" &&\n+\t(\n+\t\tGIT_PS1_DESCRIBE_STYLE=contains &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - describe detached head - branch' '\n+\tprintf \" ((b1~1))\" > expected &&\n+\tgit checkout b1^ &&\n+\ttest_when_finished \"git checkout master\" &&\n+\t(\n+\t\tGIT_PS1_DESCRIBE_STYLE=branch &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - describe detached head - describe' '\n+\tprintf \" ((t1-1-g%s))\" $(git log -1 --format=\"%h\" b1^) > expected &&\n+\tgit checkout b1^ &&\n+\ttest_when_finished \"git checkout master\" &&\n+\t(\n+\t\tGIT_PS1_DESCRIBE_STYLE=describe &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - describe detached head - default' '\n+\tprintf \" ((t2))\" > expected &&\n+\tgit checkout --detach b1 &&\n+\ttest_when_finished \"git checkout master\" &&\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - inside .git directory' '\n+\tprintf \" (GIT_DIR!)\" > expected &&\n+\t(\n+\t\tcd .git &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - deep inside .git directory' '\n+\tprintf \" (GIT_DIR!)\" > expected &&\n+\t(\n+\t\tcd .git/refs &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - inside bare repository' '\n+\tprintf \" (BARE:master)\" > expected &&\n+\tgit init --bare bare.git &&\n+\ttest_when_finished \"rm -rf bare.git\" &&\n+\t(\n+\t\tcd bare.git &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - interactive rebase' '\n+\tprintf \" (b1|REBASE-i)\" > expected\n+\techo \"#!$SHELL_PATH\" >fake_editor.sh &&\n+\tcat >>fake_editor.sh <<\\EOF &&\n+echo \"edit $(git log -1 --format=\"%h\")\" > \"$1\"\n+EOF\n+\ttest_when_finished \"rm -f fake_editor.sh\" &&\n+\tchmod a+x fake_editor.sh &&\n+\ttest_set_editor \"$TRASH_DIRECTORY/fake_editor.sh\" &&\n+\tgit checkout b1 &&\n+\ttest_when_finished \"git checkout master\" &&\n+\tgit rebase -i HEAD^ &&\n+\ttest_when_finished \"git rebase --abort\"\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - rebase merge' '\n+\tprintf \" (b2|REBASE-m)\" > expected &&\n+\tgit checkout b2 &&\n+\ttest_when_finished \"git checkout master\" &&\n+\ttest_must_fail git rebase --merge b1 b2 &&\n+\ttest_when_finished \"git rebase --abort\" &&\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - rebase' '\n+\tprintf \" ((t2)|REBASE)\" > expected &&\n+\tgit checkout b2 &&\n+\ttest_when_finished \"git checkout master\" &&\n+\ttest_must_fail git rebase b1 b2 &&\n+\ttest_when_finished \"git rebase --abort\" &&\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - merge' '\n+\tprintf \" (b1|MERGING)\" > expected &&\n+\tgit checkout b1 &&\n+\ttest_when_finished \"git checkout master\" &&\n+\ttest_must_fail git merge b2 &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - cherry-pick' '\n+\tprintf \" (master|CHERRY-PICKING)\" > expected &&\n+\ttest_must_fail git cherry-pick b1 &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - bisect' '\n+\tprintf \" (master|BISECTING)\" > expected &&\n+\tgit bisect start &&\n+\ttest_when_finished \"git bisect reset\" &&\n+\t__git_ps1 > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - dirty status indicator - clean' '\n+\tprintf \" (master)\" > expected &&\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_success 'prompt - dirty status indicator - dirty worktree' '\n+\tprintf \" (master *)\" > expected &&\n+\techo \"dirty\" > file &&\n+\ttest_when_finished \"git 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_success 'prompt - dirty status indicator - dirty index' '\n+\tprintf \" (master +)\" > 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\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - dirty status indicator - dirty index and worktree' '\n+\tprintf \" (master *+)\" > 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_SHOWDIRTYSTATE=y &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - dirty status indicator - before root commit' '\n+\tprintf \" (master #)\" > expected &&\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+'\n+\n+test_expect_success 'prompt - dirty status indicator - disabled by config' '\n+\tprintf \" (master)\" > expected &&\n+\techo \"dirty\" > file &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\ttest_config bash.showDirtyState false &&\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_success 'prompt - dirty status indicator - not shown inside .git directory' '\n+\tprintf \" (GIT_DIR!)\" > expected &&\n+\techo \"dirty\" > file &&\n+\ttest_when_finished \"git reset --hard\" &&\n+\t(\n+\t\tGIT_PS1_SHOWDIRTYSTATE=y &&\n+\t\tcd .git &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - stash status indicator - no stash' '\n+\tprintf \" (master)\" > expected &&\n+\t(\n+\t\tGIT_PS1_SHOWSTASHSTATE=y &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - stash status indicator - stash' '\n+\tprintf \" (master $)\" > 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\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - stash status indicator - not shown inside .git directory' '\n+\tprintf \" (GIT_DIR!)\" > 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\tcd .git &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - untracked files status indicator - no untracked files' '\n+\tprintf \" (master)\" > expected &&\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' '\n+\tprintf \" (master %%)\" > expected &&\n+\t(\n+\t\tGIT_PS1_SHOWUNTRACKEDFILES=y &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - untracked files status indicator - not shown inside .git directory' '\n+\tprintf \" (GIT_DIR!)\" > expected &&\n+\t(\n+\t\tGIT_PS1_SHOWUNTRACKEDFILES=y &&\n+\t\tcd .git &&\n+\t\t__git_ps1 > \"$actual\"\n+\t) &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_expect_success 'prompt - format string starting with dash' '\n+\tprintf -- \"-master\" > expected &&\n+\t__git_ps1 \"-%s\" > \"$actual\" &&\n+\ttest_cmp expected \"$actual\"\n+'\n+\n+test_done\n-- \n1.7.10.216.gb52c0\n"},{"id":"189493","messageId":"20120416234923.GZ12613@burratino","threadId":"30252","inReplyTo":"1334614176-2963-1-git-send-email-szeder@ira.uka.de","subject":"Re: [PATCH v2 1/2] tests: move code to run completion tests under bash into a helper library","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-16T23:49:24Z","receivedAt":"2012-04-16T23:49:24Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"SZEDER Gábor wrote:\n\n> --- a/t/t9902-completion.sh\n> +++ b/t/t9902-completion.sh\n> @@ -3,21 +3,9 @@\n>  # Copyright (c) 2012 Felipe Contreras\n>  #\n>  \n> -if test -n \"$BASH\" && test -z \"$POSIXLY_CORRECT\"; then\n> -\t# we are in full-on bash mode\n> -\ttrue\n> -elif type bash >/dev/null 2>&1; then\n> -\t# execute in full-on bash mode\n> -\tunset POSIXLY_CORRECT\n> -\texec bash \"$0\" \"$@\"\n> -else\n> -\techo '1..0 #SKIP skipping bash completion tests; bash not available'\n> -\texit 0\n> -fi\n> -\n>  test_description='test bash completion'\n>  \n> -. ./test-lib.sh\n> +. ./lib-completion.sh\n\nIf I understand correctly, this sources lib-completion immediately\ninstead of following the usual pattern of\n\n\t. ./test-lib.sh\n\t. \"$TEST_DIRECTORY/lib-completion.sh\"\n\nto get the self-execing over with ASAP.  \"$0\" always refers to the\noriginal shell script and not the file being sourced so this should be\nsafe.  Looks good.\n"},{"id":"189494","messageId":"20120416235026.GA12613@burratino","threadId":"30252","inReplyTo":"1334614176-2963-2-git-send-email-szeder@ira.uka.de","subject":"Re: [PATCH v2 2/2] tests: add tests for the bash prompt functions in the completion script","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-16T23:50:26Z","receivedAt":"2012-04-16T23:50:26Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"SZEDER Gábor wrote:\n\n>  create mode 100644 t/t9903-bash-prompt.sh\n\nShould be 100755, no?\n"},{"id":"189496","messageId":"20120417003331.GC2299@goldbirke","threadId":"30252","inReplyTo":"20120416235026.GA12613@burratino","subject":"Re: [PATCH v2 2/2] tests: add tests for the bash prompt functions in the completion script","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-17T00:33:31Z","receivedAt":"2012-04-17T00:33:31Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Mon, Apr 16, 2012 at 06:50:26PM -0500, Jonathan Nieder wrote:\n> SZEDER Gábor wrote:\n> \n> >  create mode 100644 t/t9903-bash-prompt.sh\n> \n> Should be 100755, no?\n\nYes, of course.  Forgot to re-format-patch after amend.\n"},{"id":"189497","messageId":"20120417004244.GD2299@goldbirke","threadId":"30252","inReplyTo":"20120416234923.GZ12613@burratino","subject":"Re: [PATCH v2 1/2] tests: move code to run completion tests under bash into a helper library","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-17T00:42:44Z","receivedAt":"2012-04-17T00:42:44Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Mon, Apr 16, 2012 at 06:49:24PM -0500, Jonathan Nieder wrote:\n> SZEDER Gábor wrote:\n> \n> > --- a/t/t9902-completion.sh\n> > +++ b/t/t9902-completion.sh\n> > @@ -3,21 +3,9 @@\n> >  # Copyright (c) 2012 Felipe Contreras\n> >  #\n> >  \n> > -if test -n \"$BASH\" && test -z \"$POSIXLY_CORRECT\"; then\n> > -\t# we are in full-on bash mode\n> > -\ttrue\n> > -elif type bash >/dev/null 2>&1; then\n> > -\t# execute in full-on bash mode\n> > -\tunset POSIXLY_CORRECT\n> > -\texec bash \"$0\" \"$@\"\n> > -else\n> > -\techo '1..0 #SKIP skipping bash completion tests; bash not available'\n> > -\texit 0\n> > -fi\n> > -\n> >  test_description='test bash completion'\n> >  \n> > -. ./test-lib.sh\n> > +. ./lib-completion.sh\n> \n> If I understand correctly, this sources lib-completion immediately\n> instead of following the usual pattern of\n> \n> \t. ./test-lib.sh\n> \t. \"$TEST_DIRECTORY/lib-completion.sh\"\n\nThere are a couple of other test libs that source test-lib.sh\nthemselves, similarly to the new t/lib-completion.sh.\n\n> to get the self-execing over with ASAP.\n\nExactly, like the original t/t9902-completion.sh.\n\n> \"$0\" always refers to the\n> original shell script and not the file being sourced so this should be\n> safe.  Looks good.\n\nYeah, I tested the tests ;) with dash as /bin/sh; works for me.\n"},{"id":"189503","messageId":"4F8D19B8.1040004@viscovery.net","threadId":"30252","inReplyTo":"1334614176-2963-1-git-send-email-szeder@ira.uka.de","subject":"Re: [PATCH v2 1/2] tests: move code to run completion tests under bash into a helper library","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2012-04-17T07:20:24Z","receivedAt":"2012-04-17T07:20:24Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 4/17/2012 0:09, schrieb SZEDER Gábor:\n> diff --git a/t/lib-completion.sh b/t/lib-completion.sh\n> new file mode 100644\n> index 00000000..3d85feb2\n> --- /dev/null\n> +++ b/t/lib-completion.sh\n> @@ -0,0 +1,17 @@\n> +#!/bin/sh\n> +#\n> +# Ensures that tests of the completion script are run under Bash.\n> +\n> +if test -n \"$BASH\" && test -z \"$POSIXLY_CORRECT\"; then\n> +\t# we are in full-on bash mode\n> +\ttrue\n> +elif type bash >/dev/null 2>&1; then\n> +\t# execute in full-on bash mode\n> +\tunset POSIXLY_CORRECT\n> +\texec bash \"$0\" \"$@\"\n> +else\n> +\techo '1..0 #SKIP skipping bash completion tests; bash not available'\n> +\texit 0\n> +fi\n\nI wonder what this 'echo...;exit' is about (I do so since I saw it the\nfirst time when Felipe submitted his patch). Shouldn't it be more like:\n\n\tskip_all='skipping bash completion tests; bash not available'\n\ttest_done\n\n-- Hannes\n"},{"id":"189505","messageId":"CAMP44s2isAvmEhaTJpg8qsT967ghkvjyU1OAnTLMZSb5MSsnXw@mail.gmail.com","threadId":"30252","inReplyTo":"4F8D19B8.1040004@viscovery.net","subject":"Re: [PATCH v2 1/2] tests: move code to run completion tests under bash into a helper library","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-17T07:37:18Z","receivedAt":"2012-04-17T07:37:18Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"2012/4/17 Johannes Sixt <j.sixt@viscovery.net>:\n> Am 4/17/2012 0:09, schrieb SZEDER Gábor:\n>> diff --git a/t/lib-completion.sh b/t/lib-completion.sh\n>> new file mode 100644\n>> index 00000000..3d85feb2\n>> --- /dev/null\n>> +++ b/t/lib-completion.sh\n>> @@ -0,0 +1,17 @@\n>> +#!/bin/sh\n>> +#\n>> +# Ensures that tests of the completion script are run under Bash.\n>> +\n>> +if test -n \"$BASH\" && test -z \"$POSIXLY_CORRECT\"; then\n>> +     # we are in full-on bash mode\n>> +     true\n>> +elif type bash >/dev/null 2>&1; then\n>> +     # execute in full-on bash mode\n>> +     unset POSIXLY_CORRECT\n>> +     exec bash \"$0\" \"$@\"\n>> +else\n>> +     echo '1..0 #SKIP skipping bash completion tests; bash not available'\n>> +     exit 0\n>> +fi\n>\n> I wonder what this 'echo...;exit' is about (I do so since I saw it the\n> first time when Felipe submitted his patch). Shouldn't it be more like:\n>\n>        skip_all='skipping bash completion tests; bash not available'\n>        test_done\n\nIt should, if the test library was loaded at that point, but it isn't.\nBTW, I didn't write that code.\n\nIn any case, what the user sees is exactly the same, except without color.\n\nCheers.\n\n-- \nFelipe Contreras\n"}]}