test: fix post rewrite hook report
[gitweb.git] / t / t5000-tar-tree.sh
index 8337a1f2cfa0fc58dd897cfec53804ae054adb62..c2023b1a3d78a7f100207a76678957d2659f8a8d 100755 (executable)
@@ -30,6 +30,32 @@ GUNZIP=${GUNZIP:-gzip -d}
 
 SUBSTFORMAT=%H%n
 
+test_lazy_prereq TAR_NEEDS_PAX_FALLBACK '
+       (
+               mkdir pax &&
+               cd pax &&
+               "$TAR" xf "$TEST_DIRECTORY"/t5000/pax.tar &&
+               test -f PaxHeaders.1791/file
+       )
+'
+
+get_pax_header() {
+       file=$1
+       header=$2=
+
+       while read len rest
+       do
+               if test "$len" = $(echo "$len $rest" | wc -c)
+               then
+                       case "$rest" in
+                       $header*)
+                               echo "${rest#$header}"
+                               ;;
+                       esac
+               fi
+       done <"$file"
+}
+
 check_tar() {
        tarfile=$1.tar
        listfile=$1.lst
@@ -40,6 +66,24 @@ check_tar() {
                (mkdir $dir && cd $dir && "$TAR" xf -) <$tarfile
        '
 
+       test_expect_success TAR_NEEDS_PAX_FALLBACK ' interpret pax headers' '
+               (
+                       cd $dir &&
+                       for header in *.paxheader
+                       do
+                               data=${header%.paxheader}.data &&
+                               if test -h $data -o -e $data
+                               then
+                                       path=$(get_pax_header $header path) &&
+                                       if test -n "$path"
+                                       then
+                                               mv "$data" "$path"
+                                       fi
+                               fi
+                       done
+               )
+       '
+
        test_expect_success ' validate filenames' '
                (cd ${dir_with_prefix}a && find .) | sort >$listfile &&
                test_cmp a.lst $listfile
@@ -54,6 +98,8 @@ test_expect_success \
     'populate workdir' \
     'mkdir a &&
      echo simple textfile >a/a &&
+     ten=0123456789 && hundred=$ten$ten$ten$ten$ten$ten$ten$ten$ten$ten &&
+     echo long filename >a/four$hundred &&
      mkdir a/bin &&
      cp /bin/sh a/bin &&
      printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 &&
@@ -103,13 +149,17 @@ test_expect_success \
 
 check_tar b
 
-test_expect_success \
-    'git tar-tree' \
-    'git tar-tree HEAD >b2.tar'
+test_expect_success 'git archive --prefix=prefix/' '
+       git archive --prefix=prefix/ HEAD >with_prefix.tar
+'
 
-test_expect_success \
-    'git archive vs. git tar-tree' \
-    'test_cmp b.tar b2.tar'
+check_tar with_prefix prefix/
+
+test_expect_success 'git-archive --prefix=olde-' '
+       git archive --prefix=olde- HEAD >with_olde-prefix.tar
+'
+
+check_tar with_olde-prefix olde-
 
 test_expect_success 'git archive on large files' '
     test_config core.bigfilethreshold 1 &&
@@ -146,22 +196,15 @@ test_expect_success \
     'git get-tar-commit-id <b.tar >b.commitid &&
      test_cmp .git/$(git symbolic-ref HEAD) b.commitid'
 
-test_expect_success \
-    'git tar-tree with prefix' \
-    'git tar-tree HEAD prefix >c.tar'
-
-test_expect_success \
-    'extract tar archive with prefix' \
-    '(mkdir c && cd c && "$TAR" xf -) <c.tar'
-
-test_expect_success \
-    'validate filenames with prefix' \
-    '(cd c/prefix/a && find .) | sort >c.lst &&
-     test_cmp a.lst c.lst'
+test_expect_success 'git tar-tree' '
+       git tar-tree HEAD >tar-tree.tar &&
+       test_cmp b.tar tar-tree.tar
+'
 
-test_expect_success \
-    'validate file contents with prefix' \
-    'diff -r a c/prefix/a'
+test_expect_success 'git tar-tree with prefix' '
+       git tar-tree HEAD prefix >tar-tree_with_prefix.tar &&
+       test_cmp with_prefix.tar tar-tree_with_prefix.tar
+'
 
 test_expect_success 'git archive with --output, override inferred format' '
        git archive --format=tar --output=d4.zip HEAD &&
@@ -180,18 +223,6 @@ test_expect_success 'clients cannot access unreachable commits' '
        test_must_fail git archive --remote=. $sha1 >remote.tar
 '
 
-test_expect_success 'git-archive --prefix=olde-' '
-       git archive --prefix=olde- >h.tar HEAD &&
-       (
-               mkdir h &&
-               cd h &&
-               "$TAR" xf - <../h.tar
-       ) &&
-       test -d h/olde-a &&
-       test -d h/olde-a/bin &&
-       test -f h/olde-a/bin/sh
-'
-
 test_expect_success 'setup tar filters' '
        git config tar.tar.foo.command "tr ab ba" &&
        git config tar.bar.command "tr ab ba" &&