2006-08-03 23:41:29 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2006 Junio C Hamano
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='Try various core-level commands in subdirectory.
|
|
|
|
'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
2011-05-25 22:10:41 +02:00
|
|
|
. "$TEST_DIRECTORY"/lib-read-tree.sh
|
2006-08-03 23:41:29 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'update-index and ls-files' '
|
2007-07-03 07:52:14 +02:00
|
|
|
git update-index --add one &&
|
|
|
|
case "`git ls-files`" in
|
2010-06-24 19:44:49 +02:00
|
|
|
one) echo pass one ;;
|
2006-08-03 23:41:29 +02:00
|
|
|
*) echo bad one; exit 1 ;;
|
|
|
|
esac &&
|
2010-09-07 03:42:54 +02:00
|
|
|
(
|
|
|
|
cd dir &&
|
|
|
|
git update-index --add two &&
|
|
|
|
case "`git ls-files`" in
|
|
|
|
two) echo pass two ;;
|
|
|
|
*) echo bad two; exit 1 ;;
|
|
|
|
esac
|
2010-09-06 20:39:54 +02:00
|
|
|
) &&
|
2007-07-03 07:52:14 +02:00
|
|
|
case "`git ls-files`" in
|
2010-06-24 19:44:49 +02:00
|
|
|
dir/two"$LF"one) echo pass both ;;
|
2006-08-03 23:41:29 +02:00
|
|
|
*) echo bad; exit 1 ;;
|
|
|
|
esac
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'cat-file' '
|
2007-07-03 07:52:14 +02:00
|
|
|
two=`git ls-files -s dir/two` &&
|
2006-08-03 23:41:29 +02:00
|
|
|
two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
|
|
|
|
echo "$two" &&
|
2007-07-03 07:52:14 +02:00
|
|
|
git cat-file -p "$two" >actual &&
|
2006-08-03 23:41:29 +02:00
|
|
|
cmp dir/two actual &&
|
2010-09-07 12:29:20 +02:00
|
|
|
(
|
|
|
|
cd dir &&
|
|
|
|
git cat-file -p "$two" >actual &&
|
|
|
|
cmp two actual
|
|
|
|
)
|
2006-08-03 23:41:29 +02:00
|
|
|
'
|
|
|
|
rm -f actual dir/actual
|
|
|
|
|
|
|
|
test_expect_success 'diff-files' '
|
|
|
|
echo a >>one &&
|
|
|
|
echo d >>dir/two &&
|
2007-07-03 07:52:14 +02:00
|
|
|
case "`git diff-files --name-only`" in
|
2010-06-24 19:44:49 +02:00
|
|
|
dir/two"$LF"one) echo pass top ;;
|
2006-08-03 23:41:29 +02:00
|
|
|
*) echo bad top; exit 1 ;;
|
|
|
|
esac &&
|
|
|
|
# diff should not omit leading paths
|
2010-09-07 12:29:20 +02:00
|
|
|
(
|
|
|
|
cd dir &&
|
|
|
|
case "`git diff-files --name-only`" in
|
|
|
|
dir/two"$LF"one) echo pass subdir ;;
|
|
|
|
*) echo bad subdir; exit 1 ;;
|
|
|
|
esac &&
|
|
|
|
case "`git diff-files --name-only .`" in
|
|
|
|
dir/two) echo pass subdir limited ;;
|
|
|
|
*) echo bad subdir limited; exit 1 ;;
|
|
|
|
esac
|
|
|
|
)
|
2006-08-03 23:41:29 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'write-tree' '
|
2007-07-03 07:52:14 +02:00
|
|
|
top=`git write-tree` &&
|
2006-08-03 23:41:29 +02:00
|
|
|
echo $top &&
|
2010-09-07 12:29:20 +02:00
|
|
|
(
|
|
|
|
cd dir &&
|
|
|
|
sub=`git write-tree` &&
|
|
|
|
echo $sub &&
|
|
|
|
test "z$top" = "z$sub"
|
|
|
|
)
|
2006-08-03 23:41:29 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'checkout-index' '
|
2007-07-03 07:52:14 +02:00
|
|
|
git checkout-index -f -u one &&
|
2006-08-03 23:41:29 +02:00
|
|
|
cmp one original.one &&
|
2010-09-07 12:29:20 +02:00
|
|
|
(
|
|
|
|
cd dir &&
|
|
|
|
git checkout-index -f -u two &&
|
|
|
|
cmp two ../original.two
|
|
|
|
)
|
2006-08-03 23:41:29 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'read-tree' '
|
|
|
|
rm -f one dir/two &&
|
2007-07-03 07:52:14 +02:00
|
|
|
tree=`git write-tree` &&
|
2011-05-25 22:10:41 +02:00
|
|
|
read_tree_u_must_succeed --reset -u "$tree" &&
|
2006-08-03 23:41:29 +02:00
|
|
|
cmp one original.one &&
|
|
|
|
cmp dir/two original.two &&
|
2010-09-07 12:29:20 +02:00
|
|
|
(
|
|
|
|
cd dir &&
|
|
|
|
rm -f two &&
|
2011-05-25 22:10:41 +02:00
|
|
|
read_tree_u_must_succeed --reset -u "$tree" &&
|
2010-09-07 12:29:20 +02:00
|
|
|
cmp two ../original.two &&
|
|
|
|
cmp ../one ../original.one
|
|
|
|
)
|
2006-08-03 23:41:29 +02:00
|
|
|
'
|
|
|
|
|
2010-11-26 16:32:37 +01:00
|
|
|
test_expect_success 'alias expansion' '
|
|
|
|
(
|
2012-12-29 00:03:06 +01:00
|
|
|
git config alias.test-status-alias status &&
|
2010-11-26 16:32:37 +01:00
|
|
|
cd dir &&
|
|
|
|
git status &&
|
2012-12-29 00:03:06 +01:00
|
|
|
git test-status-alias
|
2010-11-26 16:32:37 +01:00
|
|
|
)
|
|
|
|
'
|
2011-04-27 10:36:26 +02:00
|
|
|
|
2011-10-15 00:53:28 +02:00
|
|
|
test_expect_success NOT_MINGW '!alias expansion' '
|
2011-04-27 10:36:26 +02:00
|
|
|
pwd >expect &&
|
|
|
|
(
|
2012-12-29 00:03:06 +01:00
|
|
|
git config alias.test-alias-directory !pwd &&
|
2011-04-27 10:36:26 +02:00
|
|
|
cd dir &&
|
2012-12-29 00:03:06 +01:00
|
|
|
git test-alias-directory >../actual
|
2011-04-27 10:36:26 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2011-04-27 10:36:27 +02:00
|
|
|
test_expect_success 'GIT_PREFIX for !alias' '
|
|
|
|
printf "dir/" >expect &&
|
|
|
|
(
|
2012-12-29 00:03:06 +01:00
|
|
|
git config alias.test-alias-directory "!sh -c \"printf \$GIT_PREFIX\"" &&
|
2011-04-27 10:36:27 +02:00
|
|
|
cd dir &&
|
2012-12-29 00:03:06 +01:00
|
|
|
git test-alias-directory >../actual
|
2011-04-27 10:36:27 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2011-05-26 05:37:12 +02:00
|
|
|
test_expect_success 'GIT_PREFIX for built-ins' '
|
|
|
|
# Use GIT_EXTERNAL_DIFF to test that the "diff" built-in
|
|
|
|
# receives the GIT_PREFIX variable.
|
|
|
|
printf "dir/" >expect &&
|
|
|
|
printf "#!/bin/sh\n" >diff &&
|
|
|
|
printf "printf \"\$GIT_PREFIX\"" >>diff &&
|
|
|
|
chmod +x diff &&
|
|
|
|
(
|
|
|
|
cd dir &&
|
|
|
|
printf "change" >two &&
|
|
|
|
env GIT_EXTERNAL_DIFF=./diff git diff >../actual
|
|
|
|
git checkout -- two
|
|
|
|
) &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2007-02-04 05:49:16 +01:00
|
|
|
test_expect_success 'no file/rev ambiguity check inside .git' '
|
2007-01-20 03:09:34 +01:00
|
|
|
git commit -a -m 1 &&
|
2010-09-07 12:29:20 +02:00
|
|
|
(
|
|
|
|
cd .git &&
|
|
|
|
git show -s HEAD
|
|
|
|
)
|
2007-01-20 03:09:34 +01:00
|
|
|
'
|
|
|
|
|
2007-02-04 05:49:16 +01:00
|
|
|
test_expect_success 'no file/rev ambiguity check inside a bare repo' '
|
2007-01-20 03:09:34 +01:00
|
|
|
git clone -s --bare .git foo.git &&
|
2010-09-07 12:29:20 +02:00
|
|
|
(
|
|
|
|
cd foo.git &&
|
|
|
|
GIT_DIR=. git show -s HEAD
|
|
|
|
)
|
2007-01-20 03:09:34 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
# This still does not work as it should...
|
2007-02-04 05:49:16 +01:00
|
|
|
: test_expect_success 'no file/rev ambiguity check inside a bare repo' '
|
2007-01-20 03:09:34 +01:00
|
|
|
git clone -s --bare .git foo.git &&
|
2010-09-07 12:29:20 +02:00
|
|
|
(
|
|
|
|
cd foo.git &&
|
|
|
|
git show -s HEAD
|
|
|
|
)
|
2007-01-20 03:09:34 +01:00
|
|
|
'
|
|
|
|
|
2009-03-04 22:38:24 +01:00
|
|
|
test_expect_success SYMLINKS 'detection should not be fooled by a symlink' '
|
2007-01-20 03:09:34 +01:00
|
|
|
rm -fr foo.git &&
|
|
|
|
git clone -s .git another &&
|
|
|
|
ln -s another yetanother &&
|
2010-09-07 12:29:20 +02:00
|
|
|
(
|
|
|
|
cd yetanother/.git &&
|
|
|
|
git show -s HEAD
|
|
|
|
)
|
2007-01-20 03:09:34 +01:00
|
|
|
'
|
|
|
|
|
2006-08-03 23:41:29 +02:00
|
|
|
test_done
|