{"thread":{"id":"49932","subject":"[PATCH] t5004: avoid using tar for empty packages","startedAt":"2018-12-02T02:40:09Z","lastAt":"2018-12-03T01:29:45Z","messageCount":2,"participants":["Carlo Marcelo Arenas Belón","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"364429","messageId":"20181202024003.65103-1-carenas@gmail.com","threadId":"49932","inReplyTo":null,"subject":"[PATCH] t5004: avoid using tar for empty packages","fromName":"Carlo Marcelo Arenas Belón","fromEmail":"carenas@gmail.com","sentAt":"2018-12-02T02:40:03Z","receivedAt":"2018-12-02T02:40:09Z","isPatch":true,"sender":{"key":"carenas@gmail.com","avatar":"https://avatars.githubusercontent.com/u/76036?v=4"},"body":"ea2d20d4c2 (\"t5004: avoid using tar for checking emptiness of archive\",\n2013-05-09), introduced a fake empty tar archive to allow for portable\ntests of emptiness without having to invoke tar\n\n4318094047 (\"archive: don't add empty directories to archives\", 2017-09-13)\nchanged the expected result for its tests from one containing an empty\ndirectory to a plain empty archive but the portable test wasn't updated\nresulting on them failing again in (at least) NetBSD and OpenBSD\n\nSigned-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>\n---\n t/t5004-archive-corner-cases.sh | 17 ++++++++---------\n 1 file changed, 8 insertions(+), 9 deletions(-)\n\ndiff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh\nindex ced44355ca..271eb5a1fd 100755\n--- a/t/t5004-archive-corner-cases.sh\n+++ b/t/t5004-archive-corner-cases.sh\n@@ -3,8 +3,12 @@\n test_description='test corner cases of git-archive'\n . ./test-lib.sh\n \n-test_expect_success 'create commit with empty tree' '\n-\tgit commit --allow-empty -m foo\n+# the 10knuls.tar file is used to test for an empty git generated tar\n+# without having to invoke tar because an otherwise valid empty GNU tar\n+# will be considered broken by {Open,Net}BSD tar\n+test_expect_success 'create commit with empty tree and fake empty tar' '\n+\tgit commit --allow-empty -m foo &&\n+\tperl -e \"print \\\"\\\\0\\\" x 10240\" >10knuls.tar\n '\n \n # Make a dir and clean it up afterwards\n@@ -47,7 +51,6 @@ test_expect_success HEADER_ONLY_TAR_OK 'tar archive of commit with empty tree' '\n \n test_expect_success 'tar archive of empty tree is empty' '\n \tgit archive --format=tar HEAD: >empty.tar &&\n-\tperl -e \"print \\\"\\\\0\\\" x 10240\" >10knuls.tar &&\n \ttest_cmp_bin 10knuls.tar empty.tar\n '\n \n@@ -106,16 +109,12 @@ test_expect_success 'create a commit with an empty subtree' '\n \n test_expect_success 'archive empty subtree with no pathspec' '\n \tgit archive --format=tar $root_tree >subtree-all.tar &&\n-\tmake_dir extract &&\n-\t\"$TAR\" xf subtree-all.tar -C extract &&\n-\tcheck_dir extract\n+\ttest_cmp_bin 10knuls.tar subtree-all.tar\n '\n \n test_expect_success 'archive empty subtree by direct pathspec' '\n \tgit archive --format=tar $root_tree -- sub >subtree-path.tar &&\n-\tmake_dir extract &&\n-\t\"$TAR\" xf subtree-path.tar -C extract &&\n-\tcheck_dir extract\n+\ttest_cmp_bin 10knuls.tar subtree-path.tar\n '\n \n ZIPINFO=zipinfo\n-- \n2.20.0.rc2\n\n"},{"id":"364462","messageId":"xmqqh8fvgzym.fsf@gitster-ct.c.googlers.com","threadId":"49932","inReplyTo":"20181202024003.65103-1-carenas@gmail.com","subject":"Re: [PATCH] t5004: avoid using tar for empty packages","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-12-03T01:29:21Z","receivedAt":"2018-12-03T01:29:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Carlo Marcelo Arenas Belón  <carenas@gmail.com> writes:\n\n> ea2d20d4c2 (\"t5004: avoid using tar for checking emptiness of archive\",\n> 2013-05-09), introduced a fake empty tar archive to allow for portable\n> tests of emptiness without having to invoke tar\n>\n> 4318094047 (\"archive: don't add empty directories to archives\", 2017-09-13)\n> changed the expected result for its tests from one containing an empty\n> directory to a plain empty archive but the portable test wasn't updated\n> resulting on them failing again in (at least) NetBSD and OpenBSD\n>\n> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>\n> ---\n>  t/t5004-archive-corner-cases.sh | 17 ++++++++---------\n>  1 file changed, 8 insertions(+), 9 deletions(-)\n>\n> diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh\n> index ced44355ca..271eb5a1fd 100755\n> --- a/t/t5004-archive-corner-cases.sh\n> +++ b/t/t5004-archive-corner-cases.sh\n> @@ -3,8 +3,12 @@\n>  test_description='test corner cases of git-archive'\n>  . ./test-lib.sh\n>  \n> -test_expect_success 'create commit with empty tree' '\n> -\tgit commit --allow-empty -m foo\n> +# the 10knuls.tar file is used to test for an empty git generated tar\n> +# without having to invoke tar because an otherwise valid empty GNU tar\n> +# will be considered broken by {Open,Net}BSD tar\n> +test_expect_success 'create commit with empty tree and fake empty tar' '\n> +\tgit commit --allow-empty -m foo &&\n> +\tperl -e \"print \\\"\\\\0\\\" x 10240\" >10knuls.tar\n>  '\n\nOK, so you moved the creation of the file with block of NULs to the\nset-up phase of the entire script.\n\n>  # Make a dir and clean it up afterwards\n> @@ -47,7 +51,6 @@ test_expect_success HEADER_ONLY_TAR_OK 'tar archive of commit with empty tree' '\n>  \n>  test_expect_success 'tar archive of empty tree is empty' '\n>  \tgit archive --format=tar HEAD: >empty.tar &&\n> -\tperl -e \"print \\\"\\\\0\\\" x 10240\" >10knuls.tar &&\n>  \ttest_cmp_bin 10knuls.tar empty.tar\n>  '\n\nAnd because of that, this one that was added for ea2d20d4 (\"t5004:\navoid using tar for checking emptiness of archive\", 2013-05-09) is\nnow simplified.  It can use the one that was created in the set-up\nphase.\n\n> @@ -106,16 +109,12 @@ test_expect_success 'create a commit with an empty subtree' '\n>  \n>  test_expect_success 'archive empty subtree with no pathspec' '\n>  \tgit archive --format=tar $root_tree >subtree-all.tar &&\n> -\tmake_dir extract &&\n> -\t\"$TAR\" xf subtree-all.tar -C extract &&\n> -\tcheck_dir extract\n> +\ttest_cmp_bin 10knuls.tar subtree-all.tar\n>  '\n\nAnd then we avoid the test that assumes that an empty tar archive\ncan safely and portably extracted, and instead check the emptiness\nthe same way as the earlier test here ...\n\n>  test_expect_success 'archive empty subtree by direct pathspec' '\n>  \tgit archive --format=tar $root_tree -- sub >subtree-path.tar &&\n> -\tmake_dir extract &&\n> -\t\"$TAR\" xf subtree-path.tar -C extract &&\n> -\tcheck_dir extract\n> +\ttest_cmp_bin 10knuls.tar subtree-path.tar\n>  '\n\n... and here, too.\n\nOK, and the result is consistent with the \"We can help GNU and BSD\ntar, but NetBSD tar cannot be salvageable\" approach, laid out in the\nearlier ea2d20d4 (\"t5004: avoid using tar for checking emptiness of\narchive\", 2013-05-09).  Makes sense.\n\nThanks.\n"}]}