git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] t5004: avoid using tar for checking emptiness of archive

From
Eric Sunshine <sunshine@sunshineco.com>
Date
May 9, 2013, 18:21 UTC
Message-ID
<CAPig+cTidjz4D1vZ7Aci4YZK8ph9HJ1vMqZ1-n2hVPbLuf4AKw@mail.gmail.com>
In-Reply-To
<518BA10B.2080003@lsrfire.ath.cx>

On Thu, May 9, 2013 at 9:13 AM, René Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:

Show 48 quoted lines
> Test 2 of t5004 checks if a supposedly empty tar archive really
> contains no files.  24676f02 (t5004: fix issue with empty archive test
> and bsdtar) removed our commit hash to make it work with bsdtar, but
> the test still fails on NetBSD and OpenBSD, which use their own tar
> that considers a tar file containing only NULs as broken.
>
> Here's what the different archivers do when asked to create a tar
> file without entries:
>
>         $ uname -v
>         NetBSD 6.0.1 (GENERIC)
>         $ gtar --version | head -1
>         tar (GNU tar) 1.26
>         $ bsdtar --version
>         bsdtar 2.8.4 - libarchive 2.8.4
>
>         $ : >zero.tar
>         $ perl -e 'print "\0" x 10240' >tenk.tar
>         $ sha1 zero.tar tenk.tar
>         SHA1 (zero.tar) = da39a3ee5e6b4b0d3255bfef95601890afd80709
>         SHA1 (tenk.tar) = 34e163be8e43c5631d8b92e9c43ab0bf0fa62b9c
>
>         $ : | tar cf - -T - | sha1
>         da39a3ee5e6b4b0d3255bfef95601890afd80709
>         $ : | gtar cf - -T - | sha1
>         34e163be8e43c5631d8b92e9c43ab0bf0fa62b9c
>         $ : | bsdtar cf - -T - | sha1
>         34e163be8e43c5631d8b92e9c43ab0bf0fa62b9c
>
> So NetBSD's native tar creates an empty file, while GNU tar and bsdtar
> both give us 10KB of NULs -- just like git archive with an empty tree.
> Now let's see how the archivers handle these two kinds of empty tar
> files:
>
>         $ tar tf zero.tar; echo $?
>         tar: Unexpected EOF on archive file
>         1
>         $ gtar tf zero.tar; echo $?
>         gtar: This does not look like a tar archive
>         gtar: Exiting with failure status due to previous errors
>         2
>         $ bsdtar tf zero.tar; echo $?
>         0
>
>         $ tar tf tenk.tar; echo $?
>         tar: Cannot identify format. Searching...
>         tar: End of archive volume 1 reached
>         tar: Sorry, unable to determine archive format.
Missing "echo $?" output.
Show 17 quoted lines
>         $ gtar tf tenk.tar; echo $?
>         0
>         $ bsdtar tf tenk.tar; echo $?
>         0
>
> NetBSD's tar complains about both, bsdtar happily accepts any of them
> and GNU tar doesn't like zero-length archive files.  So the safest
> course of action is to stay with our block-of-NULs format which is
> compatible with GNU tar and bsdtar, as we can't make NetBSD's native
> tar happy anyway.
>
> We can simplify our test, however, by taking tar out of the picture.
> Instead of extracting the archive and checking for the non-presence of
> files, check if the file has a size of 10KB and contains only NULs.
> This makes t5004 pass on NetBSD and OpenBSD.
>
> Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Previous: Jonathan NiederNext: René Scharfe
Message 5 of 6 in “t5004: ignore pax global header file”
  1. 1/2 t5004: ignore pax global header fileRené Scharfe, May 9, 2013
  2. 2/2 t5004: avoid using tar for checking emptiness of archiveRené Scharfe, May 9, 2013
  3. 3/2 t5004: resurrect original empty tar archive testRené Scharfe, May 9, 2013
  4. Jonathan NiederMay 11, 2013
  5. Eric SunshineMay 9, 2013
  6. René ScharfeMay 9, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.