[PATCH] Additional git-archive tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Helped-by: Eric Sunshine <sunshine@xxxxxxxxxxxxxx>
Signed-off-by: Nick Townsend <nick.townsend@xxxxxxx>
---
 t/t5004-archive-corner-cases.sh | 71 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh
index 67f3b54..a81a836 100755
--- a/t/t5004-archive-corner-cases.sh
+++ b/t/t5004-archive-corner-cases.sh
@@ -113,4 +113,75 @@ 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 a/b/d &&
+	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
+	) &&
+	make_dir extract &&
+	"$TAR" xf asubtree.tar -C extract &&
+	check_dir extract af b b/bf b/c b/c/cf
+'
+
+test_expect_success 'archive subtree from subdir with treeish' '
+	(
+		cd a &&
+		git archive --format=tar HEAD:./b >../absubtree.tar
+	) &&
+	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
+	) &&
+	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
+	) &&
+	make_dir extract &&
+	"$TAR" xf abxsubtree.tar -C extract &&
+	check_dir extract bf c c/cf
+'
+
 test_done
-- 
1.8.5

On 3 Dec 2013, at 09:54, Junio C Hamano <gitster@xxxxxxxxx> wrote:

> Eric Sunshine <sunshine@xxxxxxxxxxxxxx> writes:
> 
>>> +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 ...
>>    ...
> 
> Thanks, and please indent the commands run in the subshell for
> better readability.

--
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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]