2006-08-04 01:41:29 +04:00
|
|
|
#!/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 &&
|
2007-07-03 09:52:14 +04:00
|
|
|
git update-index --add one &&
|
|
|
|
case "`git ls-files`" in
|
2006-08-04 01:41:29 +04:00
|
|
|
one) echo ok one ;;
|
|
|
|
*) echo bad one; exit 1 ;;
|
|
|
|
esac &&
|
|
|
|
cd dir &&
|
2007-07-03 09:52:14 +04:00
|
|
|
git update-index --add two &&
|
|
|
|
case "`git ls-files`" in
|
2006-08-04 01:41:29 +04:00
|
|
|
two) echo ok two ;;
|
|
|
|
*) echo bad two; exit 1 ;;
|
|
|
|
esac &&
|
|
|
|
cd .. &&
|
2007-07-03 09:52:14 +04:00
|
|
|
case "`git ls-files`" in
|
2006-08-04 01:41:29 +04:00
|
|
|
dir/two"$LF"one) echo ok both ;;
|
|
|
|
*) echo bad; exit 1 ;;
|
|
|
|
esac
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'cat-file' '
|
|
|
|
cd $HERE &&
|
2007-07-03 09:52:14 +04:00
|
|
|
two=`git ls-files -s dir/two` &&
|
2006-08-04 01:41:29 +04:00
|
|
|
two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
|
|
|
|
echo "$two" &&
|
2007-07-03 09:52:14 +04:00
|
|
|
git cat-file -p "$two" >actual &&
|
2006-08-04 01:41:29 +04:00
|
|
|
cmp dir/two actual &&
|
|
|
|
cd dir &&
|
2007-07-03 09:52:14 +04:00
|
|
|
git cat-file -p "$two" >actual &&
|
2006-08-04 01:41:29 +04:00
|
|
|
cmp two actual
|
|
|
|
'
|
|
|
|
rm -f actual dir/actual
|
|
|
|
|
|
|
|
test_expect_success 'diff-files' '
|
|
|
|
cd $HERE &&
|
|
|
|
echo a >>one &&
|
|
|
|
echo d >>dir/two &&
|
2007-07-03 09:52:14 +04:00
|
|
|
case "`git diff-files --name-only`" in
|
2006-08-04 01:41:29 +04:00
|
|
|
dir/two"$LF"one) echo ok top ;;
|
|
|
|
*) echo bad top; exit 1 ;;
|
|
|
|
esac &&
|
|
|
|
# diff should not omit leading paths
|
|
|
|
cd dir &&
|
2007-07-03 09:52:14 +04:00
|
|
|
case "`git diff-files --name-only`" in
|
2006-08-04 01:41:29 +04:00
|
|
|
dir/two"$LF"one) echo ok subdir ;;
|
|
|
|
*) echo bad subdir; exit 1 ;;
|
|
|
|
esac &&
|
2007-07-03 09:52:14 +04:00
|
|
|
case "`git diff-files --name-only .`" in
|
2006-08-04 01:41:29 +04:00
|
|
|
dir/two) echo ok subdir limited ;;
|
|
|
|
*) echo bad subdir limited; exit 1 ;;
|
|
|
|
esac
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'write-tree' '
|
|
|
|
cd $HERE &&
|
2007-07-03 09:52:14 +04:00
|
|
|
top=`git write-tree` &&
|
2006-08-04 01:41:29 +04:00
|
|
|
echo $top &&
|
|
|
|
cd dir &&
|
2007-07-03 09:52:14 +04:00
|
|
|
sub=`git write-tree` &&
|
2006-08-04 01:41:29 +04:00
|
|
|
echo $sub &&
|
|
|
|
test "z$top" = "z$sub"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'checkout-index' '
|
|
|
|
cd $HERE &&
|
2007-07-03 09:52:14 +04:00
|
|
|
git checkout-index -f -u one &&
|
2006-08-04 01:41:29 +04:00
|
|
|
cmp one original.one &&
|
|
|
|
cd dir &&
|
2007-07-03 09:52:14 +04:00
|
|
|
git checkout-index -f -u two &&
|
2006-08-04 01:41:29 +04:00
|
|
|
cmp two ../original.two
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'read-tree' '
|
|
|
|
cd $HERE &&
|
|
|
|
rm -f one dir/two &&
|
2007-07-03 09:52:14 +04:00
|
|
|
tree=`git write-tree` &&
|
|
|
|
git read-tree --reset -u "$tree" &&
|
2006-08-04 01:41:29 +04:00
|
|
|
cmp one original.one &&
|
|
|
|
cmp dir/two original.two &&
|
|
|
|
cd dir &&
|
|
|
|
rm -f two &&
|
2007-07-03 09:52:14 +04:00
|
|
|
git read-tree --reset -u "$tree" &&
|
2006-08-04 01:41:29 +04:00
|
|
|
cmp two ../original.two &&
|
|
|
|
cmp ../one ../original.one
|
|
|
|
'
|
|
|
|
|
2007-02-04 07:49:16 +03:00
|
|
|
test_expect_success 'no file/rev ambiguity check inside .git' '
|
2007-01-20 05:09:34 +03:00
|
|
|
cd $HERE &&
|
|
|
|
git commit -a -m 1 &&
|
|
|
|
cd $HERE/.git &&
|
|
|
|
git show -s HEAD
|
|
|
|
'
|
|
|
|
|
2007-02-04 07:49:16 +03:00
|
|
|
test_expect_success 'no file/rev ambiguity check inside a bare repo' '
|
2007-01-20 05:09:34 +03:00
|
|
|
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...
|
2007-02-04 07:49:16 +03:00
|
|
|
: test_expect_success 'no file/rev ambiguity check inside a bare repo' '
|
2007-01-20 05:09:34 +03:00
|
|
|
cd $HERE &&
|
|
|
|
git clone -s --bare .git foo.git &&
|
|
|
|
cd foo.git && git show -s HEAD
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '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
|
|
|
|
'
|
|
|
|
|
2006-08-04 01:41:29 +04:00
|
|
|
test_done
|