t3060-ls-files-with-tree.sh [plain text]
#!/bin/sh
test_description='git ls-files test (--with-tree).
This test runs git ls-files --with-tree and in particular in
a scenario known to trigger a crash with some versions of git.
'
. ./test-lib.sh
test_expect_success setup '
echo file >expected &&
mkdir sub &&
bad= &&
for n in 0 1 2 3 4 5
do
for m in 0 1 2 3 4 5 6 7 8 9
do
num=00$n$m &&
>sub/file-$num &&
echo file-$num >>expected || {
bad=t
break
}
done && test -z "$bad" || {
bad=t
break
}
done && test -z "$bad" &&
git add . &&
git commit -m "add a bunch of files" &&
rm -rf sub &&
git commit -a -m "remove them all" &&
mkdir a_directory_that_sorts_before_sub &&
>a_directory_that_sorts_before_sub/file &&
mkdir sub &&
>sub/file &&
git add .
'
test_expect_success 'git -ls-files --with-tree should succeed from subdir' '
(
cd sub &&
git ls-files --with-tree=HEAD~1 >../output
)
'
test_expect_success \
'git -ls-files --with-tree should add entries from named tree.' \
'test_cmp expected output'
test_done