git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: git discussion list <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
	BJ Hargrave <bj@bjhargrave.com>
Subject: [PATCH 3/2] t5004: resurrect original empty tar archive test
Date: Thu, 09 May 2013 15:36:10 +0200	[thread overview]
Message-ID: <518BA64A.5020302@lsrfire.ath.cx> (raw)
In-Reply-To: <518BA10B.2080003@lsrfire.ath.cx>

Add a test to verify the emptiness of an archive by extracting its
contents.  Don't run this test if the version of tar doesn't support
archives containing only a comment header, though.

The existing check 'tar archive of empty tree is empty' used to work
like that (minus the tar capability check) but was changed to depend
on the exact representation of empty tar files created by git archive
instead of on the behaviour of tar in order to avoid issues with
different tar versions.

The different approaches test different things: The existing one is
for empty trees, for which we know the exact expected output and thus
we can simply check it without extracting; the new one is for commits
with empty trees, whose archives include stamps and so the more
"natural" check by extraction is a better fit because it focuses on
the interesting aspect, namely the absence of any archive entries.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
Not urgent.  By the way: A fix for the bsdtar issue worked around by
our 24676f02 (t5004: fix issue with empty archive test and bsdtar) has
been committed to the libarchive repo, but it's not in any released
version, yet.

 t/t5004-archive-corner-cases.sh   |  14 ++++++++++++++
 t/t5004/empty-with-pax-header.tar | Bin 0 -> 10240 bytes
 2 files changed, 14 insertions(+)
 create mode 100644 t/t5004/empty-with-pax-header.tar

diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh
index 8d1bbd3..f25f06b 100755
--- a/t/t5004-archive-corner-cases.sh
+++ b/t/t5004-archive-corner-cases.sh
@@ -27,6 +27,20 @@ check_dir() {
 	test_cmp expect actual
 }
 
+# bsdtar/libarchive versions before 3.1.3 consider a tar file with a
+# global pax header that is not followed by a file record as corrupt.
+if "$TAR" tf "$TEST_DIRECTORY"/t5004/empty-with-pax-header.tar >/dev/null 2>&1
+then
+	test_set_prereq HEADER_ONLY_TAR_OK
+fi
+
+test_expect_success HEADER_ONLY_TAR_OK 'tar archive of commit with empty tree' '
+	git archive --format=tar HEAD >empty-with-pax-header.tar &&
+	make_dir extract &&
+	"$TAR" xf empty-with-pax-header.tar -C extract &&
+	check_dir extract
+'
+
 test_expect_success 'tar archive of empty tree is empty' '
 	git archive --format=tar HEAD: >empty.tar &&
 	perl -e "print \"\\0\" x 10240" >10knuls.tar &&
diff --git a/t/t5004/empty-with-pax-header.tar b/t/t5004/empty-with-pax-header.tar
new file mode 100644
index 0000000000000000000000000000000000000000..da9e39e6cf49841254a2d75aabb9ef575f9fd805
GIT binary patch
literal 10240
zcmeIuF%H5Y6vlC8PvH>&fx_TfnwHW!v|?&aJib+jCU$V?VB-HRkMITZ-tSV~%dXFL
z)t9GKHE9&vmz>KvC!T$-&pwAnD6NckQtDT(j47<>wjX8v<Lx?C<2=%s^R!Nvn{WAh
zw`IBI<xiii-p4!)={y}{+a@P%2!(3ZA%xgSuTAZ&@lBAmw}p36CcpdXg%}P21Q0*~
t0R#|0009ILKmY**5I_I{1Q0*~0R#|0009ILKmY**5I_I{1Q7TWfd`KEC+GkG

literal 0
HcmV?d00001

-- 
1.8.2.1

  reply	other threads:[~2013-05-09 13:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-09 13:10 [PATCH 1/2] t5004: ignore pax global header file René Scharfe
2013-05-09 13:13 ` [PATCH 2/2] t5004: avoid using tar for checking emptiness of archive René Scharfe
2013-05-09 13:36   ` René Scharfe [this message]
2013-05-11  6:03     ` [PATCH 3/2] t5004: resurrect original empty tar archive test Jonathan Nieder
2013-05-09 18:21   ` [PATCH 2/2] t5004: avoid using tar for checking emptiness of archive Eric Sunshine
2013-05-09 19:12     ` René Scharfe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=518BA64A.5020302@lsrfire.ath.cx \
    --to=rene.scharfe@lsrfire.ath.cx \
    --cc=bj@bjhargrave.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).