On Mon, Dec 2, 2013 at 7:16 PM, Nick Townsend <nick.townsend@xxxxxxx> wrote: > From: Nick Townsend <nick.townsend@xxxxxxx> > Date: Sat, 30 Nov 2013 16:54:20 -0800 > Subject: [PATCH 2/2] Additional git-archive tests > > Interplay between paths specified in three ways now tested: > * After a : in the tree-ish, > * As a pathspec in the command, > * By virtue of the current working directory > > Note that these tests are based on the behaviours > as found in 1.8.5. They may not be intentional. > They were developed to regression test enhancements > made to parse_treeish_arg() in archive.c > > Signed-off-by: Nick Townsend <nick.townsend@xxxxxxx> > --- > t/t5004-archive-corner-cases.sh | 67 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 67 insertions(+) > > diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh > index 67f3b54..8b70e4a 100755 > --- a/t/t5004-archive-corner-cases.sh > +++ b/t/t5004-archive-corner-cases.sh > @@ -113,4 +113,71 @@ test_expect_success 'archive empty subtree by direct pathspec' ' > check_dir extract sub > ' > > +test_expect_success 'setup - repository with subdirs' ' > + mkdir -p a/b/{c,d} && Unportable use of {foo,bar} notation. POSIX shells [1] will just create a directory named "{c,d}". Better to spell it out: mkdir -p a/b/c a/b/d && [1]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13 > + echo af >a/af && > + echo bf >a/b/bf && > + echo cf >a/b/c/cf && > + git add a && > + git commit -m "commit 1" && > + git tag -a -m "rev-1" rev-1 > +' > + > +test_expect_success 'archive subtree from root by treeish' ' > + git archive --format=tar HEAD:a >atreeroot.tar && > + make_dir extract && > + "$TAR" xf atreeroot.tar -C extract && > + check_dir extract af b b/bf b/c b/c/cf > +' > + > +test_expect_success 'archive subtree from root with pathspec' ' > + git archive --format=tar HEAD a >atreepath.tar && > + make_dir extract && > + "$TAR" xf atreepath.tar -C extract && > + check_dir extract a a/af a/b a/b/bf a/b/c a/b/c/cf > +' > + > +test_expect_success 'archive subtree from root by 2-level treeish' ' > + git archive --format=tar HEAD:a/b >abtreeroot.tar && > + make_dir extract && > + "$TAR" xf abtreeroot.tar -C extract && > + check_dir extract bf c c/cf > +' > + > +test_expect_success 'archive subtree from subdir' ' > + cd a && > + git archive --format=tar HEAD >../asubtree.tar && > + cd .. && > + make_dir extract && > + "$TAR" xf asubtree.tar -C extract && > + check_dir extract af b b/bf b/c b/c/cf > +' If git-archive fails, the subsequent 'cd ..' will not be invoked, hence all tests following this one will fail since the current directory has not been restored. If you place the 'cd a' in a subshell, then the current directory remains unchanged for commands outside the subshell (and you can drop the 'cd ..'): ( cd a && git archive ... ) && make_dir ... ... Ditto for the remaining tests which share this problem. > + > +test_expect_success 'archive subtree from subdir with treeish' ' > + cd a && > + git archive --format=tar HEAD:./b >../absubtree.tar && > + cd .. && > + make_dir extract && > + "$TAR" xf absubtree.tar -C extract && > + check_dir extract bf c c/cf > +' > + > +test_expect_success 'archive subtree from subdir with treeish and pathspec' ' > + cd a && > + git archive --format=tar HEAD:./b c >../absubtree.tar && > + cd .. && > + make_dir extract && > + "$TAR" xf absubtree.tar -C extract && > + check_dir extract c c/cf > +' > + > +test_expect_success 'archive subtree from subdir with alt treeish' ' > + cd a && > + git archive --format=tar HEAD:b >../abxsubtree.tar && > + cd .. && > + make_dir extract && > + "$TAR" xf abxsubtree.tar -C extract && > + check_dir extract bf c c/cf > +' > + > test_done > -- > 1.8.5.4.g9d8cd78.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html