{"thread":{"id":"21469","subject":"[PATCH] t1200: cleanup and modernize test style","startedAt":"2009-11-03T21:05:28Z","lastAt":"2009-11-05T06:33:53Z","messageCount":5,"participants":["Stephen Boyd","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"126673","messageId":"1257282328-6491-1-git-send-email-bebarino@gmail.com","threadId":"21469","inReplyTo":null,"subject":"[PATCH] t1200: cleanup and modernize test style","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-11-03T21:05:28Z","receivedAt":"2009-11-03T21:05:28Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Many parts of the tests in t1200 are run outside the test harness,\ncircumventing the usefulness of -v and spewing messages to stdout when\n-v isn't used. Fix these problems by modernizing the test a bit.\n\nAn extra test_done has existed since commit 6a74642 (git-commit --amend:\ntwo fixes., 2006-04-20) leading to the last 6 tests never being run.\nRemove it and teach the resolve merge test about fast-forward merges.\n\nFinally, we remove the TODO notes, because fetch, push, and clone have\ntheir own tests since t1200 was introduced and we're not going to add\nthem here 4 years later.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n\nI saw some output when running this test and thought it could be modernized a\nbit.\n\n t/t1200-tutorial.sh |  131 +++++++++++++++++++++++++++++----------------------\n 1 files changed, 74 insertions(+), 57 deletions(-)\n\ndiff --git a/t/t1200-tutorial.sh b/t/t1200-tutorial.sh\nindex 67e637b..16c5b6d 100755\n--- a/t/t1200-tutorial.sh\n+++ b/t/t1200-tutorial.sh\n@@ -7,14 +7,18 @@ test_description='A simple turial in the form of a test case'\n \n . ./test-lib.sh\n \n-echo \"Hello World\" > hello\n-echo \"Silly example\" > example\n+test_expect_success 'blob'  '\n+\techo \"Hello World\" > hello &&\n+\techo \"Silly example\" > example &&\n \n-git update-index --add hello example\n+\tgit update-index --add hello example &&\n \n-test_expect_success 'blob' \"test blob = \\\"$(git cat-file -t 557db03)\\\"\"\n+\ttest blob = \"$(git cat-file -t 557db03)\"\n+'\n \n-test_expect_success 'blob 557db03' \"test \\\"Hello World\\\" = \\\"$(git cat-file blob 557db03)\\\"\"\n+test_expect_success 'blob 557db03' '\n+\ttest \"Hello World\" = \"$(git cat-file blob 557db03)\"\n+'\n \n echo \"It's a new day for git\" >>hello\n cat > diff.expect << EOF\n@@ -26,25 +30,33 @@ index 557db03..263414f 100644\n  Hello World\n +It's a new day for git\n EOF\n-git diff-files -p > diff.output\n-test_expect_success 'git diff-files -p' 'cmp diff.expect diff.output'\n-git diff > diff.output\n-test_expect_success 'git diff' 'cmp diff.expect diff.output'\n-\n-tree=$(git write-tree 2>/dev/null)\n \n-test_expect_success 'tree' \"test 8988da15d077d4829fc51d8544c097def6644dbb = $tree\"\n+test_expect_success 'git diff-files -p' '\n+\tgit diff-files -p > diff.output &&\n+\tcmp diff.expect diff.output\n+'\n \n-output=\"$(echo \"Initial commit\" | git commit-tree $(git write-tree) 2>&1 > .git/refs/heads/master)\"\n+test_expect_success 'git diff' '\n+\tgit diff > diff.output &&\n+\tcmp diff.expect diff.output\n+'\n \n-git diff-index -p HEAD > diff.output\n-test_expect_success 'git diff-index -p HEAD' 'cmp diff.expect diff.output'\n+test_expect_success 'tree' '\n+\ttree=$(git write-tree 2>/dev/null)\n+\ttest 8988da15d077d4829fc51d8544c097def6644dbb = $tree\n+'\n \n-git diff HEAD > diff.output\n-test_expect_success 'git diff HEAD' 'cmp diff.expect diff.output'\n+test_expect_success 'git diff-index -p HEAD' '\n+\techo \"Initial commit\" | \\\n+\tgit commit-tree $(git write-tree) 2>&1 > .git/refs/heads/master &&\n+\tgit diff-index -p HEAD > diff.output &&\n+\tcmp diff.expect diff.output\n+'\n \n-#rm hello\n-#test_expect_success 'git read-tree --reset HEAD' \"git read-tree --reset HEAD ; test \\\"hello: needs update\\\" = \\\"$(git update-index --refresh)\\\"\"\n+test_expect_success 'git diff HEAD' '\n+\tgit diff HEAD > diff.output &&\n+\tcmp diff.expect diff.output\n+'\n \n cat > whatchanged.expect << EOF\n commit VARIABLE\n@@ -69,39 +81,45 @@ index 0000000..557db03\n +Hello World\n EOF\n \n-git whatchanged -p --root | \\\n-\tsed -e \"1s/^\\(.\\{7\\}\\).\\{40\\}/\\1VARIABLE/\" \\\n+test_expect_success 'git whatchanged -p --root' '\n+\tgit whatchanged -p --root | \\\n+\t\tsed -e \"1s/^\\(.\\{7\\}\\).\\{40\\}/\\1VARIABLE/\" \\\n \t\t-e \"2,3s/^\\(.\\{8\\}\\).*$/\\1VARIABLE/\" \\\n-> whatchanged.output\n-test_expect_success 'git whatchanged -p --root' 'cmp whatchanged.expect whatchanged.output'\n-\n-git tag my-first-tag\n-test_expect_success 'git tag my-first-tag' 'cmp .git/refs/heads/master .git/refs/tags/my-first-tag'\n+\t> whatchanged.output &&\n+\tcmp whatchanged.expect whatchanged.output\n+'\n \n-# TODO: test git clone\n+test_expect_success 'git tag my-first-tag' '\n+\tgit tag my-first-tag &&\n+\tcmp .git/refs/heads/master .git/refs/tags/my-first-tag\n+'\n \n-git checkout -b mybranch\n-test_expect_success 'git checkout -b mybranch' 'cmp .git/refs/heads/master .git/refs/heads/mybranch'\n+test_expect_success 'git checkout -b mybranch' '\n+\tgit checkout -b mybranch &&\n+\tcmp .git/refs/heads/master .git/refs/heads/mybranch\n+'\n \n cat > branch.expect <<EOF\n   master\n * mybranch\n EOF\n \n-git branch > branch.output\n-test_expect_success 'git branch' 'cmp branch.expect branch.output'\n+test_expect_success 'git branch' '\n+\tgit branch > branch.output &&\n+\tcmp branch.expect branch.output\n+'\n \n-git checkout mybranch\n-echo \"Work, work, work\" >>hello\n-git commit -m 'Some work.' -i hello\n+test_expect_success 'git resolve now fails' '\n+\tgit checkout mybranch &&\n+\techo \"Work, work, work\" >>hello &&\n+\tgit commit -m \"Some work.\" -i hello &&\n \n-git checkout master\n+\tgit checkout master &&\n \n-echo \"Play, play, play\" >>hello\n-echo \"Lots of fun\" >>example\n-git commit -m 'Some fun.' -i hello example\n+\techo \"Play, play, play\" >>hello &&\n+\techo \"Lots of fun\" >>example &&\n+\tgit commit -m \"Some fun.\" -i hello example &&\n \n-test_expect_success 'git resolve now fails' '\n \ttest_must_fail git merge -m \"Merge work in mybranch\" mybranch\n '\n \n@@ -112,10 +130,6 @@ Play, play, play\n Work, work, work\n EOF\n \n-git commit -m 'Merged \"mybranch\" changes.' -i hello\n-\n-test_done\n-\n cat > show-branch.expect << EOF\n * [master] Merged \"mybranch\" changes.\n  ! [mybranch] Some work.\n@@ -124,21 +138,26 @@ cat > show-branch.expect << EOF\n *+ [mybranch] Some work.\n EOF\n \n-git show-branch --topo-order master mybranch > show-branch.output\n-test_expect_success 'git show-branch' 'cmp show-branch.expect show-branch.output'\n-\n-git checkout mybranch\n+test_expect_success 'git show-branch' '\n+\tgit commit -m \"Merged \\\"mybranch\\\" changes.\" -i hello &&\n+\tgit show-branch --topo-order master mybranch > show-branch.output &&\n+\tcmp show-branch.expect show-branch.output\n+'\n \n cat > resolve.expect << EOF\n-Updating from VARIABLE to VARIABLE\n+Updating VARIABLE..VARIABLE\n+Fast forward\n  example |    1 +\n  hello   |    1 +\n  2 files changed, 2 insertions(+), 0 deletions(-)\n EOF\n \n-git merge -s \"Merge upstream changes.\" master | \\\n-\tsed -e \"1s/[0-9a-f]\\{40\\}/VARIABLE/g\" >resolve.output\n-test_expect_success 'git resolve' 'cmp resolve.expect resolve.output'\n+test_expect_success 'git resolve' '\n+\tgit checkout mybranch &&\n+\tgit merge -s resolve master | \\\n+\t\tsed -e \"1s/[0-9a-f]\\{7\\}/VARIABLE/g\" >resolve.output &&\n+\tcmp resolve.expect resolve.output\n+'\n \n cat > show-branch2.expect << EOF\n ! [master] Merged \"mybranch\" changes.\n@@ -147,12 +166,10 @@ cat > show-branch2.expect << EOF\n -- [master] Merged \"mybranch\" changes.\n EOF\n \n-git show-branch --topo-order master mybranch > show-branch2.output\n-test_expect_success 'git show-branch' 'cmp show-branch2.expect show-branch2.output'\n-\n-# TODO: test git fetch\n-\n-# TODO: test git push\n+test_expect_success 'git show-branch' '\n+\tgit show-branch --topo-order master mybranch > show-branch2.output &&\n+\tcmp show-branch2.expect show-branch2.output\n+'\n \n test_expect_success 'git repack' 'git repack'\n test_expect_success 'git prune-packed' 'git prune-packed'\n-- \n1.6.5.2.181.gd6f41\n"},{"id":"126718","messageId":"7vr5seltyi.fsf@alter.siamese.dyndns.org","threadId":"21469","inReplyTo":"1257282328-6491-1-git-send-email-bebarino@gmail.com","subject":"Re: [PATCH] t1200: cleanup and modernize test style","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-11-04T05:50:13Z","receivedAt":"2009-11-04T05:50:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stephen Boyd <bebarino@gmail.com> writes:\n\n> Many parts of the tests in t1200 are run outside the test harness,\n> circumventing the usefulness of -v and spewing messages to stdout when\n> -v isn't used. Fix these problems by modernizing the test a bit.\n>\n> An extra test_done has existed since commit 6a74642 (git-commit --amend:\n> two fixes., 2006-04-20) leading to the last 6 tests never being run.\n> Remove it and teach the resolve merge test about fast-forward merges.\n>\n> Finally, we remove the TODO notes, because fetch, push, and clone have\n> their own tests since t1200 was introduced and we're not going to add\n> them here 4 years later.\n>\n> Signed-off-by: Stephen Boyd <bebarino@gmail.com>\n> ---\n>\n> I saw some output when running this test and thought it could be modernized a\n> bit.\n\nThanks.\n\nThe sequence of commands are suppopsed to match what the user manual\nteaches, and I suspect we have had quite a many updates to the manual\nsince this test script was last touched.  Do you happen to know if they\nstill match the manual?\n\n>  t/t1200-tutorial.sh |  131 +++++++++++++++++++++++++++++----------------------\n>  1 files changed, 74 insertions(+), 57 deletions(-)\n>\n> diff --git a/t/t1200-tutorial.sh b/t/t1200-tutorial.sh\n> index 67e637b..16c5b6d 100755\n> --- a/t/t1200-tutorial.sh\n> +++ b/t/t1200-tutorial.sh\n> @@ -7,14 +7,18 @@ test_description='A simple turial in the form of a test case'\n>  \n>  . ./test-lib.sh\n>  \n> -echo \"Hello World\" > hello\n> -echo \"Silly example\" > example\n> +test_expect_success 'blob'  '\n> +\techo \"Hello World\" > hello &&\n> +\techo \"Silly example\" > example &&\n>  \n> -git update-index --add hello example\n> +\tgit update-index --add hello example &&\n>  \n> -test_expect_success 'blob' \"test blob = \\\"$(git cat-file -t 557db03)\\\"\"\n> +\ttest blob = \"$(git cat-file -t 557db03)\"\n> +'\n>  \n> -test_expect_success 'blob 557db03' \"test \\\"Hello World\\\" = \\\"$(git cat-file blob 557db03)\\\"\"\n> +test_expect_success 'blob 557db03' '\n> +\ttest \"Hello World\" = \"$(git cat-file blob 557db03)\"\n> +'\n>  \n>  echo \"It's a new day for git\" >>hello\n>  cat > diff.expect << EOF\n> @@ -26,25 +30,33 @@ index 557db03..263414f 100644\n>   Hello World\n>  +It's a new day for git\n>  EOF\n> -git diff-files -p > diff.output\n> -test_expect_success 'git diff-files -p' 'cmp diff.expect diff.output'\n> -git diff > diff.output\n> -test_expect_success 'git diff' 'cmp diff.expect diff.output'\n> -\n> -tree=$(git write-tree 2>/dev/null)\n>  \n> -test_expect_success 'tree' \"test 8988da15d077d4829fc51d8544c097def6644dbb = $tree\"\n> +test_expect_success 'git diff-files -p' '\n> +\tgit diff-files -p > diff.output &&\n> +\tcmp diff.expect diff.output\n> +'\n>  \n> -output=\"$(echo \"Initial commit\" | git commit-tree $(git write-tree) 2>&1 > .git/refs/heads/master)\"\n> +test_expect_success 'git diff' '\n> +\tgit diff > diff.output &&\n> +\tcmp diff.expect diff.output\n> +'\n>  \n> -git diff-index -p HEAD > diff.output\n> -test_expect_success 'git diff-index -p HEAD' 'cmp diff.expect diff.output'\n> +test_expect_success 'tree' '\n> +\ttree=$(git write-tree 2>/dev/null)\n> +\ttest 8988da15d077d4829fc51d8544c097def6644dbb = $tree\n> +'\n>  \n> -git diff HEAD > diff.output\n> -test_expect_success 'git diff HEAD' 'cmp diff.expect diff.output'\n> +test_expect_success 'git diff-index -p HEAD' '\n> +\techo \"Initial commit\" | \\\n> +\tgit commit-tree $(git write-tree) 2>&1 > .git/refs/heads/master &&\n> +\tgit diff-index -p HEAD > diff.output &&\n> +\tcmp diff.expect diff.output\n> +'\n>  \n> -#rm hello\n> -#test_expect_success 'git read-tree --reset HEAD' \"git read-tree --reset HEAD ; test \\\"hello: needs update\\\" = \\\"$(git update-index --refresh)\\\"\"\n> +test_expect_success 'git diff HEAD' '\n> +\tgit diff HEAD > diff.output &&\n> +\tcmp diff.expect diff.output\n> +'\n>  \n>  cat > whatchanged.expect << EOF\n>  commit VARIABLE\n> @@ -69,39 +81,45 @@ index 0000000..557db03\n>  +Hello World\n>  EOF\n>  \n> -git whatchanged -p --root | \\\n> -\tsed -e \"1s/^\\(.\\{7\\}\\).\\{40\\}/\\1VARIABLE/\" \\\n> +test_expect_success 'git whatchanged -p --root' '\n> +\tgit whatchanged -p --root | \\\n> +\t\tsed -e \"1s/^\\(.\\{7\\}\\).\\{40\\}/\\1VARIABLE/\" \\\n>  \t\t-e \"2,3s/^\\(.\\{8\\}\\).*$/\\1VARIABLE/\" \\\n> -> whatchanged.output\n> -test_expect_success 'git whatchanged -p --root' 'cmp whatchanged.expect whatchanged.output'\n> -\n> -git tag my-first-tag\n> -test_expect_success 'git tag my-first-tag' 'cmp .git/refs/heads/master .git/refs/tags/my-first-tag'\n> +\t> whatchanged.output &&\n> +\tcmp whatchanged.expect whatchanged.output\n> +'\n>  \n> -# TODO: test git clone\n> +test_expect_success 'git tag my-first-tag' '\n> +\tgit tag my-first-tag &&\n> +\tcmp .git/refs/heads/master .git/refs/tags/my-first-tag\n> +'\n>  \n> -git checkout -b mybranch\n> -test_expect_success 'git checkout -b mybranch' 'cmp .git/refs/heads/master .git/refs/heads/mybranch'\n> +test_expect_success 'git checkout -b mybranch' '\n> +\tgit checkout -b mybranch &&\n> +\tcmp .git/refs/heads/master .git/refs/heads/mybranch\n> +'\n>  \n>  cat > branch.expect <<EOF\n>    master\n>  * mybranch\n>  EOF\n>  \n> -git branch > branch.output\n> -test_expect_success 'git branch' 'cmp branch.expect branch.output'\n> +test_expect_success 'git branch' '\n> +\tgit branch > branch.output &&\n> +\tcmp branch.expect branch.output\n> +'\n>  \n> -git checkout mybranch\n> -echo \"Work, work, work\" >>hello\n> -git commit -m 'Some work.' -i hello\n> +test_expect_success 'git resolve now fails' '\n> +\tgit checkout mybranch &&\n> +\techo \"Work, work, work\" >>hello &&\n> +\tgit commit -m \"Some work.\" -i hello &&\n>  \n> -git checkout master\n> +\tgit checkout master &&\n>  \n> -echo \"Play, play, play\" >>hello\n> -echo \"Lots of fun\" >>example\n> -git commit -m 'Some fun.' -i hello example\n> +\techo \"Play, play, play\" >>hello &&\n> +\techo \"Lots of fun\" >>example &&\n> +\tgit commit -m \"Some fun.\" -i hello example &&\n>  \n> -test_expect_success 'git resolve now fails' '\n>  \ttest_must_fail git merge -m \"Merge work in mybranch\" mybranch\n>  '\n>  \n> @@ -112,10 +130,6 @@ Play, play, play\n>  Work, work, work\n>  EOF\n>  \n> -git commit -m 'Merged \"mybranch\" changes.' -i hello\n> -\n> -test_done\n> -\n>  cat > show-branch.expect << EOF\n>  * [master] Merged \"mybranch\" changes.\n>   ! [mybranch] Some work.\n> @@ -124,21 +138,26 @@ cat > show-branch.expect << EOF\n>  *+ [mybranch] Some work.\n>  EOF\n>  \n> -git show-branch --topo-order master mybranch > show-branch.output\n> -test_expect_success 'git show-branch' 'cmp show-branch.expect show-branch.output'\n> -\n> -git checkout mybranch\n> +test_expect_success 'git show-branch' '\n> +\tgit commit -m \"Merged \\\"mybranch\\\" changes.\" -i hello &&\n> +\tgit show-branch --topo-order master mybranch > show-branch.output &&\n> +\tcmp show-branch.expect show-branch.output\n> +'\n>  \n>  cat > resolve.expect << EOF\n> -Updating from VARIABLE to VARIABLE\n> +Updating VARIABLE..VARIABLE\n> +Fast forward\n>   example |    1 +\n>   hello   |    1 +\n>   2 files changed, 2 insertions(+), 0 deletions(-)\n>  EOF\n>  \n> -git merge -s \"Merge upstream changes.\" master | \\\n> -\tsed -e \"1s/[0-9a-f]\\{40\\}/VARIABLE/g\" >resolve.output\n> -test_expect_success 'git resolve' 'cmp resolve.expect resolve.output'\n> +test_expect_success 'git resolve' '\n> +\tgit checkout mybranch &&\n> +\tgit merge -s resolve master | \\\n> +\t\tsed -e \"1s/[0-9a-f]\\{7\\}/VARIABLE/g\" >resolve.output &&\n> +\tcmp resolve.expect resolve.output\n> +'\n>  \n>  cat > show-branch2.expect << EOF\n>  ! [master] Merged \"mybranch\" changes.\n> @@ -147,12 +166,10 @@ cat > show-branch2.expect << EOF\n>  -- [master] Merged \"mybranch\" changes.\n>  EOF\n>  \n> -git show-branch --topo-order master mybranch > show-branch2.output\n> -test_expect_success 'git show-branch' 'cmp show-branch2.expect show-branch2.output'\n> -\n> -# TODO: test git fetch\n> -\n> -# TODO: test git push\n> +test_expect_success 'git show-branch' '\n> +\tgit show-branch --topo-order master mybranch > show-branch2.output &&\n> +\tcmp show-branch2.expect show-branch2.output\n> +'\n>  \n>  test_expect_success 'git repack' 'git repack'\n>  test_expect_success 'git prune-packed' 'git prune-packed'\n> -- \n> 1.6.5.2.181.gd6f41\n"},{"id":"126725","messageId":"4AF12449.7050905@gmail.com","threadId":"21469","inReplyTo":"7vr5seltyi.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] t1200: cleanup and modernize test style","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-11-04T06:50:49Z","receivedAt":"2009-11-04T06:50:49Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Junio C Hamano wrote:\n> Thanks.\n>\n> The sequence of commands are suppopsed to match what the user manual\n> teaches, and I suspect we have had quite a many updates to the manual\n> since this test script was last touched.  Do you happen to know if they\n> still match the manual?\n\nI just read through it and it's different. I'm ignoring the cloning, \nfetching, pushing, and gitk parts too. There is a whole section on \nmerging which isn't really covered. I'll resend sometime soon (the last \ntest is broken too, sorry).\n"},{"id":"126879","messageId":"1257402833-4741-1-git-send-email-bebarino@gmail.com","threadId":"21469","inReplyTo":"1257282328-6491-1-git-send-email-bebarino@gmail.com","subject":"[PATCHv2 1/2] t1200: cleanup and modernize test style","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-11-05T06:33:52Z","receivedAt":"2009-11-05T06:33:52Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Many parts of the tests in t1200 are run outside the test harness,\ncircumventing the usefulness of -v and spewing messages to stdout when\n-v isn't used. Fix these problems by modernizing the test a bit.\n\nAn extra test_done has existed since commit 6a74642 (git-commit --amend:\ntwo fixes., 2006-04-20) leading to the last 6 tests never being run.\nRemove it and teach the resolve merge test about fast-forward merges.\nAlso fix the last test's incorrect find command and prune before\nchecking for unpacked objects so we remove the unreachable conflict-marked\nblob.\n\nFinally, we remove the TODO notes, because fetch, push, and clone have\ntheir own tests since t1200 was introduced and we're not going to add\nthem here 4 years later.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n\n Since v1:\n  * Fixed the last test\n\n t/t1200-tutorial.sh |  134 +++++++++++++++++++++++++++++----------------------\n 1 files changed, 76 insertions(+), 58 deletions(-)\n\ndiff --git a/t/t1200-tutorial.sh b/t/t1200-tutorial.sh\nindex 67e637b..c57c9d5 100755\n--- a/t/t1200-tutorial.sh\n+++ b/t/t1200-tutorial.sh\n@@ -7,14 +7,18 @@ test_description='A simple turial in the form of a test case'\n \n . ./test-lib.sh\n \n-echo \"Hello World\" > hello\n-echo \"Silly example\" > example\n+test_expect_success 'blob'  '\n+\techo \"Hello World\" > hello &&\n+\techo \"Silly example\" > example &&\n \n-git update-index --add hello example\n+\tgit update-index --add hello example &&\n \n-test_expect_success 'blob' \"test blob = \\\"$(git cat-file -t 557db03)\\\"\"\n+\ttest blob = \"$(git cat-file -t 557db03)\"\n+'\n \n-test_expect_success 'blob 557db03' \"test \\\"Hello World\\\" = \\\"$(git cat-file blob 557db03)\\\"\"\n+test_expect_success 'blob 557db03' '\n+\ttest \"Hello World\" = \"$(git cat-file blob 557db03)\"\n+'\n \n echo \"It's a new day for git\" >>hello\n cat > diff.expect << EOF\n@@ -26,25 +30,33 @@ index 557db03..263414f 100644\n  Hello World\n +It's a new day for git\n EOF\n-git diff-files -p > diff.output\n-test_expect_success 'git diff-files -p' 'cmp diff.expect diff.output'\n-git diff > diff.output\n-test_expect_success 'git diff' 'cmp diff.expect diff.output'\n-\n-tree=$(git write-tree 2>/dev/null)\n \n-test_expect_success 'tree' \"test 8988da15d077d4829fc51d8544c097def6644dbb = $tree\"\n+test_expect_success 'git diff-files -p' '\n+\tgit diff-files -p > diff.output &&\n+\tcmp diff.expect diff.output\n+'\n \n-output=\"$(echo \"Initial commit\" | git commit-tree $(git write-tree) 2>&1 > .git/refs/heads/master)\"\n+test_expect_success 'git diff' '\n+\tgit diff > diff.output &&\n+\tcmp diff.expect diff.output\n+'\n \n-git diff-index -p HEAD > diff.output\n-test_expect_success 'git diff-index -p HEAD' 'cmp diff.expect diff.output'\n+test_expect_success 'tree' '\n+\ttree=$(git write-tree 2>/dev/null)\n+\ttest 8988da15d077d4829fc51d8544c097def6644dbb = $tree\n+'\n \n-git diff HEAD > diff.output\n-test_expect_success 'git diff HEAD' 'cmp diff.expect diff.output'\n+test_expect_success 'git diff-index -p HEAD' '\n+\techo \"Initial commit\" | \\\n+\tgit commit-tree $(git write-tree) 2>&1 > .git/refs/heads/master &&\n+\tgit diff-index -p HEAD > diff.output &&\n+\tcmp diff.expect diff.output\n+'\n \n-#rm hello\n-#test_expect_success 'git read-tree --reset HEAD' \"git read-tree --reset HEAD ; test \\\"hello: needs update\\\" = \\\"$(git update-index --refresh)\\\"\"\n+test_expect_success 'git diff HEAD' '\n+\tgit diff HEAD > diff.output &&\n+\tcmp diff.expect diff.output\n+'\n \n cat > whatchanged.expect << EOF\n commit VARIABLE\n@@ -69,39 +81,45 @@ index 0000000..557db03\n +Hello World\n EOF\n \n-git whatchanged -p --root | \\\n-\tsed -e \"1s/^\\(.\\{7\\}\\).\\{40\\}/\\1VARIABLE/\" \\\n+test_expect_success 'git whatchanged -p --root' '\n+\tgit whatchanged -p --root | \\\n+\t\tsed -e \"1s/^\\(.\\{7\\}\\).\\{40\\}/\\1VARIABLE/\" \\\n \t\t-e \"2,3s/^\\(.\\{8\\}\\).*$/\\1VARIABLE/\" \\\n-> whatchanged.output\n-test_expect_success 'git whatchanged -p --root' 'cmp whatchanged.expect whatchanged.output'\n-\n-git tag my-first-tag\n-test_expect_success 'git tag my-first-tag' 'cmp .git/refs/heads/master .git/refs/tags/my-first-tag'\n+\t> whatchanged.output &&\n+\tcmp whatchanged.expect whatchanged.output\n+'\n \n-# TODO: test git clone\n+test_expect_success 'git tag my-first-tag' '\n+\tgit tag my-first-tag &&\n+\tcmp .git/refs/heads/master .git/refs/tags/my-first-tag\n+'\n \n-git checkout -b mybranch\n-test_expect_success 'git checkout -b mybranch' 'cmp .git/refs/heads/master .git/refs/heads/mybranch'\n+test_expect_success 'git checkout -b mybranch' '\n+\tgit checkout -b mybranch &&\n+\tcmp .git/refs/heads/master .git/refs/heads/mybranch\n+'\n \n cat > branch.expect <<EOF\n   master\n * mybranch\n EOF\n \n-git branch > branch.output\n-test_expect_success 'git branch' 'cmp branch.expect branch.output'\n+test_expect_success 'git branch' '\n+\tgit branch > branch.output &&\n+\tcmp branch.expect branch.output\n+'\n \n-git checkout mybranch\n-echo \"Work, work, work\" >>hello\n-git commit -m 'Some work.' -i hello\n+test_expect_success 'git resolve now fails' '\n+\tgit checkout mybranch &&\n+\techo \"Work, work, work\" >>hello &&\n+\tgit commit -m \"Some work.\" -i hello &&\n \n-git checkout master\n+\tgit checkout master &&\n \n-echo \"Play, play, play\" >>hello\n-echo \"Lots of fun\" >>example\n-git commit -m 'Some fun.' -i hello example\n+\techo \"Play, play, play\" >>hello &&\n+\techo \"Lots of fun\" >>example &&\n+\tgit commit -m \"Some fun.\" -i hello example &&\n \n-test_expect_success 'git resolve now fails' '\n \ttest_must_fail git merge -m \"Merge work in mybranch\" mybranch\n '\n \n@@ -112,10 +130,6 @@ Play, play, play\n Work, work, work\n EOF\n \n-git commit -m 'Merged \"mybranch\" changes.' -i hello\n-\n-test_done\n-\n cat > show-branch.expect << EOF\n * [master] Merged \"mybranch\" changes.\n  ! [mybranch] Some work.\n@@ -124,21 +138,26 @@ cat > show-branch.expect << EOF\n *+ [mybranch] Some work.\n EOF\n \n-git show-branch --topo-order master mybranch > show-branch.output\n-test_expect_success 'git show-branch' 'cmp show-branch.expect show-branch.output'\n-\n-git checkout mybranch\n+test_expect_success 'git show-branch' '\n+\tgit commit -m \"Merged \\\"mybranch\\\" changes.\" -i hello &&\n+\tgit show-branch --topo-order master mybranch > show-branch.output &&\n+\tcmp show-branch.expect show-branch.output\n+'\n \n cat > resolve.expect << EOF\n-Updating from VARIABLE to VARIABLE\n+Updating VARIABLE..VARIABLE\n+Fast forward (no commit created; -m option ignored)\n  example |    1 +\n  hello   |    1 +\n  2 files changed, 2 insertions(+), 0 deletions(-)\n EOF\n \n-git merge -s \"Merge upstream changes.\" master | \\\n-\tsed -e \"1s/[0-9a-f]\\{40\\}/VARIABLE/g\" >resolve.output\n-test_expect_success 'git resolve' 'cmp resolve.expect resolve.output'\n+test_expect_success 'git resolve' '\n+\tgit checkout mybranch &&\n+\tgit merge -m \"Merge upstream changes.\" master | \\\n+\t\tsed -e \"1s/[0-9a-f]\\{7\\}/VARIABLE/g\" >resolve.output &&\n+\tcmp resolve.expect resolve.output\n+'\n \n cat > show-branch2.expect << EOF\n ! [master] Merged \"mybranch\" changes.\n@@ -147,17 +166,16 @@ cat > show-branch2.expect << EOF\n -- [master] Merged \"mybranch\" changes.\n EOF\n \n-git show-branch --topo-order master mybranch > show-branch2.output\n-test_expect_success 'git show-branch' 'cmp show-branch2.expect show-branch2.output'\n-\n-# TODO: test git fetch\n-\n-# TODO: test git push\n+test_expect_success 'git show-branch (part 2)' '\n+\tgit show-branch --topo-order master mybranch > show-branch2.output &&\n+\tcmp show-branch2.expect show-branch2.output\n+'\n \n test_expect_success 'git repack' 'git repack'\n test_expect_success 'git prune-packed' 'git prune-packed'\n test_expect_success '-> only packed objects' '\n-\t! find -type f .git/objects/[0-9a-f][0-9a-f]\n+\tgit prune && # Remove conflict marked blobs\n+\t! find .git/objects/[0-9a-f][0-9a-f] -type f\n '\n \n test_done\n-- \n1.6.5.2.143.g8cc62\n"},{"id":"126880","messageId":"1257402833-4741-2-git-send-email-bebarino@gmail.com","threadId":"21469","inReplyTo":"1257402833-4741-1-git-send-email-bebarino@gmail.com","subject":"[PATCHv2 2/2] t1200: Make documentation and test agree","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-11-05T06:33:53Z","receivedAt":"2009-11-05T06:33:53Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"There were some differences between t1200 and the gitcore-tutorial. Add\nmissing tests for manually merging two branches, and use the same\ncommands in both files.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n\n This is all new since v1\n\n Documentation/gitcore-tutorial.txt |   20 ++++----\n t/t1200-tutorial.sh                |   97 ++++++++++++++++++++++++++++++++---\n 2 files changed, 98 insertions(+), 19 deletions(-)\n\ndiff --git a/Documentation/gitcore-tutorial.txt b/Documentation/gitcore-tutorial.txt\nindex b3640c4..7bdf090 100644\n--- a/Documentation/gitcore-tutorial.txt\n+++ b/Documentation/gitcore-tutorial.txt\n@@ -185,7 +185,7 @@ object is. git will tell you that you have a \"blob\" object (i.e., just a\n regular file), and you can see the contents with\n \n ----------------\n-$ git cat-file \"blob\" 557db03\n+$ git cat-file blob 557db03\n ----------------\n \n which will print out \"Hello World\". The object `557db03` is nothing\n@@ -1188,7 +1188,7 @@ $ git show-branch\n --\n  + [mybranch] Some work.\n *  [master] Some fun.\n-*+ [mybranch^] New day.\n+*+ [mybranch^] Initial commit\n ------------\n \n Now we are ready to experiment with the merge by hand.\n@@ -1204,11 +1204,11 @@ $ mb=$(git merge-base HEAD mybranch)\n The command writes the commit object name of the common ancestor\n to the standard output, so we captured its output to a variable,\n because we will be using it in the next step.  By the way, the common\n-ancestor commit is the \"New day.\" commit in this case.  You can\n+ancestor commit is the \"Initial commit\" commit in this case.  You can\n tell it by:\n \n ------------\n-$ git name-rev $mb\n+$ git name-rev --name-only --tags $mb\n my-first-tag\n ------------\n \n@@ -1237,8 +1237,8 @@ inspect the index file with this command:\n ------------\n $ git ls-files --stage\n 100644 7f8b141b65fdcee47321e399a2598a235a032422 0\texample\n-100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1\thello\n-100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2\thello\n+100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1\thello\n+100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2\thello\n 100644 cc44c73eb783565da5831b4d820c962954019b69 3\thello\n ------------\n \n@@ -1253,8 +1253,8 @@ To look at only non-zero stages, use `\\--unmerged` flag:\n \n ------------\n $ git ls-files --unmerged\n-100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1\thello\n-100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2\thello\n+100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1\thello\n+100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2\thello\n 100644 cc44c73eb783565da5831b4d820c962954019b69 3\thello\n ------------\n \n@@ -1283,8 +1283,8 @@ the working tree..  This can be seen if you run `ls-files\n ------------\n $ git ls-files --stage\n 100644 7f8b141b65fdcee47321e399a2598a235a032422 0\texample\n-100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1\thello\n-100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2\thello\n+100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1\thello\n+100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2\thello\n 100644 cc44c73eb783565da5831b4d820c962954019b69 3\thello\n ------------\n \ndiff --git a/t/t1200-tutorial.sh b/t/t1200-tutorial.sh\nindex c57c9d5..299e724 100755\n--- a/t/t1200-tutorial.sh\n+++ b/t/t1200-tutorial.sh\n@@ -47,8 +47,9 @@ test_expect_success 'tree' '\n '\n \n test_expect_success 'git diff-index -p HEAD' '\n-\techo \"Initial commit\" | \\\n-\tgit commit-tree $(git write-tree) 2>&1 > .git/refs/heads/master &&\n+\ttree=$(git write-tree)\n+\tcommit=$(echo \"Initial commit\" | git commit-tree $tree) &&\n+\tgit update-ref HEAD $commit &&\n \tgit diff-index -p HEAD > diff.output &&\n \tcmp diff.expect diff.output\n '\n@@ -131,16 +132,18 @@ Work, work, work\n EOF\n \n cat > show-branch.expect << EOF\n-* [master] Merged \"mybranch\" changes.\n+* [master] Merge work in mybranch\n  ! [mybranch] Some work.\n --\n--  [master] Merged \"mybranch\" changes.\n+-  [master] Merge work in mybranch\n *+ [mybranch] Some work.\n+*  [master^] Some fun.\n EOF\n \n test_expect_success 'git show-branch' '\n-\tgit commit -m \"Merged \\\"mybranch\\\" changes.\" -i hello &&\n-\tgit show-branch --topo-order master mybranch > show-branch.output &&\n+\tgit commit -m \"Merge work in mybranch\" -i hello &&\n+\tgit show-branch --topo-order --more=1 master mybranch \\\n+\t\t> show-branch.output &&\n \tcmp show-branch.expect show-branch.output\n '\n \n@@ -160,10 +163,10 @@ test_expect_success 'git resolve' '\n '\n \n cat > show-branch2.expect << EOF\n-! [master] Merged \"mybranch\" changes.\n- * [mybranch] Merged \"mybranch\" changes.\n+! [master] Merge work in mybranch\n+ * [mybranch] Merge work in mybranch\n --\n--- [master] Merged \"mybranch\" changes.\n+-- [master] Merge work in mybranch\n EOF\n \n test_expect_success 'git show-branch (part 2)' '\n@@ -171,6 +174,82 @@ test_expect_success 'git show-branch (part 2)' '\n \tcmp show-branch2.expect show-branch2.output\n '\n \n+cat > show-branch3.expect << EOF\n+! [master] Merge work in mybranch\n+ * [mybranch] Merge work in mybranch\n+--\n+-- [master] Merge work in mybranch\n++* [master^2] Some work.\n++* [master^] Some fun.\n+EOF\n+\n+test_expect_success 'git show-branch (part 3)' '\n+\tgit show-branch --topo-order --more=2 master mybranch \\\n+\t\t> show-branch3.output &&\n+\tcmp show-branch3.expect show-branch3.output\n+'\n+\n+test_expect_success 'rewind to \"Some fun.\" and \"Some work.\"' '\n+\tgit checkout mybranch &&\n+\tgit reset --hard master^2 &&\n+\tgit checkout master &&\n+\tgit reset --hard master^\n+'\n+\n+cat > show-branch4.expect << EOF\n+* [master] Some fun.\n+ ! [mybranch] Some work.\n+--\n+ + [mybranch] Some work.\n+*  [master] Some fun.\n+*+ [mybranch^] Initial commit\n+EOF\n+\n+test_expect_success 'git show-branch (part 4)' '\n+\tgit show-branch --topo-order > show-branch4.output &&\n+\tcmp show-branch4.expect show-branch4.output\n+'\n+\n+test_expect_success 'manual merge' '\n+\tmb=$(git merge-base HEAD mybranch) &&\n+\tgit name-rev --name-only --tags $mb > name-rev.output &&\n+\ttest \"my-first-tag\" = $(cat name-rev.output) &&\n+\n+\tgit read-tree -m -u $mb HEAD mybranch\n+'\n+\n+cat > ls-files.expect << EOF\n+100644 7f8b141b65fdcee47321e399a2598a235a032422 0\texample\n+100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1\thello\n+100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2\thello\n+100644 cc44c73eb783565da5831b4d820c962954019b69 3\thello\n+EOF\n+\n+test_expect_success 'git ls-files --stage' '\n+\tgit ls-files --stage > ls-files.output &&\n+\tcmp ls-files.expect ls-files.output\n+'\n+\n+cat > ls-files-unmerged.expect << EOF\n+100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1\thello\n+100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2\thello\n+100644 cc44c73eb783565da5831b4d820c962954019b69 3\thello\n+EOF\n+\n+test_expect_success 'git ls-files --unmerged' '\n+\tgit ls-files --unmerged > ls-files-unmerged.output &&\n+\tcmp ls-files-unmerged.expect ls-files-unmerged.output\n+'\n+\n+test_expect_success 'git-merge-index' '\n+\ttest_must_fail git merge-index git-merge-one-file hello\n+'\n+\n+test_expect_success 'git ls-files --stage (part 2)' '\n+\tgit ls-files --stage > ls-files.output2 &&\n+\tcmp ls-files.expect ls-files.output2\n+'\n+\n test_expect_success 'git repack' 'git repack'\n test_expect_success 'git prune-packed' 'git prune-packed'\n test_expect_success '-> only packed objects' '\n-- \n1.6.5.2.143.g8cc62\n"}]}