Skip to content

Commit

Permalink
t1011 (sparse checkout): style nitpicks
Browse files Browse the repository at this point in the history
Tweak the rest of the script to more closely follow the test
style guide.  Guarding setup commands with test_expect_success
makes it easy to see the scope in which some particular data is
used; removal of whitespace after >redirection operators is just
for consistency.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jonathan Nieder authored and Junio C Hamano committed Aug 2, 2010
1 parent e923eae commit 7f71a6a
Showing 1 changed file with 55 additions and 47 deletions.
102 changes: 55 additions & 47 deletions t/t1011-read-tree-sparse-checkout.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
#!/bin/sh

test_description='sparse checkout tests'
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

cat >expected <<EOF
100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added
EOF
test_expect_success 'setup' '
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
test_commit init &&
echo modified >> init.t &&
echo modified >>init.t &&
mkdir sub &&
touch sub/added &&
git add init.t sub/added &&
Expand All @@ -20,129 +34,123 @@ test_expect_success 'setup' '
git commit -m removed &&
git tag removed &&
git checkout top &&
git ls-files --stage > result &&
git ls-files --stage >result &&
test_cmp expected result
'

cat >expected.swt <<EOF
H init.t
H sub/added
EOF
test_expect_success 'read-tree without .git/info/sparse-checkout' '
git read-tree -m -u HEAD &&
git ls-files --stage > result &&
git ls-files --stage >result &&
test_cmp expected result &&
git ls-files -t > 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
echo >.git/info/sparse-checkout
git read-tree -m -u HEAD &&
git ls-files -t > result &&
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 &&
echo >.git/info/sparse-checkout &&
git read-tree --no-sparse-checkout -m -u HEAD &&
git ls-files -t > result &&
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 &&
echo >.git/info/sparse-checkout &&
test_must_fail git read-tree -m -u HEAD &&
git ls-files --stage > result &&
git ls-files --stage >result &&
test_cmp expected result &&
git ls-files -t > result &&
git ls-files -t >result &&
test_cmp expected.swt result &&
test -f init.t &&
test -f sub/added
'

cat >expected.swt <<EOF
S init.t
H sub/added
EOF
test_expect_success 'match directories with trailing slash' '
cat >expected.swt-noinit <<-\EOF &&
S init.t
H sub/added
EOF
echo sub/ > .git/info/sparse-checkout &&
git read-tree -m -u HEAD &&
git ls-files -t > result &&
test_cmp expected.swt result &&
test_cmp expected.swt-noinit result &&
test ! -f init.t &&
test -f sub/added
'

cat >expected.swt <<EOF
H init.t
H sub/added
EOF
test_expect_failure 'match directories without trailing slash' '
echo init.t > .git/info/sparse-checkout &&
echo sub >> .git/info/sparse-checkout &&
echo init.t >.git/info/sparse-checkout &&
echo sub >>.git/info/sparse-checkout &&
git read-tree -m -u HEAD &&
git ls-files -t > result &&
git ls-files -t >result &&
test_cmp expected.swt result &&
test ! -f init.t &&
test -f sub/added
'

cat >expected.swt <<EOF
H init.t
S sub/added
EOF
test_expect_success 'checkout area changes' '
echo init.t > .git/info/sparse-checkout &&
cat >expected.swt-nosub <<-\EOF &&
H init.t
S sub/added
EOF
echo init.t >.git/info/sparse-checkout &&
git read-tree -m -u HEAD &&
git ls-files -t > result &&
test_cmp expected.swt result &&
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 &&
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 &&
echo sub/added >.git/info/sparse-checkout &&
git checkout -f top &&
echo dirty > init.t &&
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 &&
echo init.t >.git/info/sparse-checkout &&
git checkout -f top &&
echo dirty > added &&
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 &&
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 &&
echo init.t >.git/info/sparse-checkout &&
git checkout -f removed &&
mkdir sub &&
echo dirty > sub/added &&
echo dirty >sub/added &&
git read-tree -u -m HEAD^ &&
grep -q dirty sub/added
'
Expand Down

0 comments on commit 7f71a6a

Please sign in to comment.