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
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 paths shorter than 99 characters are
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
31 test "$no_symlinks" && {
33 test "$1" = -s && shift
41 echo simple textfile >a/a &&
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 && /usr/bin/find .) | /usr/bin/sort >a.lst'
51 'add files to repository' \
52 '/usr/bin/find a -type f | xargs git update-index --add &&
53 /usr/bin/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)'
61 'git archive HEAD >b.tar'
65 'git tar-tree HEAD >b2.tar'
68 'git archive vs. git tar-tree' \
72 'validate file modification time' \
73 'TZ=GMT $TAR tvf b.tar a/a |
74 awk \{print\ \$4,\ \(length\(\$5\)\<7\)\ ?\ \$5\":00\"\ :\ \$5\} \
76 echo "2005-05-27 22:00:00" >expected.mtime &&
77 diff expected.mtime b.mtime'
80 'git get-tar-commit-id' \
81 'git get-tar-commit-id <b.tar >b.commitid &&
82 diff .git/$(git symbolic-ref HEAD) b.commitid'
85 'extract tar archive' \
86 '(cd b && $TAR xf -) <b.tar'
89 'validate filenames' \
90 '(cd b/a && /usr/bin/find .) | /usr/bin/sort >b.lst &&
94 'validate file contents' \
98 'git tar-tree with prefix' \
99 'git tar-tree HEAD prefix >c.tar'
101 test_expect_success \
102 'extract tar archive with prefix' \
103 '(cd c && $TAR xf -) <c.tar'
105 test_expect_success \
106 'validate filenames with prefix' \
107 '(cd c/prefix/a && /usr/bin/find .) | /usr/bin/sort >c.lst &&
110 test_expect_success \
111 'validate file contents with prefix' \
112 'diff -r a c/prefix/a'
114 test_expect_success \
115 'git archive --format=zip' \
116 'git archive --format=zip HEAD >d.zip'
118 $UNZIP -v >/dev
/null
2>&1
119 if [ $?
-eq 127 ]; then
120 echo "Skipping ZIP tests, because unzip was not found"
125 test_expect_success \
126 'extract ZIP archive' \
127 '(mkdir d && cd d && $UNZIP ../d.zip)'
129 test_expect_success \
130 'validate filenames' \
131 '(cd d/a && /usr/bin/find .) | /usr/bin/sort >d.lst &&
134 test_expect_success \
135 'validate file contents' \
138 test_expect_success \
139 'git archive --format=zip with prefix' \
140 'git archive --format=zip --prefix=prefix/ HEAD >e.zip'
142 test_expect_success \
143 'extract ZIP archive with prefix' \
144 '(mkdir e && cd e && $UNZIP ../e.zip)'
146 test_expect_success \
147 'validate filenames with prefix' \
148 '(cd e/prefix/a && /usr/bin/find .) | /usr/bin/sort >e.lst &&
151 test_expect_success \
152 'validate file contents with prefix' \
153 'diff -r a e/prefix/a'
155 test_expect_success \
156 'git archive --list outside of a git repo' \
157 'GIT_DIR=some/non-existing/directory git archive --list'