Move make_cache_entry() from merge-recursive.c into read-cache.c
[gitweb.git] / t / t9200-git-cvsexportcommit.sh
index 315119abff31bfe7cdb85e0d7f2d29f5cf89a8b5..910c584f242c6b29fc6d398d2433703765abbcc5 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # Copyright (c) Robin Rosenberg
 #
@@ -28,6 +28,18 @@ git add empty &&
 git commit -q -a -m "Initial" 2>/dev/null ||
 exit 1
 
+check_entries () {
+       # $1 == directory, $2 == expected
+       grep '^/' "$1/CVS/Entries" | sort | cut -d/ -f2,3,5 >actual
+       if test -z "$2"
+       then
+               >expected
+       else
+               printf '%s\n' "$2" | tr '|' '\012' >expected
+       fi
+       diff -u expected actual
+}
+
 test_expect_success \
     'New file' \
     'mkdir A B C D E F &&
@@ -43,10 +55,10 @@ test_expect_success \
      id=$(git rev-list --max-count=1 HEAD) &&
      (cd "$CVSWORK" &&
      git cvsexportcommit -c $id &&
-     test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.1/" &&
-     test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "newfile2.txt/1.1/" &&
-     test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "newfile3.png/1.1/-kb" &&
-     test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "newfile4.png/1.1/-kb" &&
+     check_entries A "newfile1.txt/1.1/" &&
+     check_entries B "newfile2.txt/1.1/" &&
+     check_entries C "newfile3.png/1.1/-kb" &&
+     check_entries D "newfile4.png/1.1/-kb" &&
      diff A/newfile1.txt ../A/newfile1.txt &&
      diff B/newfile2.txt ../B/newfile2.txt &&
      diff C/newfile3.png ../C/newfile3.png &&
@@ -67,12 +79,12 @@ test_expect_success \
      id=$(git rev-list --max-count=1 HEAD) &&
      (cd "$CVSWORK" &&
      git cvsexportcommit -c $id &&
-     test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.2/" &&
-     test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
-     test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
-     test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "newfile4.png/1.2/-kb" &&
-     test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
-     test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
+     check_entries A "newfile1.txt/1.2/" &&
+     check_entries B "" &&
+     check_entries C "" &&
+     check_entries D "newfile4.png/1.2/-kb" &&
+     check_entries E "newfile5.txt/1.1/" &&
+     check_entries F "newfile6.png/1.1/-kb" &&
      diff A/newfile1.txt ../A/newfile1.txt &&
      diff D/newfile4.png ../D/newfile4.png &&
      diff E/newfile5.txt ../E/newfile5.txt &&
@@ -115,12 +127,12 @@ test_expect_success \
      id=$(git rev-list --max-count=1 HEAD) &&
      (cd "$CVSWORK" &&
      git cvsexportcommit -c $id &&
-     test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.2/" &&
-     test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
-     test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
-     test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
-     test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
-     test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
+     check_entries A "newfile1.txt/1.2/" &&
+     check_entries B "" &&
+     check_entries C "" &&
+     check_entries D "" &&
+     check_entries E "newfile5.txt/1.1/" &&
+     check_entries F "newfile6.png/1.1/-kb" &&
      diff A/newfile1.txt ../A/newfile1.txt &&
      diff E/newfile5.txt ../E/newfile5.txt &&
      diff F/newfile6.png ../F/newfile6.png
@@ -133,12 +145,12 @@ test_expect_success \
      id=$(git rev-list --max-count=1 HEAD) &&
      (cd "$CVSWORK" &&
      git cvsexportcommit -c $id &&
-     test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
-     test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
-     test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
-     test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
-     test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
-     test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
+     check_entries A "" &&
+     check_entries B "" &&
+     check_entries C "" &&
+     check_entries D "" &&
+     check_entries E "newfile5.txt/1.1/" &&
+     check_entries F "newfile6.png/1.1/-kb" &&
      diff E/newfile5.txt ../E/newfile5.txt &&
      diff F/newfile6.png ../F/newfile6.png
      )'
@@ -154,7 +166,7 @@ test_expect_success \
       id=$(git rev-list --max-count=1 HEAD) &&
       (cd "$CVSWORK" &&
       git-cvsexportcommit -c $id &&
-      test "$(echo $(sort "G g/CVS/Entries"|cut -d/ -f2,3,5))" = "with spaces.png/1.1/-kb with spaces.txt/1.1/"
+      check_entries "G g" "with spaces.png/1.1/-kb|with spaces.txt/1.1/"
       )'
 
 test_expect_success \
@@ -166,24 +178,40 @@ test_expect_success \
       id=$(git rev-list --max-count=1 HEAD) &&
       (cd "$CVSWORK" &&
       git-cvsexportcommit -c $id
-      test "$(echo $(sort "G g/CVS/Entries"|cut -d/ -f2,3,5))" = "with spaces.png/1.2/-kb with spaces.txt/1.2/"
+      check_entries "G g" "with spaces.png/1.2/-kb|with spaces.txt/1.2/"
       )'
 
-# This test contains ISO-8859-1 characters
+# Some filesystems mangle pathnames with UTF-8 characters --
+# check and skip
+if p="Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö" &&
+       mkdir -p "tst/$p" &&
+       date >"tst/$p/day" &&
+       found=$(find tst -type f -print) &&
+       test "z$found" = "ztst/$p/day" &&
+       rm -fr tst
+then
+
+# This test contains UTF-8 characters
 test_expect_success \
      'File with non-ascii file name' \
-     'mkdir -p Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö &&
-      echo Foo >Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
-      git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
-      cp ../test9200a.png Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
-      git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
-      git commit -a -m "Går det så går det" && \
+     'mkdir -p Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö &&
+      echo Foo >Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
+      git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
+      cp ../test9200a.png Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
+      git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
+      git commit -a -m "Går det så går det" && \
       id=$(git rev-list --max-count=1 HEAD) &&
       (cd "$CVSWORK" &&
       git-cvsexportcommit -v -c $id &&
-      test "$(echo $(sort Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/CVS/Entries|cut -d/ -f2,3,5))" = "gårdetsågårdet.png/1.1/-kb gårdetsågårdet.txt/1.1/"
+      check_entries \
+      "Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö" \
+      "gårdetsågårdet.png/1.1/-kb|gårdetsågårdet.txt/1.1/"
       )'
 
+fi
+
+rm -fr tst
+
 test_expect_success \
      'Mismatching patch should fail' \
      'date >>"E/newfile5.txt" &&
@@ -197,6 +225,10 @@ test_expect_success \
       ! git-cvsexportcommit -c $id
       )'
 
+case "$(git repo-config --bool core.filemode)" in
+false)
+       ;;
+*)
 test_expect_success \
      'Retain execute bit' \
      'mkdir G &&
@@ -211,5 +243,7 @@ test_expect_success \
       test -x G/on &&
       ! test -x G/off
       )'
+       ;;
+esac
 
 test_done