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