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