git/t/t1020-subdirectory.sh
Johannes Sixt 704a3143d5 Use prerequisite tags to skip tests that depend on symbolic links
Many tests depend on that symbolic links work.  This introduces a check
that sets the prerequisite tag SYMLINKS if the file system supports
symbolic links.  Since so many tests have to check for this prerequisite,
we do the check in test-lib.sh, so that we don't need to repeat the test
in many scripts.

To check for 'ln -s' failures, you can use a FAT partition on Linux:

$ mkdosfs -C git-on-fat 1000000
$ sudo mount -o loop,uid=j6t,gid=users,shortname=winnt git-on-fat /mnt

Clone git to /mnt and

$ GIT_SKIP_TESTS='t0001.1[34] t0010 t1301 t403[34] t4129.[47] t5701.7
          t7701.3 t9100 t9101.26 t9119 t9124.[67] t9200.10 t9600.6' \
        make test

(These additionally skipped tests depend on POSIX permissions that FAT on
Linux does not provide.)

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
2009-03-22 17:26:44 +01:00

139 lines
2.9 KiB
Bash
Executable file

#!/bin/sh
#
# Copyright (c) 2006 Junio C Hamano
#
test_description='Try various core-level commands in subdirectory.
'
. ./test-lib.sh
test_expect_success setup '
long="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" &&
for c in $long; do echo $c; done >one &&
mkdir dir &&
for c in x y z $long a b c; do echo $c; done >dir/two &&
cp one original.one &&
cp dir/two original.two
'
HERE=`pwd`
LF='
'
test_expect_success 'update-index and ls-files' '
cd "$HERE" &&
git update-index --add one &&
case "`git ls-files`" in
one) echo ok one ;;
*) echo bad one; exit 1 ;;
esac &&
cd dir &&
git update-index --add two &&
case "`git ls-files`" in
two) echo ok two ;;
*) echo bad two; exit 1 ;;
esac &&
cd .. &&
case "`git ls-files`" in
dir/two"$LF"one) echo ok both ;;
*) echo bad; exit 1 ;;
esac
'
test_expect_success 'cat-file' '
cd "$HERE" &&
two=`git ls-files -s dir/two` &&
two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
echo "$two" &&
git cat-file -p "$two" >actual &&
cmp dir/two actual &&
cd dir &&
git cat-file -p "$two" >actual &&
cmp two actual
'
rm -f actual dir/actual
test_expect_success 'diff-files' '
cd "$HERE" &&
echo a >>one &&
echo d >>dir/two &&
case "`git diff-files --name-only`" in
dir/two"$LF"one) echo ok top ;;
*) echo bad top; exit 1 ;;
esac &&
# diff should not omit leading paths
cd dir &&
case "`git diff-files --name-only`" in
dir/two"$LF"one) echo ok subdir ;;
*) echo bad subdir; exit 1 ;;
esac &&
case "`git diff-files --name-only .`" in
dir/two) echo ok subdir limited ;;
*) echo bad subdir limited; exit 1 ;;
esac
'
test_expect_success 'write-tree' '
cd "$HERE" &&
top=`git write-tree` &&
echo $top &&
cd dir &&
sub=`git write-tree` &&
echo $sub &&
test "z$top" = "z$sub"
'
test_expect_success 'checkout-index' '
cd "$HERE" &&
git checkout-index -f -u one &&
cmp one original.one &&
cd dir &&
git checkout-index -f -u two &&
cmp two ../original.two
'
test_expect_success 'read-tree' '
cd "$HERE" &&
rm -f one dir/two &&
tree=`git write-tree` &&
git read-tree --reset -u "$tree" &&
cmp one original.one &&
cmp dir/two original.two &&
cd dir &&
rm -f two &&
git read-tree --reset -u "$tree" &&
cmp two ../original.two &&
cmp ../one ../original.one
'
test_expect_success 'no file/rev ambiguity check inside .git' '
cd "$HERE" &&
git commit -a -m 1 &&
cd "$HERE"/.git &&
git show -s HEAD
'
test_expect_success 'no file/rev ambiguity check inside a bare repo' '
cd "$HERE" &&
git clone -s --bare .git foo.git &&
cd foo.git && GIT_DIR=. git show -s HEAD
'
# This still does not work as it should...
: test_expect_success 'no file/rev ambiguity check inside a bare repo' '
cd "$HERE" &&
git clone -s --bare .git foo.git &&
cd foo.git && git show -s HEAD
'
test_expect_success SYMLINKS 'detection should not be fooled by a symlink' '
cd "$HERE" &&
rm -fr foo.git &&
git clone -s .git another &&
ln -s another yetanother &&
cd yetanother/.git &&
git show -s HEAD
'
test_done