2009-08-20 15:47:12 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-07-31 08:14:25 +02:00
|
|
|
test_description='sparse checkout tests
|
|
|
|
|
|
|
|
* (tag: removed, master) removed
|
|
|
|
| D sub/added
|
|
|
|
* (HEAD, tag: top) modified and added
|
|
|
|
| M init.t
|
|
|
|
| A sub/added
|
|
|
|
* (tag: init) init
|
|
|
|
A init.t
|
|
|
|
'
|
2009-08-20 15:47:12 +02:00
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success 'setup' '
|
2010-07-31 08:14:25 +02:00
|
|
|
cat >expected <<-\EOF &&
|
|
|
|
100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t
|
|
|
|
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added
|
|
|
|
EOF
|
|
|
|
cat >expected.swt <<-\EOF &&
|
|
|
|
H init.t
|
|
|
|
H sub/added
|
|
|
|
EOF
|
|
|
|
|
2009-08-20 15:47:12 +02:00
|
|
|
test_commit init &&
|
2010-07-31 08:14:25 +02:00
|
|
|
echo modified >>init.t &&
|
2009-08-20 15:47:12 +02:00
|
|
|
mkdir sub &&
|
|
|
|
touch sub/added &&
|
|
|
|
git add init.t sub/added &&
|
|
|
|
git commit -m "modified and added" &&
|
|
|
|
git tag top &&
|
|
|
|
git rm sub/added &&
|
|
|
|
git commit -m removed &&
|
|
|
|
git tag removed &&
|
|
|
|
git checkout top &&
|
2010-07-31 08:14:25 +02:00
|
|
|
git ls-files --stage >result &&
|
2009-08-20 15:47:12 +02:00
|
|
|
test_cmp expected result
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'read-tree without .git/info/sparse-checkout' '
|
|
|
|
git read-tree -m -u HEAD &&
|
2010-07-31 08:14:25 +02:00
|
|
|
git ls-files --stage >result &&
|
2009-08-20 15:47:12 +02:00
|
|
|
test_cmp expected result &&
|
2010-07-31 08:14:25 +02:00
|
|
|
git ls-files -t >result &&
|
2009-08-20 15:47:12 +02:00
|
|
|
test_cmp expected.swt result
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'read-tree with .git/info/sparse-checkout but disabled' '
|
2010-07-31 08:14:25 +02:00
|
|
|
echo >.git/info/sparse-checkout
|
2009-08-20 15:47:12 +02:00
|
|
|
git read-tree -m -u HEAD &&
|
2010-07-31 08:14:25 +02:00
|
|
|
git ls-files -t >result &&
|
2009-08-20 15:47:12 +02:00
|
|
|
test_cmp expected.swt result &&
|
|
|
|
test -f init.t &&
|
|
|
|
test -f sub/added
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'read-tree --no-sparse-checkout with empty .git/info/sparse-checkout and enabled' '
|
|
|
|
git config core.sparsecheckout true &&
|
2010-07-31 08:14:25 +02:00
|
|
|
echo >.git/info/sparse-checkout &&
|
2009-08-20 15:47:12 +02:00
|
|
|
git read-tree --no-sparse-checkout -m -u HEAD &&
|
2010-07-31 08:14:25 +02:00
|
|
|
git ls-files -t >result &&
|
2009-08-20 15:47:12 +02:00
|
|
|
test_cmp expected.swt result &&
|
|
|
|
test -f init.t &&
|
|
|
|
test -f sub/added
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'read-tree with empty .git/info/sparse-checkout' '
|
|
|
|
git config core.sparsecheckout true &&
|
2010-07-31 08:14:25 +02:00
|
|
|
echo >.git/info/sparse-checkout &&
|
2009-08-20 15:47:13 +02:00
|
|
|
test_must_fail git read-tree -m -u HEAD &&
|
2010-07-31 08:14:25 +02:00
|
|
|
git ls-files --stage >result &&
|
2009-08-20 15:47:12 +02:00
|
|
|
test_cmp expected result &&
|
2010-07-31 08:14:25 +02:00
|
|
|
git ls-files -t >result &&
|
2009-08-20 15:47:12 +02:00
|
|
|
test_cmp expected.swt result &&
|
2009-08-20 15:47:13 +02:00
|
|
|
test -f init.t &&
|
|
|
|
test -f sub/added
|
2009-08-20 15:47:12 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'match directories with trailing slash' '
|
2010-07-31 08:14:25 +02:00
|
|
|
cat >expected.swt-noinit <<-\EOF &&
|
|
|
|
S init.t
|
|
|
|
H sub/added
|
|
|
|
EOF
|
|
|
|
|
2009-08-20 15:47:12 +02:00
|
|
|
echo sub/ > .git/info/sparse-checkout &&
|
|
|
|
git read-tree -m -u HEAD &&
|
|
|
|
git ls-files -t > result &&
|
2010-07-31 08:14:25 +02:00
|
|
|
test_cmp expected.swt-noinit result &&
|
2009-08-20 15:47:12 +02:00
|
|
|
test ! -f init.t &&
|
|
|
|
test -f sub/added
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_failure 'match directories without trailing slash' '
|
2010-07-31 08:14:25 +02:00
|
|
|
echo init.t >.git/info/sparse-checkout &&
|
|
|
|
echo sub >>.git/info/sparse-checkout &&
|
2009-08-20 15:47:12 +02:00
|
|
|
git read-tree -m -u HEAD &&
|
2010-07-31 08:14:25 +02:00
|
|
|
git ls-files -t >result &&
|
2009-08-20 15:47:12 +02:00
|
|
|
test_cmp expected.swt result &&
|
|
|
|
test ! -f init.t &&
|
|
|
|
test -f sub/added
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'checkout area changes' '
|
2010-07-31 08:14:25 +02:00
|
|
|
cat >expected.swt-nosub <<-\EOF &&
|
|
|
|
H init.t
|
|
|
|
S sub/added
|
|
|
|
EOF
|
|
|
|
|
|
|
|
echo init.t >.git/info/sparse-checkout &&
|
2009-08-20 15:47:12 +02:00
|
|
|
git read-tree -m -u HEAD &&
|
2010-07-31 08:14:25 +02:00
|
|
|
git ls-files -t >result &&
|
|
|
|
test_cmp expected.swt-nosub result &&
|
2009-08-20 15:47:12 +02:00
|
|
|
test -f init.t &&
|
|
|
|
test ! -f sub/added
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'read-tree updates worktree, absent case' '
|
2010-07-31 08:14:25 +02:00
|
|
|
echo sub/added >.git/info/sparse-checkout &&
|
2009-08-20 15:47:12 +02:00
|
|
|
git checkout -f top &&
|
|
|
|
git read-tree -m -u HEAD^ &&
|
|
|
|
test ! -f init.t
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'read-tree updates worktree, dirty case' '
|
2010-07-31 08:14:25 +02:00
|
|
|
echo sub/added >.git/info/sparse-checkout &&
|
2009-08-20 15:47:12 +02:00
|
|
|
git checkout -f top &&
|
2010-07-31 08:14:25 +02:00
|
|
|
echo dirty >init.t &&
|
2009-08-20 15:47:12 +02:00
|
|
|
git read-tree -m -u HEAD^ &&
|
|
|
|
grep -q dirty init.t &&
|
|
|
|
rm init.t
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'read-tree removes worktree, dirty case' '
|
2010-07-31 08:14:25 +02:00
|
|
|
echo init.t >.git/info/sparse-checkout &&
|
2009-08-20 15:47:12 +02:00
|
|
|
git checkout -f top &&
|
2010-07-31 08:14:25 +02:00
|
|
|
echo dirty >added &&
|
2009-08-20 15:47:12 +02:00
|
|
|
git read-tree -m -u HEAD^ &&
|
|
|
|
grep -q dirty added
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'read-tree adds to worktree, absent case' '
|
2010-07-31 08:14:25 +02:00
|
|
|
echo init.t >.git/info/sparse-checkout &&
|
2009-08-20 15:47:12 +02:00
|
|
|
git checkout -f removed &&
|
|
|
|
git read-tree -u -m HEAD^ &&
|
|
|
|
test ! -f sub/added
|
|
|
|
'
|
|
|
|
|
2010-07-31 08:14:29 +02:00
|
|
|
test_expect_success 'read-tree adds to worktree, dirty case' '
|
2010-07-31 08:14:25 +02:00
|
|
|
echo init.t >.git/info/sparse-checkout &&
|
2009-08-20 15:47:12 +02:00
|
|
|
git checkout -f removed &&
|
|
|
|
mkdir sub &&
|
2010-07-31 08:14:25 +02:00
|
|
|
echo dirty >sub/added &&
|
2009-08-20 15:47:12 +02:00
|
|
|
git read-tree -u -m HEAD^ &&
|
|
|
|
grep -q dirty sub/added
|
|
|
|
'
|
|
|
|
|
2010-07-31 08:14:26 +02:00
|
|
|
test_expect_success 'index removal and worktree narrowing at the same time' '
|
|
|
|
>empty &&
|
|
|
|
echo init.t >.git/info/sparse-checkout &&
|
|
|
|
echo sub/added >>.git/info/sparse-checkout &&
|
|
|
|
git checkout -f top &&
|
|
|
|
echo init.t >.git/info/sparse-checkout &&
|
|
|
|
git checkout removed &&
|
|
|
|
git ls-files sub/added >result &&
|
|
|
|
test ! -f sub/added &&
|
|
|
|
test_cmp empty result
|
|
|
|
'
|
|
|
|
|
2010-07-31 08:14:27 +02:00
|
|
|
test_expect_success 'read-tree --reset removes outside worktree' '
|
|
|
|
>empty &&
|
|
|
|
echo init.t >.git/info/sparse-checkout &&
|
|
|
|
git checkout -f top &&
|
|
|
|
git reset --hard removed &&
|
|
|
|
git ls-files sub/added >result &&
|
|
|
|
test_cmp empty result
|
|
|
|
'
|
|
|
|
|
2009-08-20 15:47:12 +02:00
|
|
|
test_done
|