{"thread":{"id":"33437","subject":"tar on Mac does not like empty tar from git archive","startedAt":"2013-04-08T18:36:05Z","lastAt":"2013-04-10T17:00:20Z","messageCount":5,"participants":["BJ Hargrave","Jeff King","René Scharfe"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"213576","messageId":"ABD0C67A-0B2B-4E32-AF49-93FBABC032A7@bjhargrave.com","threadId":"33437","inReplyTo":null,"subject":"tar on Mac does not like empty tar from git archive","fromName":"BJ Hargrave","fromEmail":"bj@bjhargrave.com","sentAt":"2013-04-08T18:36:05Z","receivedAt":"2013-04-08T18:36:05Z","isPatch":false,"sender":{"key":"bj@bjhargrave.com","avatar":"https://gravatar.com/avatar/48e60c01177c0e8d3e60c996d54fbe36cf70058efcdd020375b4055e34fc05d7?d=mp&s=160"},"body":"Git 1.8.2.1 includes commit bd54cf17 - archive: handle commits with an empty tree\n\nTest 2 of t5004-archive-corner-cases, \"tar archive of empty tree is empty\", fails on Mac OS X 10.8.3 (with XCode 4.6.1) since the tar command exits with return code 1 on the generated  tar file.\n\nexpecting success: \n\tgit archive --format=tar HEAD >empty.tar &&\n\tmake_dir extract &&\n\t\"$TAR\" xf empty.tar -C extract &&\n\tcheck_dir extract\n\ntar: Damaged tar archive\ntar: Error exit delayed from previous errors.\nnot ok 2 - tar archive of empty tree is empty\n\ntar tf \"trash directory.t5004-archive-corner-cases/empty.tar\"; echo $?\ntar: Damaged tar archive\ntar: Error exit delayed from previous errors.\n1\n\ntar --version\nbsdtar 2.8.3 - libarchive 2.8.3\n\nIt appears that bsdtar does not like the empty tar files created by git archive. An empty tar file created by bsdtar is accepted.\n\ntar cT /dev/null | tar t; echo $?\n0\n\n-- \n\nBJ Hargrave\n"},{"id":"213606","messageId":"20130408210536.GB9649@sigill.intra.peff.net","threadId":"33437","inReplyTo":"ABD0C67A-0B2B-4E32-AF49-93FBABC032A7@bjhargrave.com","subject":"Re: tar on Mac does not like empty tar from git archive","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-04-08T21:05:36Z","receivedAt":"2013-04-08T21:05:36Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Apr 08, 2013 at 02:36:05PM -0400, BJ Hargrave wrote:\n\n> Git 1.8.2.1 includes commit bd54cf17 - archive: handle commits with an\n> empty tree\n> \n> Test 2 of t5004-archive-corner-cases, \"tar archive of empty tree is\n> empty\", fails on Mac OS X 10.8.3 (with XCode 4.6.1) since the tar\n> command exits with return code 1 on the generated  tar file.\n\nHmm. So I guess the question is: do we need to work around this in the\ntest for platforms that do not like empty tar files, or are the empty\ntarfiles we are making wrong somehow?\n\n> tar --version\n> bsdtar 2.8.3 - libarchive 2.8.3\n> \n> It appears that bsdtar does not like the empty tar files created by\n> git archive. An empty tar file created by bsdtar is accepted.\n> \n> tar cT /dev/null | tar t; echo $?\n> 0\n\nThat makes me think the latter (\"we are wrong\"). I don't have my OS X\nbox handy; can you provide a sample empty tarfile that it creates?\n\n-Peff\n"},{"id":"213623","messageId":"9AA8143E-C8A2-4EB3-AB35-27C7031B4ED7@bjhargrave.com","threadId":"33437","inReplyTo":"20130408210536.GB9649@sigill.intra.peff.net","subject":"Re: tar on Mac does not like empty tar from git archive","fromName":"BJ Hargrave","fromEmail":"bj@bjhargrave.com","sentAt":"2013-04-08T22:07:14Z","receivedAt":"2013-04-08T22:07:14Z","isPatch":false,"sender":{"key":"bj@bjhargrave.com","avatar":"https://gravatar.com/avatar/48e60c01177c0e8d3e60c996d54fbe36cf70058efcdd020375b4055e34fc05d7?d=mp&s=160"},"body":"\nOn Apr 8, 2013, at 17:05 , Jeff King <peff@peff.net> wrote:\n\n> That makes me think the latter (\"we are wrong\"). I don't have my OS X\n> box handy; can you provide a sample empty tarfile that it creates?\n\nI created mac.tar on my Mac and linux.tar on a RHEL6.3 machine (tar (GNU tar) 1.23). Both were created with \n\ntar cTf /dev/null xxx.tar\n\nBoth files are accepted by tar on both the Mac and the RHEL machines. (Both files contain nothing but zeros.)\n\n-- \n\nBJ Hargrave\n\n\n"},{"id":"213708","messageId":"51646E12.2030506@lsrfire.ath.cx","threadId":"33437","inReplyTo":"20130408210536.GB9649@sigill.intra.peff.net","subject":"Re: tar on Mac does not like empty tar from git archive","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2013-04-09T19:37:54Z","receivedAt":"2013-04-09T19:37:54Z","isPatch":false,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 08.04.2013 23:05, schrieb Jeff King:\n> On Mon, Apr 08, 2013 at 02:36:05PM -0400, BJ Hargrave wrote:\n> \n>> Git 1.8.2.1 includes commit bd54cf17 - archive: handle commits with an\n>> empty tree\n>>\n>> Test 2 of t5004-archive-corner-cases, \"tar archive of empty tree is\n>> empty\", fails on Mac OS X 10.8.3 (with XCode 4.6.1) since the tar\n>> command exits with return code 1 on the generated  tar file.\n> \n> Hmm. So I guess the question is: do we need to work around this in the\n> test for platforms that do not like empty tar files, or are the empty\n> tarfiles we are making wrong somehow?\n> \n>> tar --version\n>> bsdtar 2.8.3 - libarchive 2.8.3\n>>\n>> It appears that bsdtar does not like the empty tar files created by\n>> git archive. An empty tar file created by bsdtar is accepted.\n>>\n>> tar cT /dev/null | tar t; echo $?\n>> 0\n> \n> That makes me think the latter (\"we are wrong\"). I don't have my OS X\n> box handy; can you provide a sample empty tarfile that it creates?\n\nlibarchive (on which bsdtar is based) doesn't like extended pax headers\nat the end of archives.  Here's the relevant source file:\n\nhttps://github.com/libarchive/libarchive/blob/master/libarchive/archive_read_support_format_tar.c\n\ntar_read_header() calls header_pax_global() to handle a global pax\nheader, which in turn calls tar_read_header() again to fetch the next\nheader.  If it reaches the end of the archive then err is set to\nARCHIVE_EOF and \"Damaged tar archive\" is reported at the end of this\nfunction.\n\nI tried come up with a small patch that convinces it to ignore such a\ncondition, but it's apparently not as easy as it looks -- I just made\nbsdtar report even more obscure errors.  Will look deeper into it\nlater this week.\n\nRené\n"},{"id":"213787","messageId":"51659AA4.80203@lsrfire.ath.cx","threadId":"33437","inReplyTo":"ABD0C67A-0B2B-4E32-AF49-93FBABC032A7@bjhargrave.com","subject":"Re: tar on Mac does not like empty tar from git archive","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2013-04-10T17:00:20Z","receivedAt":"2013-04-10T17:00:20Z","isPatch":false,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 08.04.2013 20:36, schrieb BJ Hargrave:\n> Git 1.8.2.1 includes commit bd54cf17 - archive: handle commits with\n> an empty tree\n> \n> Test 2 of t5004-archive-corner-cases, \"tar archive of empty tree is\n> empty\", fails on Mac OS X 10.8.3 (with XCode 4.6.1) since the tar\n> command exits with return code 1 on the generated tar file.\n> \n> expecting success:\n> \tgit archive --format=tar HEAD >empty.tar &&\n> \tmake_dir extract &&\n> \t\"$TAR\" xf empty.tar -C extract &&\n> \tcheck_dir extract\n> \n> tar: Damaged tar archive\n> tar: Error exit delayed from previous errors.\n> not ok 2 - tar archive of empty tree is empty\n> \n> tar tf \"trash directory.t5004-archive-corner-cases/empty.tar\"; echo $?\n> tar: Damaged tar archive\n> tar: Error exit delayed from previous errors.\n> 1\n> \n> tar --version\n> bsdtar 2.8.3 - libarchive 2.8.3\n> \n> It appears that bsdtar does not like the empty tar files created by\n> git archive. An empty tar file created by bsdtar is accepted.\n> \n> tar cT /dev/null | tar t; echo $?\n> 0\n\nI've opened an issue for libarchive for that behaviour:\nhttp://code.google.com/p/libarchive/issues/detail?id=314\n\nWe can work around bsdtar's dislike of not-quite-empty tar archives by\nleaving out the comment that contains the commit hash.\n\n-- >8 --\nSubject: t5004: fix issue with empty archive test and bsdtar\n\nbsdtar, which is the default tar on Mac OS X, handles empty archives\njust fine but reports archives containing only a pax extended header\ncomment as damaged.  Work around the issue by explicitly generating\nthe archive for the tree and not the commit, which causes git archive\nto omit the commit hash comment record from the tar file.\n\nReported-by: BJ Hargrave <bj@bjhargrave.com>\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n t/t5004-archive-corner-cases.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh\nindex cdb7d7a..bfdb56a 100755\n--- a/t/t5004-archive-corner-cases.sh\n+++ b/t/t5004-archive-corner-cases.sh\n@@ -28,7 +28,7 @@ check_dir() {\n }\n \n test_expect_success 'tar archive of empty tree is empty' '\n-\tgit archive --format=tar HEAD >empty.tar &&\n+\tgit archive --format=tar HEAD: >empty.tar &&\n \tmake_dir extract &&\n \t\"$TAR\" xf empty.tar -C extract &&\n \tcheck_dir extract\n-- \n1.8.2.1\n"}]}