t / t5000-tar-tree.shon commit [PATCH] -w support for git-ssh-pull/push (c7c4bbe)
   1#!/bin/sh
   2#
   3# Copyright (C) 2005 Rene Scharfe
   4#
   5
   6test_description='git-tar-tree and git-get-tar-commit-id test
   7
   8This test covers the topics of file contents, commit date handling and
   9commit id embedding:
  10
  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.
  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
  29test_expect_success \
  30    'populate workdir' \
  31    'mkdir a b c &&
  32     echo simple textfile >a/a &&
  33     mkdir a/bin &&
  34     cp /bin/sh a/bin &&
  35     ln -s a a/l1 &&
  36     (cd a && find .) | sort >a.lst'
  37
  38test_expect_success \
  39    'add files to repository' \
  40    'find a -type f | xargs git-update-cache --add &&
  41     find a -type l | xargs git-update-cache --add &&
  42     treeid=`git-write-tree` &&
  43     echo $treeid >treeid &&
  44     TZ= GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
  45     git-commit-tree $treeid </dev/null >.git/HEAD'
  46
  47test_expect_success \
  48    'git-tar-tree' \
  49    'git-tar-tree HEAD >b.tar'
  50
  51test_expect_success \
  52    'validate file modification time' \
  53    'tar tvf b.tar a/a |
  54     awk \{print\ \$4,\ length\(\$5\)\<7\ ?\ \$5\":00\"\ :\ \$5\} >b.mtime &&
  55     echo "2005-05-27 22:00:00" >expected.mtime &&
  56     diff expected.mtime b.mtime'
  57
  58test_expect_success \
  59    'git-get-tar-commit-id' \
  60    'git-get-tar-commit-id <b.tar >b.commitid &&
  61     diff .git/HEAD b.commitid'
  62
  63test_expect_success \
  64    'extract tar archive' \
  65    '(cd b && tar xf -) <b.tar'
  66
  67test_expect_success \
  68    'validate filenames' \
  69    '(cd b/a && find .) | sort >b.lst &&
  70     diff a.lst b.lst'
  71
  72test_expect_success \
  73    'validate file contents' \
  74    'diff -r a b/a'
  75
  76test_expect_success \
  77    'git-tar-tree with prefix' \
  78    'git-tar-tree HEAD prefix >c.tar'
  79
  80test_expect_success \
  81    'extract tar archive with prefix' \
  82    '(cd c && tar xf -) <c.tar'
  83
  84test_expect_success \
  85    'validate filenames with prefix' \
  86    '(cd c/prefix/a && find .) | sort >c.lst &&
  87     diff a.lst c.lst'
  88
  89test_expect_success \
  90    'validate file contents with prefix' \
  91    'diff -r a c/prefix/a'
  92
  93test_done