{"thread":{"id":"49912","subject":"[BUG REPORT] t5322: demonstrate a pack-objects bug","startedAt":"2018-11-28T19:45:42Z","lastAt":"2018-11-28T19:56:00Z","messageCount":2,"participants":["Derrick Stolee"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"364241","messageId":"20181128194536.57019-1-dstolee@microsoft.com","threadId":"49912","inReplyTo":null,"subject":"[BUG REPORT] t5322: demonstrate a pack-objects bug","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-11-28T19:45:36Z","receivedAt":"2018-11-28T19:45:42Z","isPatch":false,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"I was preparing a new \"sparse\" algorithm for calculating the\ninteresting objects to send on push. The important steps happen\nduring 'git pack-objects', so I was creating test cases to see\nhow the behavior changes in narrow cases. Specifically, when\ncopying a directory across sibling directories (see test case),\nthe new logic would accidentally send that object as an extra.\n\nHowever, I found a bug in the existing logic. The included test\ndemonstrates this during the final 'git index-pack' call. It\nfails with the message\n\n\t'fatal: pack has 1 unresolved delta'\n\nIt is probable that this is not a minimal test case, but happens\nto be the test I had created before discovering the problem.\n\nI compiled v2.17.0 and v2.12.0 as checks to see if I could find\na \"good\" commit with which to start a bisect, but both failed.\nThis is an old bug!\n\nSigned-off-by: Derrick Stolee <dstolee@microsoft.com>\n---\n t/t5322-pack-objects-sparse.sh | 94 ++++++++++++++++++++++++++++++++++\n 1 file changed, 94 insertions(+)\n create mode 100755 t/t5322-pack-objects-sparse.sh\n\ndiff --git a/t/t5322-pack-objects-sparse.sh b/t/t5322-pack-objects-sparse.sh\nnew file mode 100755\nindex 0000000000..36faa70fe9\n--- /dev/null\n+++ b/t/t5322-pack-objects-sparse.sh\n@@ -0,0 +1,94 @@\n+#!/bin/sh\n+\n+test_description='pack-objects object selection using sparse algorithm'\n+. ./test-lib.sh\n+\n+test_expect_success 'setup repo' '\n+\ttest_commit initial &&\n+\tfor i in $(test_seq 1 3)\n+\tdo\n+\t\tmkdir f$i &&\n+\t\tfor j in $(test_seq 1 3)\n+\t\tdo\n+\t\t\tmkdir f$i/f$j &&\n+\t\t\techo $j >f$i/f$j/data.txt\n+\t\tdone\n+\tdone &&\n+\tgit add . &&\n+\tgit commit -m \"Initialized trees\" &&\n+\tfor i in $(test_seq 1 3)\n+\tdo\n+\t\tgit checkout -b topic$i master &&\n+\t\techo change-$i >f$i/f$i/data.txt &&\n+\t\tgit commit -a -m \"Changed f$i/f$i/data.txt\"\n+\tdone &&\n+\tcat >packinput.txt <<-EOF &&\n+\ttopic1\n+\t^topic2\n+\t^topic3\n+\tEOF\n+\tgit rev-parse\t\t\t\\\n+\t\ttopic1\t\t\t\\\n+\t\ttopic1^{tree}\t\t\\\n+\t\ttopic1:f1\t\t\\\n+\t\ttopic1:f1/f1\t\t\\\n+\t\ttopic1:f1/f1/data.txt | sort >actual_objects.txt\n+'\n+\n+test_expect_success 'non-sparse pack-objects' '\n+\tgit pack-objects --stdout --thin --revs <packinput.txt >nonsparse.pack &&\n+\tgit index-pack -o nonsparse.idx nonsparse.pack &&\n+\tgit show-index <nonsparse.idx | awk \"{print \\$2}\" >nonsparse_objects.txt &&\n+\ttest_cmp actual_objects.txt nonsparse_objects.txt\n+'\n+\n+# Demonstrate that both algorithms send \"extra\" objects because\n+# they are not in the frontier.\n+\n+test_expect_success 'duplicate a folder from f3 and commit to topic1' '\n+\tgit checkout topic1 &&\n+\techo change-3 >f3/f3/data.txt &&\n+\tgit commit -a -m \"Changed f3/f3/data.txt\" &&\n+\tgit rev-parse\t\t\t\\\n+\t\ttopic1~1\t\t\\\n+\t\ttopic1~1^{tree}\t\t\\\n+\t\ttopic1^{tree}\t\t\\\n+\t\ttopic1\t\t\t\\\n+\t\ttopic1:f1\t\t\\\n+\t\ttopic1:f1/f1\t\t\\\n+\t\ttopic1:f1/f1/data.txt\t\\\n+\t\ttopic1:f3\t\t\\\n+\t\ttopic1:f3/f3\t\t\\\n+\t\ttopic1:f3/f3/data.txt | sort >actual_objects.txt\n+'\n+\n+test_expect_success 'non-sparse pack-objects' '\n+\tgit pack-objects --stdout --thin --revs <packinput.txt >nonsparse.pack &&\n+\tgit index-pack -o nonsparse.idx nonsparse.pack &&\n+\tgit show-index <nonsparse.idx | awk \"{print \\$2}\" >nonsparse_objects.txt &&\n+\ttest_cmp actual_objects.txt nonsparse_objects.txt\n+'\n+\n+test_expect_success 'duplicate a folder from f3 and commit to topic1' '\n+\tmkdir f3/f4 &&\n+\tcp -r f1/f1/* f3/f4 &&\n+\tgit add f3/f4 &&\n+\tgit commit -m \"Copied f1/f1 to f3/f4\" &&\n+\tcat >packinput.txt <<-EOF &&\n+\ttopic1\n+\t^topic1~1\n+\tEOF\n+\tgit rev-parse\t\t\\\n+\t\ttopic1\t\t\\\n+\t\ttopic1^{tree}\t\\\n+\t\ttopic1:f3 | sort >actual_objects.txt\n+'\n+\n+test_expect_success 'non-sparse pack-objects' '\n+\tgit pack-objects --stdout --thin --revs <packinput.txt >nonsparse.pack &&\n+\tgit index-pack -o nonsparse.idx nonsparse.pack &&\n+\tgit show-index <nonsparse.idx | awk \"{print \\$2}\" >nonsparse_objects.txt &&\n+\ttest_cmp actual_objects.txt nonsparse_objects.txt\n+'\n+\n+test_done\n-- \n2.20.0.rc1\n\n"},{"id":"364242","messageId":"8774b686-e399-975f-b033-421b3ec1427d@gmail.com","threadId":"49912","inReplyTo":"20181128194536.57019-1-dstolee@microsoft.com","subject":"Re: [BUG REPORT] t5322: demonstrate a pack-objects bug","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-11-28T19:55:55Z","receivedAt":"2018-11-28T19:56:00Z","isPatch":false,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 11/28/2018 2:45 PM, Derrick Stolee wrote:\n> I was preparing a new \"sparse\" algorithm for calculating the\n> interesting objects to send on push. The important steps happen\n> during 'git pack-objects', so I was creating test cases to see\n> how the behavior changes in narrow cases. Specifically, when\n> copying a directory across sibling directories (see test case),\n> the new logic would accidentally send that object as an extra.\n>\n> However, I found a bug in the existing logic. The included test\n> demonstrates this during the final 'git index-pack' call. It\n> fails with the message\n>\n> \t'fatal: pack has 1 unresolved delta'\n\nI realize now that I've gone through this effort that the problem is me \n(of course it is).\n\n> +\tgit pack-objects --stdout --thin --revs <packinput.txt >nonsparse.pack &&\n\nSince I'm packing thin packs, the index operation is complaining about \ndeltas. So, I need to use a different mechanism to list the objects in \nthe pack (say, 'git verify-pack -v').\n\nSorry for the noise!\n\nThanks,\n\n-Stolee\n\n"}]}