From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
Subject: Re: [PATCH 0/2] fix git-archive with empty trees
Date: Mon, 11 Mar 2013 00:58:11 -0400 [thread overview]
Message-ID: <20130311045811.GA13510@sigill.intra.peff.net> (raw)
In-Reply-To: <20130311013123.GA11692@sigill.intra.peff.net>
On Sun, Mar 10, 2013 at 09:31:24PM -0400, Jeff King wrote:
> I noticed that "git archive" will barf when the root tree is empty.
> [...]
> I didn't bother even looking at empty subtrees. AFAIK, git should never
> produce them (it omits the tree entirely if there is no content in it).
> You would have to fake it using hash-object manually. I suspect it would
> work just fine, as we already exercise the empty-dir code paths in the
> tests I did add.
Curious, I went ahead and tested this. It does indeed work as expected.
The following tests can be squashed into patch 2/2 if we want:
diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh
index 395dd58..cdb7d7a 100755
--- a/t/t5004-archive-corner-cases.sh
+++ b/t/t5004-archive-corner-cases.sh
@@ -80,4 +80,23 @@ test_expect_success 'archive complains about pathspec on empty tree' '
test_must_fail git archive --format=tar HEAD -- foo >/dev/null
'
+test_expect_success 'create a commit with an empty subtree' '
+ empty_tree=$(git hash-object -t tree /dev/null) &&
+ root_tree=$(printf "040000 tree $empty_tree\tsub\n" | git mktree)
+'
+
+test_expect_success 'archive empty subtree with no pathspec' '
+ git archive --format=tar $root_tree >subtree-all.tar &&
+ make_dir extract &&
+ "$TAR" xf subtree-all.tar -C extract &&
+ check_dir extract sub
+'
+
+test_expect_success 'archive empty subtree by direct pathspec' '
+ git archive --format=tar $root_tree -- sub >subtree-path.tar &&
+ make_dir extract &&
+ "$TAR" xf subtree-path.tar -C extract &&
+ check_dir extract sub
+'
+
test_done
next prev parent reply other threads:[~2013-03-11 4:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-11 1:31 [PATCH 0/2] fix git-archive with empty trees Jeff King
2013-03-11 1:31 ` [PATCH 1/2] test-lib: factor out $GIT_UNZIP setup Jeff King
2013-03-11 1:32 ` [PATCH 2/2] archive: handle commits with an empty tree Jeff King
2013-03-11 4:58 ` Jeff King [this message]
2013-03-11 5:25 ` [PATCH 0/2] fix git-archive with empty trees Junio C Hamano
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=20130311045811.GA13510@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=rene.scharfe@lsrfire.ath.cx \
/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).