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

Re: tar on Mac does not like empty tar from git archive

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Apr 9, 2013, 19:37 UTC
Message-ID
<51646E12.2030506@lsrfire.ath.cx>
In-Reply-To
<20130408210536.GB9649@sigill.intra.peff.net>
Am 08.04.2013 23:05, schrieb Jeff King:
Show 24 quoted lines
> On Mon, Apr 08, 2013 at 02:36:05PM -0400, BJ Hargrave wrote:
> 
>> Git 1.8.2.1 includes commit bd54cf17 - archive: handle commits with an
>> empty tree
>>
>> Test 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.
> 
> Hmm. So I guess the question is: do we need to work around this in the
> test for platforms that do not like empty tar files, or are the empty
> tarfiles we are making wrong somehow?
> 
>> tar --version
>> bsdtar 2.8.3 - libarchive 2.8.3
>>
>> It appears that bsdtar does not like the empty tar files created by
>> git archive. An empty tar file created by bsdtar is accepted.
>>
>> tar cT /dev/null | tar t; echo $?
>> 0
> 
> That makes me think the latter ("we are wrong"). I don't have my OS X
> box handy; can you provide a sample empty tarfile that it creates?

libarchive (on which bsdtar is based) doesn't like extended pax headers at the end of archives. Here's the relevant source file:

https://github.com/libarchive/libarchive/blob/master/libarchive/archive_read_support_format_tar.c

tar_read_header() calls header_pax_global() to handle a global pax header, which in turn calls tar_read_header() again to fetch the next header. If it reaches the end of the archive then err is set to ARCHIVE_EOF and "Damaged tar archive" is reported at the end of this function.

I tried come up with a small patch that convinces it to ignore such a condition, but it's apparently not as easy as it looks -- I just made bsdtar report even more obscure errors. Will look deeper into it later this week.

René
Previous: BJ HargraveNext: René Scharfe
Message 4 of 5 in “tar on Mac does not like empty tar from git archive”
  1. BJ HargraveApr 8, 2013
  2. Jeff KingApr 8, 2013
  3. BJ HargraveApr 8, 2013
  4. René ScharfeApr 9, 2013
  5. René ScharfeApr 10, 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.