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 10, 2013, 17:00 UTC
Message-ID
<51659AA4.80203@lsrfire.ath.cx>
In-Reply-To
<ABD0C67A-0B2B-4E32-AF49-93FBABC032A7@bjhargrave.com>
Am 08.04.2013 20:36, schrieb BJ Hargrave:
Show 30 quoted lines
> 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.
> 
> expecting success:
> 	git archive --format=tar HEAD >empty.tar &&
> 	make_dir extract &&
> 	"$TAR" xf empty.tar -C extract &&
> 	check_dir extract
> 
> tar: Damaged tar archive
> tar: Error exit delayed from previous errors.
> not ok 2 - tar archive of empty tree is empty
> 
> tar tf "trash directory.t5004-archive-corner-cases/empty.tar"; echo $?
> tar: Damaged tar archive
> tar: Error exit delayed from previous errors.
> 1
> 
> 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

I've opened an issue for libarchive for that behaviour: http://code.google.com/p/libarchive/issues/detail?id=314

We can work around bsdtar's dislike of not-quite-empty tar archives by leaving out the comment that contains the commit hash.

-- >8 --
Subject: t5004: fix issue with empty archive test and bsdtar

bsdtar, which is the default tar on Mac OS X, handles empty archives just fine but reports archives containing only a pax extended header comment as damaged. Work around the issue by explicitly generating the archive for the tree and not the commit, which causes git archive to omit the commit hash comment record from the tar file.

Reported-by: BJ Hargrave <bj@bjhargrave.com>
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 t/t5004-archive-corner-cases.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh
index cdb7d7a..bfdb56a 100755
--- a/t/t5004-archive-corner-cases.sh
+++ b/t/t5004-archive-corner-cases.sh
@@ -28,7 +28,7 @@ check_dir() {
 }
 
 test_expect_success 'tar archive of empty tree is empty' '
-	git archive --format=tar HEAD >empty.tar &&
+	git archive --format=tar HEAD: >empty.tar &&
 	make_dir extract &&
 	"$TAR" xf empty.tar -C extract &&
 	check_dir extract
-- 
1.8.2.1
Previous: René Scharfe
Message 5 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.