@matheusbsbs / matheus-bagliano / commits / 7f71a6ae18
Fork 0

t1011 (sparse checkout): style nitpicks

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>

Jonathan Nieder committed Jul 31, 2010 at 13:14 UTC 7f71a6ae184d4aad78b37b9eeda4d7a6e5a01d99
1 file changed +55 -47
t/t1011-read-tree-sparse-checkout.sh
+55 -47
@@ -1,16 +1,30 @@
1 #!/bin/sh
2
3 -test_description='sparse checkout tests'
3 +test_description='sparse checkout tests
4 +
5 +* (tag: removed, master) removed
6 +| D sub/added
7 +* (HEAD, tag: top) modified and added
8 +| M init.t
9 +| A sub/added
10 +* (tag: init) init
11 + A init.t
12 +'
13
14 . ./test-lib.sh
15
7 -cat >expected <<EOF
8 -100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t
9 -100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added
10 -EOF
16 test_expect_success 'setup' '
17 + cat >expected <<-\EOF &&
18 + 100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t
19 + 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added
20 + EOF
21 + cat >expected.swt <<-\EOF &&
22 + H init.t
23 + H sub/added
24 + EOF
25 +
26 test_commit init &&
13 - echo modified >> init.t &&
27 + echo modified >>init.t &&
28 mkdir sub &&
29 touch sub/added &&
30 git add init.t sub/added &&
@@ -20,26 +34,22 @@ test_expect_success 'setup' '
34 git commit -m removed &&
35 git tag removed &&
36 git checkout top &&
23 - git ls-files --stage > result &&
37 + git ls-files --stage >result &&
38 test_cmp expected result
39 '
40
27 -cat >expected.swt <<EOF
28 -H init.t
29 -H sub/added
30 -EOF
41 test_expect_success 'read-tree without .git/info/sparse-checkout' '
42 git read-tree -m -u HEAD &&
33 - git ls-files --stage > result &&
43 + git ls-files --stage >result &&
44 test_cmp expected result &&
35 - git ls-files -t > result &&
45 + git ls-files -t >result &&
46 test_cmp expected.swt result
47 '
48
49 test_expect_success 'read-tree with .git/info/sparse-checkout but disabled' '
40 - echo > .git/info/sparse-checkout
50 + echo >.git/info/sparse-checkout
51 git read-tree -m -u HEAD &&
42 - git ls-files -t > result &&
52 + git ls-files -t >result &&
53 test_cmp expected.swt result &&
54 test -f init.t &&
55 test -f sub/added
@@ -47,9 +57,9 @@ test_expect_success 'read-tree with .git/info/sparse-checkout but disabled' '
57
58 test_expect_success 'read-tree --no-sparse-checkout with empty .git/info/sparse-checkout and enabled' '
59 git config core.sparsecheckout true &&
50 - echo > .git/info/sparse-checkout &&
60 + echo >.git/info/sparse-checkout &&
61 git read-tree --no-sparse-checkout -m -u HEAD &&
52 - git ls-files -t > result &&
62 + git ls-files -t >result &&
63 test_cmp expected.swt result &&
64 test -f init.t &&
65 test -f sub/added
@@ -57,92 +67,90 @@ test_expect_success 'read-tree --no-sparse-checkout with empty .git/info/sparse-
67
68 test_expect_success 'read-tree with empty .git/info/sparse-checkout' '
69 git config core.sparsecheckout true &&
60 - echo > .git/info/sparse-checkout &&
70 + echo >.git/info/sparse-checkout &&
71 test_must_fail git read-tree -m -u HEAD &&
62 - git ls-files --stage > result &&
72 + git ls-files --stage >result &&
73 test_cmp expected result &&
64 - git ls-files -t > result &&
74 + git ls-files -t >result &&
75 test_cmp expected.swt result &&
76 test -f init.t &&
77 test -f sub/added
78 '
79
70 -cat >expected.swt <<EOF
71 -S init.t
72 -H sub/added
73 -EOF
80 test_expect_success 'match directories with trailing slash' '
81 + cat >expected.swt-noinit <<-\EOF &&
82 + S init.t
83 + H sub/added
84 + EOF
85 +
86 echo sub/ > .git/info/sparse-checkout &&
87 git read-tree -m -u HEAD &&
88 git ls-files -t > result &&
78 - test_cmp expected.swt result &&
89 + test_cmp expected.swt-noinit result &&
90 test ! -f init.t &&
91 test -f sub/added
92 '
93
83 -cat >expected.swt <<EOF
84 -H init.t
85 -H sub/added
86 -EOF
94 test_expect_failure 'match directories without trailing slash' '
88 - echo init.t > .git/info/sparse-checkout &&
89 - echo sub >> .git/info/sparse-checkout &&
95 + echo init.t >.git/info/sparse-checkout &&
96 + echo sub >>.git/info/sparse-checkout &&
97 git read-tree -m -u HEAD &&
91 - git ls-files -t > result &&
98 + git ls-files -t >result &&
99 test_cmp expected.swt result &&
100 test ! -f init.t &&
101 test -f sub/added
102 '
103
97 -cat >expected.swt <<EOF
98 -H init.t
99 -S sub/added
100 -EOF
104 test_expect_success 'checkout area changes' '
102 - echo init.t > .git/info/sparse-checkout &&
105 + cat >expected.swt-nosub <<-\EOF &&
106 + H init.t
107 + S sub/added
108 + EOF
109 +
110 + echo init.t >.git/info/sparse-checkout &&
111 git read-tree -m -u HEAD &&
104 - git ls-files -t > result &&
105 - test_cmp expected.swt result &&
112 + git ls-files -t >result &&
113 + test_cmp expected.swt-nosub result &&
114 test -f init.t &&
115 test ! -f sub/added
116 '
117
118 test_expect_success 'read-tree updates worktree, absent case' '
111 - echo sub/added > .git/info/sparse-checkout &&
119 + echo sub/added >.git/info/sparse-checkout &&
120 git checkout -f top &&
121 git read-tree -m -u HEAD^ &&
122 test ! -f init.t
123 '
124
125 test_expect_success 'read-tree updates worktree, dirty case' '
118 - echo sub/added > .git/info/sparse-checkout &&
126 + echo sub/added >.git/info/sparse-checkout &&
127 git checkout -f top &&
120 - echo dirty > init.t &&
128 + echo dirty >init.t &&
129 git read-tree -m -u HEAD^ &&
130 grep -q dirty init.t &&
131 rm init.t
132 '
133
134 test_expect_success 'read-tree removes worktree, dirty case' '
127 - echo init.t > .git/info/sparse-checkout &&
135 + echo init.t >.git/info/sparse-checkout &&
136 git checkout -f top &&
129 - echo dirty > added &&
137 + echo dirty >added &&
138 git read-tree -m -u HEAD^ &&
139 grep -q dirty added
140 '
141
142 test_expect_success 'read-tree adds to worktree, absent case' '
135 - echo init.t > .git/info/sparse-checkout &&
143 + echo init.t >.git/info/sparse-checkout &&
144 git checkout -f removed &&
145 git read-tree -u -m HEAD^ &&
146 test ! -f sub/added
147 '
148
149 test_expect_success 'read-tree adds to worktree, dirty case' '
142 - echo init.t > .git/info/sparse-checkout &&
150 + echo init.t >.git/info/sparse-checkout &&
151 git checkout -f removed &&
152 mkdir sub &&
145 - echo dirty > sub/added &&
153 + echo dirty >sub/added &&
154 git read-tree -u -m HEAD^ &&
155 grep -q dirty sub/added
156 '