Skip to content

Commit 378932d

Browse files
pcloudsgitster
authored andcommitted
test-lib.sh: introduce and use $EMPTY_BLOB
Similar to $EMPTY_TREE this makes it easier to recognize this special SHA-1 and change hash later. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f9e7d9f commit 378932d

8 files changed

+35
-38
lines changed

t/t1011-read-tree-sparse-checkout.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ test_description='sparse checkout tests
1515
. "$TEST_DIRECTORY"/lib-read-tree.sh
1616

1717
test_expect_success 'setup' '
18-
cat >expected <<-\EOF &&
18+
cat >expected <<-EOF &&
1919
100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t
20-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added
21-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/addedtoo
22-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 subsub/added
20+
100644 $EMPTY_BLOB 0 sub/added
21+
100644 $EMPTY_BLOB 0 sub/addedtoo
22+
100644 $EMPTY_BLOB 0 subsub/added
2323
EOF
2424
cat >expected.swt <<-\EOF &&
2525
H init.t

t/t1700-split-index.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ test_expect_success 'add one file' '
3333
git update-index --add one &&
3434
git ls-files --stage >ls-files.actual &&
3535
cat >ls-files.expect <<EOF &&
36-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
36+
100644 $EMPTY_BLOB 0 one
3737
EOF
3838
test_cmp ls-files.expect ls-files.actual &&
3939
4040
test-dump-split-index .git/index | sed "/^own/d" >actual &&
4141
cat >expect <<EOF &&
4242
base $base
43-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
43+
100644 $EMPTY_BLOB 0 one
4444
replacements:
4545
deletions:
4646
EOF
@@ -51,7 +51,7 @@ test_expect_success 'disable split index' '
5151
git update-index --no-split-index &&
5252
git ls-files --stage >ls-files.actual &&
5353
cat >ls-files.expect <<EOF &&
54-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
54+
100644 $EMPTY_BLOB 0 one
5555
EOF
5656
test_cmp ls-files.expect ls-files.actual &&
5757
@@ -67,7 +67,7 @@ test_expect_success 'enable split index again, "one" now belongs to base index"'
6767
git update-index --split-index &&
6868
git ls-files --stage >ls-files.actual &&
6969
cat >ls-files.expect <<EOF &&
70-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
70+
100644 $EMPTY_BLOB 0 one
7171
EOF
7272
test_cmp ls-files.expect ls-files.actual &&
7373
@@ -105,15 +105,15 @@ test_expect_success 'add another file, which stays index' '
105105
git ls-files --stage >ls-files.actual &&
106106
cat >ls-files.expect <<EOF &&
107107
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
108-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
108+
100644 $EMPTY_BLOB 0 two
109109
EOF
110110
test_cmp ls-files.expect ls-files.actual &&
111111
112112
test-dump-split-index .git/index | sed "/^own/d" >actual &&
113113
q_to_tab >expect <<EOF &&
114114
$BASE
115115
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
116-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
116+
100644 $EMPTY_BLOB 0 two
117117
replacements: 0
118118
deletions:
119119
EOF
@@ -159,14 +159,14 @@ test_expect_success 'add original file back' '
159159
git update-index --add one &&
160160
git ls-files --stage >ls-files.actual &&
161161
cat >ls-files.expect <<EOF &&
162-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
162+
100644 $EMPTY_BLOB 0 one
163163
EOF
164164
test_cmp ls-files.expect ls-files.actual &&
165165
166166
test-dump-split-index .git/index | sed "/^own/d" >actual &&
167167
cat >expect <<EOF &&
168168
$BASE
169-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
169+
100644 $EMPTY_BLOB 0 one
170170
replacements:
171171
deletions: 0
172172
EOF
@@ -178,8 +178,8 @@ test_expect_success 'add new file' '
178178
git update-index --add two &&
179179
git ls-files --stage >actual &&
180180
cat >expect <<EOF &&
181-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
182-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
181+
100644 $EMPTY_BLOB 0 one
182+
100644 $EMPTY_BLOB 0 two
183183
EOF
184184
test_cmp expect actual
185185
'
@@ -188,8 +188,8 @@ test_expect_success 'unify index, two files remain' '
188188
git update-index --no-split-index &&
189189
git ls-files --stage >ls-files.actual &&
190190
cat >ls-files.expect <<EOF &&
191-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
192-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
191+
100644 $EMPTY_BLOB 0 one
192+
100644 $EMPTY_BLOB 0 two
193193
EOF
194194
test_cmp ls-files.expect ls-files.actual &&
195195

t/t3102-ls-tree-wildcards.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ test_expect_success 'setup' '
1212
'
1313

1414
test_expect_success 'ls-tree a[a] matches literally' '
15-
cat >expect <<-\EOF &&
16-
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 a[a]/three
15+
cat >expect <<-EOF &&
16+
100644 blob $EMPTY_BLOB a[a]/three
1717
EOF
1818
git ls-tree -r HEAD "a[a]" >actual &&
1919
test_cmp expect actual
2020
'
2121

2222
test_expect_success 'ls-tree outside prefix' '
23-
cat >expect <<-\EOF &&
24-
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 ../a[a]/three
23+
cat >expect <<-EOF &&
24+
100644 blob $EMPTY_BLOB ../a[a]/three
2525
EOF
2626
( cd aa && git ls-tree -r HEAD "../a[a]"; ) >actual &&
2727
test_cmp expect actual

t/t7011-skip-worktree-reading.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,15 @@ S sub/1
2323
H sub/2
2424
EOF
2525

26-
NULL_SHA1=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
27-
2826
setup_absent() {
2927
test -f 1 && rm 1
3028
git update-index --remove 1 &&
31-
git update-index --add --cacheinfo 100644 $NULL_SHA1 1 &&
29+
git update-index --add --cacheinfo 100644 $EMPTY_BLOB 1 &&
3230
git update-index --skip-worktree 1
3331
}
3432

3533
test_absent() {
36-
echo "100644 $NULL_SHA1 0 1" > expected &&
34+
echo "100644 $EMPTY_BLOB 0 1" > expected &&
3735
git ls-files --stage 1 > result &&
3836
test_cmp expected result &&
3937
test ! -f 1
@@ -42,12 +40,12 @@ test_absent() {
4240
setup_dirty() {
4341
git update-index --force-remove 1 &&
4442
echo dirty > 1 &&
45-
git update-index --add --cacheinfo 100644 $NULL_SHA1 1 &&
43+
git update-index --add --cacheinfo 100644 $EMPTY_BLOB 1 &&
4644
git update-index --skip-worktree 1
4745
}
4846

4947
test_dirty() {
50-
echo "100644 $NULL_SHA1 0 1" > expected &&
48+
echo "100644 $EMPTY_BLOB 0 1" > expected &&
5149
git ls-files --stage 1 > result &&
5250
test_cmp expected result &&
5351
echo dirty > expected
@@ -120,7 +118,7 @@ test_expect_success 'grep with skip-worktree file' '
120118
test "$(git grep --no-ext-grep test)" = "1:test"
121119
'
122120

123-
echo ":000000 100644 $_z40 $NULL_SHA1 A 1" > expected
121+
echo ":000000 100644 $_z40 $EMPTY_BLOB A 1" > expected
124122
test_expect_success 'diff-index does not examine skip-worktree absent entries' '
125123
setup_absent &&
126124
git diff-index HEAD -- 1 > result &&

t/t7012-skip-worktree-writing.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,15 @@ test_expect_success 'read-tree removes worktree, dirty case' '
5353
git update-index --no-skip-worktree added
5454
'
5555

56-
NULL_SHA1=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
57-
5856
setup_absent() {
5957
test -f 1 && rm 1
6058
git update-index --remove 1 &&
61-
git update-index --add --cacheinfo 100644 $NULL_SHA1 1 &&
59+
git update-index --add --cacheinfo 100644 $EMPTY_BLOB 1 &&
6260
git update-index --skip-worktree 1
6361
}
6462

6563
test_absent() {
66-
echo "100644 $NULL_SHA1 0 1" > expected &&
64+
echo "100644 $EMPTY_BLOB 0 1" > expected &&
6765
git ls-files --stage 1 > result &&
6866
test_cmp expected result &&
6967
test ! -f 1
@@ -72,12 +70,12 @@ test_absent() {
7270
setup_dirty() {
7371
git update-index --force-remove 1 &&
7472
echo dirty > 1 &&
75-
git update-index --add --cacheinfo 100644 $NULL_SHA1 1 &&
73+
git update-index --add --cacheinfo 100644 $EMPTY_BLOB 1 &&
7674
git update-index --skip-worktree 1
7775
}
7876

7977
test_dirty() {
80-
echo "100644 $NULL_SHA1 0 1" > expected &&
78+
echo "100644 $EMPTY_BLOB 0 1" > expected &&
8179
git ls-files --stage 1 > result &&
8280
test_cmp expected result &&
8381
echo dirty > expected

t/t7063-status-untracked-cache.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ A two
5353
EOF
5454

5555
cat >../dump.expect <<EOF &&
56-
info/exclude e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
56+
info/exclude $EMPTY_BLOB
5757
core.excludesfile 0000000000000000000000000000000000000000
5858
exclude_per_dir .gitignore
5959
flags 00000006
@@ -137,7 +137,7 @@ EOF
137137
test_expect_success 'verify untracked cache dump' '
138138
test-dump-untracked-cache >../actual &&
139139
cat >../expect <<EOF &&
140-
info/exclude e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
140+
info/exclude $EMPTY_BLOB
141141
core.excludesfile 0000000000000000000000000000000000000000
142142
exclude_per_dir .gitignore
143143
flags 00000006
@@ -184,7 +184,7 @@ EOF
184184
test_expect_success 'verify untracked cache dump' '
185185
test-dump-untracked-cache >../actual &&
186186
cat >../expect <<EOF &&
187-
info/exclude e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
187+
info/exclude $EMPTY_BLOB
188188
core.excludesfile 0000000000000000000000000000000000000000
189189
exclude_per_dir .gitignore
190190
flags 00000006

t/t7508-status.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ EOF
803803
'
804804

805805
cat >expect <<EOF
806-
:100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
806+
:100644 100644 $EMPTY_BLOB 0000000000000000000000000000000000000000 M dir1/modified
807807
EOF
808808
test_expect_success 'status refreshes the index' '
809809
touch dir2/added &&

t/test-lib.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ _x40="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05"
163163
_z40=0000000000000000000000000000000000000000
164164

165165
EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
166+
EMPTY_BLOB=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
166167

167168
# Line feed
168169
LF='
@@ -172,7 +173,7 @@ LF='
172173
# when case-folding filenames
173174
u200c=$(printf '\342\200\214')
174175

175-
export _x05 _x40 _z40 LF u200c EMPTY_TREE
176+
export _x05 _x40 _z40 LF u200c EMPTY_TREE EMPTY_BLOB
176177

177178
# Each test should start with something like this, after copyright notices:
178179
#

0 commit comments

Comments
 (0)