2005-06-03 00:50:17 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (C) 2005 Rene Scharfe
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='git-tar-tree and git-get-tar-commit-id test
|
|
|
|
|
2005-06-03 20:21:23 +04:00
|
|
|
This test covers the topics of file contents, commit date handling and
|
|
|
|
commit id embedding:
|
2005-06-03 00:50:17 +04:00
|
|
|
|
|
|
|
The contents of the repository is compared to the extracted tar
|
|
|
|
archive. The repository contains simple text files, symlinks and a
|
2005-06-03 20:21:23 +04:00
|
|
|
binary file (/bin/sh). Only pathes shorter than 99 characters are
|
|
|
|
used.
|
2005-06-03 00:50:17 +04:00
|
|
|
|
|
|
|
git-tar-tree applies the commit date to every file in the archive it
|
|
|
|
creates. The test sets the commit date to a specific value and checks
|
|
|
|
if the tar archive contains that value.
|
|
|
|
|
|
|
|
When giving git-tar-tree a commit id (in contrast to a tree id) it
|
|
|
|
embeds this commit id into the tar archive as a comment. The test
|
|
|
|
checks the ability of git-get-tar-commit-id to figure it out from the
|
|
|
|
tar file.
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'populate workdir' \
|
|
|
|
'mkdir a b c &&
|
|
|
|
echo simple textfile >a/a &&
|
|
|
|
mkdir a/bin &&
|
2005-06-03 20:21:23 +04:00
|
|
|
cp /bin/sh a/bin &&
|
2005-06-03 00:50:17 +04:00
|
|
|
ln -s a a/l1 &&
|
|
|
|
(cd a && find .) | sort >a.lst'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'add files to repository' \
|
2005-09-08 04:26:23 +04:00
|
|
|
'find a -type f | xargs git-update-index --add &&
|
|
|
|
find a -type l | xargs git-update-index --add &&
|
2005-06-03 00:50:17 +04:00
|
|
|
treeid=`git-write-tree` &&
|
|
|
|
echo $treeid >treeid &&
|
2005-10-12 02:15:15 +04:00
|
|
|
git-update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
|
|
|
|
git-commit-tree $treeid </dev/null)'
|
2005-06-03 00:50:17 +04:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'git-tar-tree' \
|
|
|
|
'git-tar-tree HEAD >b.tar'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'validate file modification time' \
|
2005-10-01 00:31:16 +04:00
|
|
|
'TZ=GMT $TAR tvf b.tar a/a |
|
2005-06-14 21:09:39 +04:00
|
|
|
awk \{print\ \$4,\ \(length\(\$5\)\<7\)\ ?\ \$5\":00\"\ :\ \$5\} \
|
|
|
|
>b.mtime &&
|
2005-06-03 00:50:17 +04:00
|
|
|
echo "2005-05-27 22:00:00" >expected.mtime &&
|
|
|
|
diff expected.mtime b.mtime'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'git-get-tar-commit-id' \
|
|
|
|
'git-get-tar-commit-id <b.tar >b.commitid &&
|
2005-10-12 02:15:15 +04:00
|
|
|
diff .git/$(git-symbolic-ref HEAD) b.commitid'
|
2005-06-03 00:50:17 +04:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'extract tar archive' \
|
2005-10-01 00:31:16 +04:00
|
|
|
'(cd b && $TAR xf -) <b.tar'
|
2005-06-03 00:50:17 +04:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'validate filenames' \
|
|
|
|
'(cd b/a && find .) | sort >b.lst &&
|
|
|
|
diff a.lst b.lst'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'validate file contents' \
|
|
|
|
'diff -r a b/a'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'git-tar-tree with prefix' \
|
|
|
|
'git-tar-tree HEAD prefix >c.tar'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'extract tar archive with prefix' \
|
2005-10-01 00:31:16 +04:00
|
|
|
'(cd c && $TAR xf -) <c.tar'
|
2005-06-03 00:50:17 +04:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'validate filenames with prefix' \
|
|
|
|
'(cd c/prefix/a && find .) | sort >c.lst &&
|
|
|
|
diff a.lst c.lst'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'validate file contents with prefix' \
|
|
|
|
'diff -r a c/prefix/a'
|
|
|
|
|
|
|
|
test_done
|