mirror of
https://github.com/git/git.git
synced 2024-10-30 22:07:53 +01:00
b3ff808b71
* en/and-cascade-tests: (25 commits) t4124 (apply --whitespace): use test_might_fail t3404: do not use 'describe' to implement test_cmp_rev t3404 (rebase -i): introduce helper to check position of HEAD t3404 (rebase -i): move comment to description t3404 (rebase -i): unroll test_commit loops t3301 (notes): use test_expect_code for clarity t1400 (update-ref): use test_must_fail t1502 (rev-parse --parseopt): test exit code from "-h" t6022 (renaming merge): chain test commands with && test-lib: introduce test_line_count to measure files tests: add missing &&, batch 2 tests: add missing && Introduce sane_unset and use it to ensure proper && chaining t7800 (difftool): add missing && t7601 (merge-pull-config): add missing && t7001 (mv): add missing && t6016 (rev-list-graph-simplify-history): add missing && t5602 (clone-remote-exec): add missing && t4026 (color): remove unneeded and unchained command t4019 (diff-wserror): add lots of missing && ... Conflicts: t/t7006-pager.sh
183 lines
4.5 KiB
Bash
Executable file
183 lines
4.5 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
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
|
|
'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'setup' '
|
|
cat >expected <<-\EOF &&
|
|
100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t
|
|
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added
|
|
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 subsub/added
|
|
EOF
|
|
cat >expected.swt <<-\EOF &&
|
|
H init.t
|
|
H sub/added
|
|
H subsub/added
|
|
EOF
|
|
|
|
test_commit init &&
|
|
echo modified >>init.t &&
|
|
mkdir sub subsub &&
|
|
touch sub/added subsub/added &&
|
|
git add init.t sub/added subsub/added &&
|
|
git commit -m "modified and added" &&
|
|
git tag top &&
|
|
git rm sub/added &&
|
|
git commit -m removed &&
|
|
git tag removed &&
|
|
git checkout top &&
|
|
git ls-files --stage >result &&
|
|
test_cmp expected result
|
|
'
|
|
|
|
test_expect_success 'read-tree without .git/info/sparse-checkout' '
|
|
git read-tree -m -u HEAD &&
|
|
git ls-files --stage >result &&
|
|
test_cmp expected result &&
|
|
git ls-files -t >result &&
|
|
test_cmp expected.swt result
|
|
'
|
|
|
|
test_expect_success 'read-tree with .git/info/sparse-checkout but disabled' '
|
|
echo >.git/info/sparse-checkout &&
|
|
git read-tree -m -u HEAD &&
|
|
git ls-files -t >result &&
|
|
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 &&
|
|
echo >.git/info/sparse-checkout &&
|
|
git read-tree --no-sparse-checkout -m -u HEAD &&
|
|
git ls-files -t >result &&
|
|
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 &&
|
|
echo >.git/info/sparse-checkout &&
|
|
test_must_fail git read-tree -m -u HEAD &&
|
|
git ls-files --stage >result &&
|
|
test_cmp expected result &&
|
|
git ls-files -t >result &&
|
|
test_cmp expected.swt result &&
|
|
test -f init.t &&
|
|
test -f sub/added
|
|
'
|
|
|
|
test_expect_success 'match directories with trailing slash' '
|
|
cat >expected.swt-noinit <<-\EOF &&
|
|
S init.t
|
|
H sub/added
|
|
S subsub/added
|
|
EOF
|
|
|
|
echo sub/ > .git/info/sparse-checkout &&
|
|
git read-tree -m -u HEAD &&
|
|
git ls-files -t > result &&
|
|
test_cmp expected.swt-noinit result &&
|
|
test ! -f init.t &&
|
|
test -f sub/added
|
|
'
|
|
|
|
test_expect_failure 'match directories without trailing slash' '
|
|
echo init.t >.git/info/sparse-checkout &&
|
|
echo sub >>.git/info/sparse-checkout &&
|
|
git read-tree -m -u HEAD &&
|
|
git ls-files -t >result &&
|
|
test_cmp expected.swt result &&
|
|
test ! -f init.t &&
|
|
test -f sub/added
|
|
'
|
|
|
|
test_expect_success 'checkout area changes' '
|
|
cat >expected.swt-nosub <<-\EOF &&
|
|
H init.t
|
|
S sub/added
|
|
S subsub/added
|
|
EOF
|
|
|
|
echo init.t >.git/info/sparse-checkout &&
|
|
git read-tree -m -u HEAD &&
|
|
git ls-files -t >result &&
|
|
test_cmp expected.swt-nosub result &&
|
|
test -f init.t &&
|
|
test ! -f sub/added
|
|
'
|
|
|
|
test_expect_success 'read-tree updates worktree, absent case' '
|
|
echo sub/added >.git/info/sparse-checkout &&
|
|
git checkout -f top &&
|
|
git read-tree -m -u HEAD^ &&
|
|
test ! -f init.t
|
|
'
|
|
|
|
test_expect_success 'read-tree updates worktree, dirty case' '
|
|
echo sub/added >.git/info/sparse-checkout &&
|
|
git checkout -f top &&
|
|
echo dirty >init.t &&
|
|
git read-tree -m -u HEAD^ &&
|
|
grep -q dirty init.t &&
|
|
rm init.t
|
|
'
|
|
|
|
test_expect_success 'read-tree removes worktree, dirty case' '
|
|
echo init.t >.git/info/sparse-checkout &&
|
|
git checkout -f top &&
|
|
echo dirty >added &&
|
|
git read-tree -m -u HEAD^ &&
|
|
grep -q dirty added
|
|
'
|
|
|
|
test_expect_success 'read-tree adds to worktree, absent case' '
|
|
echo init.t >.git/info/sparse-checkout &&
|
|
git checkout -f removed &&
|
|
git read-tree -u -m HEAD^ &&
|
|
test ! -f sub/added
|
|
'
|
|
|
|
test_expect_success 'read-tree adds to worktree, dirty case' '
|
|
echo init.t >.git/info/sparse-checkout &&
|
|
git checkout -f removed &&
|
|
mkdir sub &&
|
|
echo dirty >sub/added &&
|
|
git read-tree -u -m HEAD^ &&
|
|
grep -q dirty sub/added
|
|
'
|
|
|
|
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
|
|
'
|
|
|
|
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
|
|
'
|
|
|
|
test_done
|