{"thread":{"id":"32913","subject":"[PATCH 2/3] contrib/subtree/t: Added tests for .gitsubtree support","startedAt":"2013-02-15T22:50:58Z","lastAt":"2013-02-18T00:35:26Z","messageCount":6,"participants":["Paul Campbell","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"209565","messageId":"CALeLG_=ir-kBTYpsRr_Hf8q2UY2ZtjShbTkO_tH=YiWSskfPOw@mail.gmail.com","threadId":"32913","inReplyTo":null,"subject":"[PATCH 2/3] contrib/subtree/t: Added tests for .gitsubtree support","fromName":"Paul Campbell","fromEmail":"pcampbell@kemitix.net","sentAt":"2013-02-15T22:50:58Z","receivedAt":"2013-02-15T22:50:58Z","isPatch":true,"sender":{"key":"pcampbell@kemitix.net","avatar":"https://gravatar.com/avatar/57584e05501b694929004e43fcd7308f4ad64df2eb0474cd8c7e5f93662bb0f1?d=mp&s=160"},"body":"add: ensure details are added to .gitsubtree\npush: check for a SHA1 update line\npull: add a file on one subtree, push it to a branch, then pull into\n    another subtree containing the same branch and confirm the files match\nadd: ensure stale .gitsubtree entry is replaced\n\nSigned-off-by: Paul Campbell <pcampbell@kemitix.net>\n---\n contrib/subtree/t/t7900-subtree.sh | 30 ++++++++++++++++++++++++++++++\n 1 file changed, 30 insertions(+)\n\ndiff --git a/contrib/subtree/t/t7900-subtree.sh\nb/contrib/subtree/t/t7900-subtree.sh\nindex 80d3399..4437dc6 100755\n--- a/contrib/subtree/t/t7900-subtree.sh\n+++ b/contrib/subtree/t/t7900-subtree.sh\n@@ -465,4 +465,34 @@ test_expect_success 'verify one file change per commit' '\n         ))\n '\n\n+# return to mainline\n+cd ../..\n+\n+# .gitsubtree\n+test_expect_success 'added repository appears in .gitsubtree' '\n+        git subtree add --prefix=copy0 sub1 &&\n+        grep \"^copy0 \\. sub1$\" .gitsubtree\n+'\n+\n+test_expect_success 'change in subtree is pushed okay' '\n+        cd copy0 && create new_file && git commit -m\"Added new_file\" &&\n+        cd .. && git subtree push --prefix=copy0 2>&1 | \\\n+                grep\n\"^\\s\\{3\\}[0-9a-f]\\{7\\}\\.\\.[0-9a-f]\\{7\\}\\s\\s[0-9a-f]\\{40\\}\\s->\\ssub1$\"\n+'\n+\n+test_expect_success 'pull into subtree okay' '\n+        git subtree add --prefix=copy1 sub1 &&\n+        git subtree add --prefix=copy2 sub1 &&\n+        cd copy1 && create new_file_in_copy1 && git commit -m\"Added\nnew_file_in_copy1\" &&\n+        cd .. && git subtree push --prefix=copy1 &&\n+        git subtree pull --prefix=copy2 | grep \"^ create mode 100644\ncopy2/new_file_in_copy1$\"\n+'\n+\n+test_expect_success 'replace outdated entry in .gitsubtree' '\n+        echo \"copy3 . sub2\" >> .gitsubtree &&\n+        git subtree add --prefix=copy3 sub1 &&\n+        (grep \"^copy3 . sub2$\" .gitsubtree && die || true) &&\n+        grep \"^copy3 . sub1$\" .gitsubtree\n+'\n+\n test_done\n-- \n1.8.1.3.605.g02339dd\n"},{"id":"209567","messageId":"20130215225624.GB21165@google.com","threadId":"32913","inReplyTo":"CALeLG_=ir-kBTYpsRr_Hf8q2UY2ZtjShbTkO_tH=YiWSskfPOw@mail.gmail.com","subject":"Re: [PATCH 2/3] contrib/subtree/t: Added tests for .gitsubtree support","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2013-02-15T22:56:24Z","receivedAt":"2013-02-15T22:56:24Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Paul,\n\nPaul Campbell wrote:\n\n> --- a/contrib/subtree/t/t7900-subtree.sh\n> +++ b/contrib/subtree/t/t7900-subtree.sh\n> @@ -465,4 +465,34 @@ test_expect_success 'verify one file change per commit' '\n[...]\n> +test_expect_success 'change in subtree is pushed okay' '\n> +        cd copy0 && create new_file && git commit -m\"Added new_file\" &&\n> +        cd .. && git subtree push --prefix=copy0 2>&1 | \\\n\nIf it possible to restrict the chdirs to subshells, that can make the\ntest more resiliant to early failures without breaking later tests.\n\nThat is:\n\n\t(\n\t\tcd copy0 &&\n\t\tcreate new_file &&\n\t\ttest_tick &&\n\t\tgit commit -m \"add new_file\"\n\t) &&\n\tgit subtree push --prefix=copy0 >output 2>&1 &&\n\tgrep \"...\" output\n\n> +                grep \"^\\s\\{3\\}[0-9a-f]\\{7\\}\\.\\.[0-9a-f]\\{7\\}\\s\\s[0-9a-f]\\{40\\}\\s->\\ssub1$\"\n\nThis might not be portable if I understand\nDocumentation/CodingGuidelines correctly.\n\n[...]\n> +        (grep \"^copy3 . sub2$\" .gitsubtree && die || true) &&\n\n\t! grep \"^copy3 . sub2\\$\" .gitsubtree &&\n\nHope that helps,\nJonathan\n"},{"id":"209568","messageId":"CALeLG_nLz9Gfqcfk4EcWixRXbWC0x0GUVFDAKD20DGbkhRNWvQ@mail.gmail.com","threadId":"32913","inReplyTo":"20130215225624.GB21165@google.com","subject":"Re: [PATCH 2/3] contrib/subtree/t: Added tests for .gitsubtree support","fromName":"Paul Campbell","fromEmail":"pcampbell@kemitix.net","sentAt":"2013-02-15T23:16:29Z","receivedAt":"2013-02-15T23:16:29Z","isPatch":true,"sender":{"key":"pcampbell@kemitix.net","avatar":"https://gravatar.com/avatar/57584e05501b694929004e43fcd7308f4ad64df2eb0474cd8c7e5f93662bb0f1?d=mp&s=160"},"body":"Hi Jonathan,\n\nOn Fri, Feb 15, 2013 at 10:56 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Hi Paul,\n>\n> Paul Campbell wrote:\n>\n>> --- a/contrib/subtree/t/t7900-subtree.sh\n>> +++ b/contrib/subtree/t/t7900-subtree.sh\n>> @@ -465,4 +465,34 @@ test_expect_success 'verify one file change per commit' '\n> [...]\n>> +test_expect_success 'change in subtree is pushed okay' '\n>> +        cd copy0 && create new_file && git commit -m\"Added new_file\" &&\n>> +        cd .. && git subtree push --prefix=copy0 2>&1 | \\\n>\n> If it possible to restrict the chdirs to subshells, that can make the\n> test more resiliant to early failures without breaking later tests.\n>\n> That is:\n>\n>         (\n>                 cd copy0 &&\n>                 create new_file &&\n>                 test_tick &&\n>                 git commit -m \"add new_file\"\n>         ) &&\n>         git subtree push --prefix=copy0 >output 2>&1 &&\n>         grep \"...\" output\n>\n\nAdding them in.\n\n>> +                grep \"^\\s\\{3\\}[0-9a-f]\\{7\\}\\.\\.[0-9a-f]\\{7\\}\\s\\s[0-9a-f]\\{40\\}\\s->\\ssub1$\"\n>\n> This might not be portable if I understand\n> Documentation/CodingGuidelines correctly.\n>\n\nAnd it's ugly. But I believe it fits the \"don't use grep -E\"\ncondition. Unless I missed something else.\n\nIs there was a better way to verify that the push operation succeeds\nthen grepping for a SHA1?\n\n> [...]\n>> +        (grep \"^copy3 . sub2$\" .gitsubtree && die || true) &&\n>\n>         ! grep \"^copy3 . sub2\\$\" .gitsubtree &&\n>\n> Hope that helps,\n> Jonathan\n\nThanks. That's a much neater way to do it.\n\n-- \nPaul [W] Campbell\n"},{"id":"209596","messageId":"20130217113723.GA9882@elie.Belkin","threadId":"32913","inReplyTo":"CALeLG_nLz9Gfqcfk4EcWixRXbWC0x0GUVFDAKD20DGbkhRNWvQ@mail.gmail.com","subject":"Re: [PATCH 2/3] contrib/subtree/t: Added tests for .gitsubtree support","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2013-02-17T11:37:23Z","receivedAt":"2013-02-17T11:37:23Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Paul Campbell wrote:\n\n> Is there was a better way to verify that the push operation succeeds\n> then grepping for a SHA1?\n\nIIRC then when a push fails, it will exit with nonzero status (so the\nusual &&-chaining would propagate the error).\n\nAlternatively, one can fetch, ls-remote, or enter the target repo and\nuse history inspection tools to check that the result is as expected.\n\nHope that helps,\nJonathan\n"},{"id":"209601","messageId":"CALeLG_n-WocsMTvRZHm6v-+wrCNVvCh6O2baVDALSE3JB8ibng@mail.gmail.com","threadId":"32913","inReplyTo":"20130217113723.GA9882@elie.Belkin","subject":"Re: [PATCH 2/3] contrib/subtree/t: Added tests for .gitsubtree support","fromName":"Paul Campbell","fromEmail":"pcampbell@kemitix.net","sentAt":"2013-02-17T15:26:30Z","receivedAt":"2013-02-17T15:26:30Z","isPatch":true,"sender":{"key":"pcampbell@kemitix.net","avatar":"https://gravatar.com/avatar/57584e05501b694929004e43fcd7308f4ad64df2eb0474cd8c7e5f93662bb0f1?d=mp&s=160"},"body":"On Sun, Feb 17, 2013 at 11:37 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Paul Campbell wrote:\n>\n>> Is there was a better way to verify that the push operation succeeds\n>> then grepping for a SHA1?\n>\n> IIRC then when a push fails, it will exit with nonzero status (so the\n> usual &&-chaining would propagate the error).\n>\n> Alternatively, one can fetch, ls-remote, or enter the target repo and\n> use history inspection tools to check that the result is as expected.\n>\n> Hope that helps,\n> Jonathan\n\nThanks Jonathan.\n\nHere's the updated version of the tests:\n\n contrib/subtree/t/t7900-subtree.sh | 33 +++++++++++++++++++++++++++++++++\n 1 file changed, 33 insertions(+)\n\ndiff --git a/contrib/subtree/t/t7900-subtree.sh\nb/contrib/subtree/t/t7900-subtree.sh\nindex 80d3399..e7bb911 100755\n--- a/contrib/subtree/t/t7900-subtree.sh\n+++ b/contrib/subtree/t/t7900-subtree.sh\n@@ -465,4 +465,37 @@ test_expect_success 'verify one file change per commit' '\n         ))\n '\n\n+# return to mainline\n+cd ../..\n+\n+# .gitsubtree\n+test_expect_success 'added repository appears in .gitsubtree' '\n+\tgit subtree add --prefix=copy0 sub1 &&\n+\tgrep \"^copy0 \\. sub1$\" .gitsubtree\n+'\n+\n+test_expect_success 'change in subtree is pushed okay' '\n+\t(cd copy0 && create new_file && git commit -m\"Added new_file\") &&\n+\tgit ls-tree refs/heads/sub1 >output &&\n+\t! grep \"new_file$\" output &&\n+\tgit subtree push --prefix=copy0 &&\n+\tgit ls-tree refs/heads/sub1 >output &&\n+\tgrep \"new_file$\" output\n+'\n+\n+test_expect_success 'pull into subtree okay' '\n+\tgit subtree add --prefix=copy1 sub1 &&\n+\tgit subtree add --prefix=copy2 sub1 &&\n+\t(cd copy1 && create new_file_in_copy1 && git commit -m\"Added\nnew_file_in_copy1\") &&\n+\tgit subtree push --prefix=copy1 &&\n+\tgit subtree pull --prefix=copy2 | grep \"^ create mode 100644\ncopy2/new_file_in_copy1$\"\n+'\n+\n+test_expect_success 'replace outdated entry in .gitsubtree' '\n+\techo \"copy3 . sub2\" >>.gitsubtree &&\n+\tgit subtree add --prefix=copy3 sub1 &&\n+\t! grep \"^copy3 . sub2$\" .gitsubtree &&\n+\tgrep \"^copy3 . sub1$\" .gitsubtree\n+'\n+\n test_done\n-- \n1.8.1.3.605.g02339dd\n\n\n-- \nPaul [W] Campbell\n"},{"id":"209626","messageId":"20130218003526.GA3221@elie.Belkin","threadId":"32913","inReplyTo":"CALeLG_n-WocsMTvRZHm6v-+wrCNVvCh6O2baVDALSE3JB8ibng@mail.gmail.com","subject":"Re: [PATCH 2/3] contrib/subtree/t: Added tests for .gitsubtree support","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2013-02-18T00:35:26Z","receivedAt":"2013-02-18T00:35:26Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Paul Campbell wrote:\n\n> Here's the updated version of the tests:\n\nJust a few more nits:\n\n> --- a/contrib/subtree/t/t7900-subtree.sh\n> +++ b/contrib/subtree/t/t7900-subtree.sh\n> @@ -465,4 +465,37 @@ test_expect_success 'verify one file change per commit' '\n[...]\n> +test_expect_success 'change in subtree is pushed okay' '\n> +\t(cd copy0 && create new_file && git commit -m\"Added new_file\") &&\n\nStyle: this would be easier to read with each command on a separate\nline, like so:\n\n\t(\n\t\tcd copy0 &&\n\t\tcreate new_file &&\n\t\ttest_tick &&\n\t\tgit commit -m \"Add new_file\"\n\t) &&\n\n[...]\n> +test_expect_success 'pull into subtree okay' '\n> +\tgit subtree add --prefix=copy1 sub1 &&\n> +\tgit subtree add --prefix=copy2 sub1 &&\n> +\t(cd copy1 && create new_file_in_copy1 && git commit -m\"Added new_file_in_copy1\") &&\n\nLikewise (and as a nice side-benefit, it would avoid a long line that\nmailers like to wrap).\n\n> +\tgit subtree push --prefix=copy1 &&\n> +\tgit subtree pull --prefix=copy2 | grep \"^ create mode 100644 copy2/new_file_in_copy1$\"\n\nLikewise.  More importantly, this forgets the exit status from \"git\nsubtree pull\", so if it were to segfault after writing appropriate\noutput, the test wouldn't notice.  How about:\n\n\tgit subtree pull --prefix=copy2 >output &&\n\tgrep \"^ create mode 100644 copy2/new_file_in_copy1\\$\" output\n\nThanks,\nJonathan\n"}]}