verify-tag: also grok CR/LFs in the tag signature
[git/mingw/4msysgit/wingit-dll.git] / t / t5000-tar-tree.sh
bloba76c0f632bbbaa9d0b581347e2d478b456e75d37
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 paths 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}
29 UNZIP=${UNZIP:-unzip}
31 test "$no_symlinks" && {
32 function ln () {
33 test "$1" = -s && shift
34 date > "$2"
38 test_expect_success \
39 'populate workdir' \
40 'mkdir a b c &&
41 echo simple textfile >a/a &&
42 mkdir a/bin &&
43 cp /bin/sh a/bin &&
44 ln -s a a/l1 &&
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'
50 test_expect_success \
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)'
59 test_expect_success \
60 'git archive' \
61 'git archive HEAD >b.tar'
63 test_expect_success \
64 'git tar-tree' \
65 'git tar-tree HEAD >b2.tar'
67 test_expect_success \
68 'git archive vs. git tar-tree' \
69 'diff b.tar b2.tar'
71 test_expect_success \
72 'validate file modification time' \
73 'TZ=GMT $TAR tvf b.tar a/a |
74 awk \{print\ \$4,\ \(length\(\$5\)\<7\)\ ?\ \$5\":00\"\ :\ \$5\} \
75 >b.mtime &&
76 echo "2005-05-27 22:00:00" >expected.mtime &&
77 diff expected.mtime b.mtime'
79 test_expect_success \
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'
84 test_expect_success \
85 'extract tar archive' \
86 '(cd b && $TAR xf -) <b.tar'
88 test_expect_success \
89 'validate filenames' \
90 '(cd b/a && /usr/bin/find .) | /usr/bin/sort >b.lst &&
91 diff a.lst b.lst'
93 test_expect_success \
94 'validate file contents' \
95 'diff -r a b/a'
97 test_expect_success \
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 &&
108 diff a.lst 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"
121 test_done
122 exit
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 &&
132 diff a.lst d.lst'
134 test_expect_success \
135 'validate file contents' \
136 'diff -r a d/a'
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 &&
149 diff a.lst 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'
159 test_done