Even more tests to skip due to missing symbolic link support.
[git/mingw.git] / t / t5000-tar-tree.sh
blobfcfa7e4e41d117b9ab5efa3c9f10218ad499add4
1 #!/bin/sh
3 # Copyright (C) 2005 Rene Scharfe
6 test_description='git-tar-tree and git-get-tar-commit-id test
8 This test covers the topics of file contents, commit date handling and
9 commit id embedding:
11 The contents of the repository is compared to the extracted tar
12 archive. The repository contains simple text files, symlinks and a
13 binary file (/bin/sh). Only pathes shorter than 99 characters are
14 used.
16 git-tar-tree applies the commit date to every file in the archive it
17 creates. The test sets the commit date to a specific value and checks
18 if the tar archive contains that value.
20 When giving git-tar-tree a commit id (in contrast to a tree id) it
21 embeds this commit id into the tar archive as a comment. The test
22 checks the ability of git-get-tar-commit-id to figure it out from the
23 tar file.
27 . ./test-lib.sh
28 TAR=${TAR:-tar}
29 UNZIP=${UNZIP:-unzip}
31 test "$no_symlinks" && {
32 function ln () {
33 test "$1" = -s && shift
34 date > "$2"
38 test_expect_success \
39 'populate workdir' \
40 'mkdir a b c &&
41 echo simple textfile >a/a &&
42 mkdir a/bin &&
43 cp /bin/sh a/bin &&
44 ln -s a a/l1 &&
45 (p=long_path_to_a_file && cd a &&
46 for depth in 1 2 3 4 5; do mkdir $p && cd $p; done &&
47 echo text >file_with_long_path) &&
48 (cd a && find .) | sort >a.lst'
50 test_expect_success \
51 'add files to repository' \
52 'find a -type f | xargs git-update-index --add &&
53 find a -type l | xargs git-update-index --add &&
54 treeid=`git-write-tree` &&
55 echo $treeid >treeid &&
56 git-update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
57 git-commit-tree $treeid </dev/null)'
59 test_expect_success \
60 'git-tar-tree' \
61 'git-tar-tree HEAD >b.tar'
63 test_expect_success \
64 'validate file modification time' \
65 'TZ=GMT $TAR tvf b.tar a/a |
66 awk \{print\ \$4,\ \(length\(\$5\)\<7\)\ ?\ \$5\":00\"\ :\ \$5\} \
67 >b.mtime &&
68 echo "2005-05-27 22:00:00" >expected.mtime &&
69 diff expected.mtime b.mtime'
71 test_expect_success \
72 'git-get-tar-commit-id' \
73 'git-get-tar-commit-id <b.tar >b.commitid &&
74 diff .git/$(git-symbolic-ref HEAD) b.commitid'
76 test_expect_success \
77 'extract tar archive' \
78 '(cd b && $TAR xf -) <b.tar'
80 test_expect_success \
81 'validate filenames' \
82 '(cd b/a && find .) | sort >b.lst &&
83 diff a.lst b.lst'
85 test_expect_success \
86 'validate file contents' \
87 'diff -r a b/a'
89 test_expect_success \
90 'git-tar-tree with prefix' \
91 'git-tar-tree HEAD prefix >c.tar'
93 test_expect_success \
94 'extract tar archive with prefix' \
95 '(cd c && $TAR xf -) <c.tar'
97 test_expect_success \
98 'validate filenames with prefix' \
99 '(cd c/prefix/a && find .) | sort >c.lst &&
100 diff a.lst c.lst'
102 test_expect_success \
103 'validate file contents with prefix' \
104 'diff -r a c/prefix/a'
106 test_expect_success \
107 'git-archive --format=zip' \
108 'git-archive --format=zip HEAD >d.zip'
110 test_expect_success \
111 'extract ZIP archive' \
112 '(mkdir d && cd d && $UNZIP ../d.zip)'
114 test_expect_success \
115 'validate filenames' \
116 '(cd d/a && find .) | sort >d.lst &&
117 diff a.lst d.lst'
119 test_expect_success \
120 'validate file contents' \
121 'diff -r a d/a'
123 test_expect_success \
124 'git-archive --format=zip with prefix' \
125 'git-archive --format=zip --prefix=prefix/ HEAD >e.zip'
127 test_expect_success \
128 'extract ZIP archive with prefix' \
129 '(mkdir e && cd e && $UNZIP ../e.zip)'
131 test_expect_success \
132 'validate filenames with prefix' \
133 '(cd e/prefix/a && find .) | sort >e.lst &&
134 diff a.lst e.lst'
136 test_expect_success \
137 'validate file contents with prefix' \
138 'diff -r a e/prefix/a'
140 test_done