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