]>
Commit | Line | Data |
---|---|---|
d3d49c3d RS |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (C) 2005 Rene Scharfe | |
4 | # | |
5 | ||
6 | test_description='git-tar-tree and git-get-tar-commit-id test | |
7 | ||
5b860406 RS |
8 | This test covers the topics of file contents, commit date handling and |
9 | commit id embedding: | |
d3d49c3d RS |
10 | |
11 | The contents of the repository is compared to the extracted tar | |
12 | archive. The repository contains simple text files, symlinks and a | |
3dff5379 | 13 | binary file (/bin/sh). Only paths shorter than 99 characters are |
5b860406 | 14 | used. |
d3d49c3d RS |
15 | |
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. | |
19 | ||
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. | |
24 | ||
25 | ' | |
26 | ||
27 | . ./test-lib.sh | |
cb34882b | 28 | TAR=${TAR:-tar} |
62cdce17 | 29 | UNZIP=${UNZIP:-unzip} |
d3d49c3d RS |
30 | |
31 | test_expect_success \ | |
32 | 'populate workdir' \ | |
33 | 'mkdir a b c && | |
d3d49c3d | 34 | echo simple textfile >a/a && |
d3d49c3d | 35 | mkdir a/bin && |
5b860406 | 36 | cp /bin/sh a/bin && |
d3d49c3d | 37 | ln -s a a/l1 && |
4c691724 RS |
38 | (p=long_path_to_a_file && cd a && |
39 | for depth in 1 2 3 4 5; do mkdir $p && cd $p; done && | |
40 | echo text >file_with_long_path) && | |
d3d49c3d RS |
41 | (cd a && find .) | sort >a.lst' |
42 | ||
43 | test_expect_success \ | |
44 | 'add files to repository' \ | |
215a7ad1 JH |
45 | 'find a -type f | xargs git-update-index --add && |
46 | find a -type l | xargs git-update-index --add && | |
d3d49c3d RS |
47 | treeid=`git-write-tree` && |
48 | echo $treeid >treeid && | |
0a81552e JS |
49 | git-update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \ |
50 | git-commit-tree $treeid </dev/null)' | |
d3d49c3d RS |
51 | |
52 | test_expect_success \ | |
53 | 'git-tar-tree' \ | |
54 | 'git-tar-tree HEAD >b.tar' | |
55 | ||
56 | test_expect_success \ | |
57 | 'validate file modification time' \ | |
455a7f32 | 58 | 'TZ=GMT $TAR tvf b.tar a/a | |
7737314d MA |
59 | awk \{print\ \$4,\ \(length\(\$5\)\<7\)\ ?\ \$5\":00\"\ :\ \$5\} \ |
60 | >b.mtime && | |
d3d49c3d RS |
61 | echo "2005-05-27 22:00:00" >expected.mtime && |
62 | diff expected.mtime b.mtime' | |
63 | ||
64 | test_expect_success \ | |
65 | 'git-get-tar-commit-id' \ | |
66 | 'git-get-tar-commit-id <b.tar >b.commitid && | |
0a81552e | 67 | diff .git/$(git-symbolic-ref HEAD) b.commitid' |
d3d49c3d RS |
68 | |
69 | test_expect_success \ | |
70 | 'extract tar archive' \ | |
455a7f32 | 71 | '(cd b && $TAR xf -) <b.tar' |
d3d49c3d RS |
72 | |
73 | test_expect_success \ | |
74 | 'validate filenames' \ | |
75 | '(cd b/a && find .) | sort >b.lst && | |
76 | diff a.lst b.lst' | |
77 | ||
78 | test_expect_success \ | |
79 | 'validate file contents' \ | |
80 | 'diff -r a b/a' | |
81 | ||
82 | test_expect_success \ | |
83 | 'git-tar-tree with prefix' \ | |
84 | 'git-tar-tree HEAD prefix >c.tar' | |
85 | ||
86 | test_expect_success \ | |
87 | 'extract tar archive with prefix' \ | |
455a7f32 | 88 | '(cd c && $TAR xf -) <c.tar' |
d3d49c3d RS |
89 | |
90 | test_expect_success \ | |
91 | 'validate filenames with prefix' \ | |
92 | '(cd c/prefix/a && find .) | sort >c.lst && | |
93 | diff a.lst c.lst' | |
94 | ||
95 | test_expect_success \ | |
96 | 'validate file contents with prefix' \ | |
97 | 'diff -r a c/prefix/a' | |
98 | ||
62cdce17 RS |
99 | test_expect_success \ |
100 | 'git-archive --format=zip' \ | |
101 | 'git-archive --format=zip HEAD >d.zip' | |
102 | ||
103 | test_expect_success \ | |
104 | 'extract ZIP archive' \ | |
105 | '(mkdir d && cd d && $UNZIP ../d.zip)' | |
106 | ||
107 | test_expect_success \ | |
108 | 'validate filenames' \ | |
109 | '(cd d/a && find .) | sort >d.lst && | |
110 | diff a.lst d.lst' | |
111 | ||
112 | test_expect_success \ | |
113 | 'validate file contents' \ | |
114 | 'diff -r a d/a' | |
115 | ||
116 | test_expect_success \ | |
117 | 'git-archive --format=zip with prefix' \ | |
118 | 'git-archive --format=zip --prefix=prefix/ HEAD >e.zip' | |
119 | ||
120 | test_expect_success \ | |
121 | 'extract ZIP archive with prefix' \ | |
122 | '(mkdir e && cd e && $UNZIP ../e.zip)' | |
123 | ||
124 | test_expect_success \ | |
125 | 'validate filenames with prefix' \ | |
126 | '(cd e/prefix/a && find .) | sort >e.lst && | |
127 | diff a.lst e.lst' | |
128 | ||
129 | test_expect_success \ | |
130 | 'validate file contents with prefix' \ | |
131 | 'diff -r a e/prefix/a' | |
132 | ||
265d5280 RS |
133 | test_expect_success \ |
134 | 'git-archive --list outside of a git repo' \ | |
135 | 'GIT_DIR=some/non-existing/directory git-archive --list' | |
136 | ||
d3d49c3d | 137 | test_done |