]>
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 | |
5b860406 RS |
13 | binary file (/bin/sh). Only pathes shorter than 99 characters are |
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} |
d3d49c3d RS |
29 | |
30 | test_expect_success \ | |
31 | 'populate workdir' \ | |
32 | 'mkdir a b c && | |
d3d49c3d | 33 | echo simple textfile >a/a && |
d3d49c3d | 34 | mkdir a/bin && |
5b860406 | 35 | cp /bin/sh a/bin && |
d3d49c3d | 36 | ln -s a a/l1 && |
d3d49c3d RS |
37 | (cd a && find .) | sort >a.lst' |
38 | ||
39 | test_expect_success \ | |
40 | 'add files to repository' \ | |
215a7ad1 JH |
41 | 'find a -type f | xargs git-update-index --add && |
42 | find a -type l | xargs git-update-index --add && | |
d3d49c3d RS |
43 | treeid=`git-write-tree` && |
44 | echo $treeid >treeid && | |
0a81552e JS |
45 | git-update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \ |
46 | git-commit-tree $treeid </dev/null)' | |
d3d49c3d RS |
47 | |
48 | test_expect_success \ | |
49 | 'git-tar-tree' \ | |
50 | 'git-tar-tree HEAD >b.tar' | |
51 | ||
52 | test_expect_success \ | |
53 | 'validate file modification time' \ | |
455a7f32 | 54 | 'TZ=GMT $TAR tvf b.tar a/a | |
7737314d MA |
55 | awk \{print\ \$4,\ \(length\(\$5\)\<7\)\ ?\ \$5\":00\"\ :\ \$5\} \ |
56 | >b.mtime && | |
d3d49c3d RS |
57 | echo "2005-05-27 22:00:00" >expected.mtime && |
58 | diff expected.mtime b.mtime' | |
59 | ||
60 | test_expect_success \ | |
61 | 'git-get-tar-commit-id' \ | |
62 | 'git-get-tar-commit-id <b.tar >b.commitid && | |
0a81552e | 63 | diff .git/$(git-symbolic-ref HEAD) b.commitid' |
d3d49c3d RS |
64 | |
65 | test_expect_success \ | |
66 | 'extract tar archive' \ | |
455a7f32 | 67 | '(cd b && $TAR xf -) <b.tar' |
d3d49c3d RS |
68 | |
69 | test_expect_success \ | |
70 | 'validate filenames' \ | |
71 | '(cd b/a && find .) | sort >b.lst && | |
72 | diff a.lst b.lst' | |
73 | ||
74 | test_expect_success \ | |
75 | 'validate file contents' \ | |
76 | 'diff -r a b/a' | |
77 | ||
78 | test_expect_success \ | |
79 | 'git-tar-tree with prefix' \ | |
80 | 'git-tar-tree HEAD prefix >c.tar' | |
81 | ||
82 | test_expect_success \ | |
83 | 'extract tar archive with prefix' \ | |
455a7f32 | 84 | '(cd c && $TAR xf -) <c.tar' |
d3d49c3d RS |
85 | |
86 | test_expect_success \ | |
87 | 'validate filenames with prefix' \ | |
88 | '(cd c/prefix/a && find .) | sort >c.lst && | |
89 | diff a.lst c.lst' | |
90 | ||
91 | test_expect_success \ | |
92 | 'validate file contents with prefix' \ | |
93 | 'diff -r a c/prefix/a' | |
94 | ||
95 | test_done |