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 <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Jul 16, 2016 at 07:06 UTC 378932d3c3214cf658805af20c4bd101922d8fcd
8 files changed +35 -38
t/t1011-read-tree-sparse-checkout.sh
+4 -4
@@ -15,11 +15,11 @@ test_description='sparse checkout tests
15 . "$TEST_DIRECTORY"/lib-read-tree.sh
16
17 test_expect_success 'setup' '
18 - cat >expected <<-\EOF &&
18 + cat >expected <<-EOF &&
19 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
23 EOF
24 cat >expected.swt <<-\EOF &&
25 H init.t
t/t1700-split-index.sh
+12 -12
@@ -33,14 +33,14 @@ test_expect_success 'add one file' '
33 git update-index --add one &&
34 git ls-files --stage >ls-files.actual &&
35 cat >ls-files.expect <<EOF &&
36 -100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
36 +100644 $EMPTY_BLOB 0 one
37 EOF
38 test_cmp ls-files.expect ls-files.actual &&
39
40 test-dump-split-index .git/index | sed "/^own/d" >actual &&
41 cat >expect <<EOF &&
42 base $base
43 -100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
43 +100644 $EMPTY_BLOB 0 one
44 replacements:
45 deletions:
46 EOF
@@ -51,7 +51,7 @@ test_expect_success 'disable split index' '
51 git update-index --no-split-index &&
52 git ls-files --stage >ls-files.actual &&
53 cat >ls-files.expect <<EOF &&
54 -100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
54 +100644 $EMPTY_BLOB 0 one
55 EOF
56 test_cmp ls-files.expect ls-files.actual &&
57
@@ -67,7 +67,7 @@ test_expect_success 'enable split index again, "one" now belongs to base index"'
67 git update-index --split-index &&
68 git ls-files --stage >ls-files.actual &&
69 cat >ls-files.expect <<EOF &&
70 -100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
70 +100644 $EMPTY_BLOB 0 one
71 EOF
72 test_cmp ls-files.expect ls-files.actual &&
73
@@ -105,7 +105,7 @@ test_expect_success 'add another file, which stays index' '
105 git ls-files --stage >ls-files.actual &&
106 cat >ls-files.expect <<EOF &&
107 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
108 -100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
108 +100644 $EMPTY_BLOB 0 two
109 EOF
110 test_cmp ls-files.expect ls-files.actual &&
111
@@ -113,7 +113,7 @@ EOF
113 q_to_tab >expect <<EOF &&
114 $BASE
115 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
116 -100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
116 +100644 $EMPTY_BLOB 0 two
117 replacements: 0
118 deletions:
119 EOF
@@ -159,14 +159,14 @@ test_expect_success 'add original file back' '
159 git update-index --add one &&
160 git ls-files --stage >ls-files.actual &&
161 cat >ls-files.expect <<EOF &&
162 -100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
162 +100644 $EMPTY_BLOB 0 one
163 EOF
164 test_cmp ls-files.expect ls-files.actual &&
165
166 test-dump-split-index .git/index | sed "/^own/d" >actual &&
167 cat >expect <<EOF &&
168 $BASE
169 -100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
169 +100644 $EMPTY_BLOB 0 one
170 replacements:
171 deletions: 0
172 EOF
@@ -178,8 +178,8 @@ test_expect_success 'add new file' '
178 git update-index --add two &&
179 git ls-files --stage >actual &&
180 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
183 EOF
184 test_cmp expect actual
185 '
@@ -188,8 +188,8 @@ test_expect_success 'unify index, two files remain' '
188 git update-index --no-split-index &&
189 git ls-files --stage >ls-files.actual &&
190 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
193 EOF
194 test_cmp ls-files.expect ls-files.actual &&
195
t/t3102-ls-tree-wildcards.sh
+4 -4
@@ -12,16 +12,16 @@ test_expect_success 'setup' '
12 '
13
14 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
17 EOF
18 git ls-tree -r HEAD "a[a]" >actual &&
19 test_cmp expect actual
20 '
21
22 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
25 EOF
26 ( cd aa && git ls-tree -r HEAD "../a[a]"; ) >actual &&
27 test_cmp expect actual
t/t7011-skip-worktree-reading.sh
+5 -7
@@ -23,17 +23,15 @@ S sub/1
23 H sub/2
24 EOF
25
26 -NULL_SHA1=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
27 -
26 setup_absent() {
27 test -f 1 && rm 1
28 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 &&
30 git update-index --skip-worktree 1
31 }
32
33 test_absent() {
36 - echo "100644 $NULL_SHA1 0 1" > expected &&
34 + echo "100644 $EMPTY_BLOB 0 1" > expected &&
35 git ls-files --stage 1 > result &&
36 test_cmp expected result &&
37 test ! -f 1
@@ -42,12 +40,12 @@ test_absent() {
40 setup_dirty() {
41 git update-index --force-remove 1 &&
42 echo dirty > 1 &&
45 - git update-index --add --cacheinfo 100644 $NULL_SHA1 1 &&
43 + git update-index --add --cacheinfo 100644 $EMPTY_BLOB 1 &&
44 git update-index --skip-worktree 1
45 }
46
47 test_dirty() {
50 - echo "100644 $NULL_SHA1 0 1" > expected &&
48 + echo "100644 $EMPTY_BLOB 0 1" > expected &&
49 git ls-files --stage 1 > result &&
50 test_cmp expected result &&
51 echo dirty > expected
@@ -120,7 +118,7 @@ test_expect_success 'grep with skip-worktree file' '
118 test "$(git grep --no-ext-grep test)" = "1:test"
119 '
120
123 -echo ":000000 100644 $_z40 $NULL_SHA1 A 1" > expected
121 +echo ":000000 100644 $_z40 $EMPTY_BLOB A 1" > expected
122 test_expect_success 'diff-index does not examine skip-worktree absent entries' '
123 setup_absent &&
124 git diff-index HEAD -- 1 > result &&
t/t7012-skip-worktree-writing.sh
+4 -6
@@ -53,17 +53,15 @@ test_expect_success 'read-tree removes worktree, dirty case' '
53 git update-index --no-skip-worktree added
54 '
55
56 -NULL_SHA1=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
57 -
56 setup_absent() {
57 test -f 1 && rm 1
58 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 &&
60 git update-index --skip-worktree 1
61 }
62
63 test_absent() {
66 - echo "100644 $NULL_SHA1 0 1" > expected &&
64 + echo "100644 $EMPTY_BLOB 0 1" > expected &&
65 git ls-files --stage 1 > result &&
66 test_cmp expected result &&
67 test ! -f 1
@@ -72,12 +70,12 @@ test_absent() {
70 setup_dirty() {
71 git update-index --force-remove 1 &&
72 echo dirty > 1 &&
75 - git update-index --add --cacheinfo 100644 $NULL_SHA1 1 &&
73 + git update-index --add --cacheinfo 100644 $EMPTY_BLOB 1 &&
74 git update-index --skip-worktree 1
75 }
76
77 test_dirty() {
80 - echo "100644 $NULL_SHA1 0 1" > expected &&
78 + echo "100644 $EMPTY_BLOB 0 1" > expected &&
79 git ls-files --stage 1 > result &&
80 test_cmp expected result &&
81 echo dirty > expected
t/t7063-status-untracked-cache.sh
+3 -3
@@ -53,7 +53,7 @@ A two
53 EOF
54
55 cat >../dump.expect <<EOF &&
56 -info/exclude e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
56 +info/exclude $EMPTY_BLOB
57 core.excludesfile 0000000000000000000000000000000000000000
58 exclude_per_dir .gitignore
59 flags 00000006
@@ -137,7 +137,7 @@ EOF
137 test_expect_success 'verify untracked cache dump' '
138 test-dump-untracked-cache >../actual &&
139 cat >../expect <<EOF &&
140 -info/exclude e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
140 +info/exclude $EMPTY_BLOB
141 core.excludesfile 0000000000000000000000000000000000000000
142 exclude_per_dir .gitignore
143 flags 00000006
@@ -184,7 +184,7 @@ EOF
184 test_expect_success 'verify untracked cache dump' '
185 test-dump-untracked-cache >../actual &&
186 cat >../expect <<EOF &&
187 -info/exclude e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
187 +info/exclude $EMPTY_BLOB
188 core.excludesfile 0000000000000000000000000000000000000000
189 exclude_per_dir .gitignore
190 flags 00000006
t/t7508-status.sh
+1 -1
@@ -803,7 +803,7 @@ EOF
803 '
804
805 cat >expect <<EOF
806 -:100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
806 +:100644 100644 $EMPTY_BLOB 0000000000000000000000000000000000000000 M dir1/modified
807 EOF
808 test_expect_success 'status refreshes the index' '
809 touch dir2/added &&
t/test-lib.sh
+2 -1
@@ -163,6 +163,7 @@ _x40="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05"
163 _z40=0000000000000000000000000000000000000000
164
165 EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
166 +EMPTY_BLOB=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
167
168 # Line feed
169 LF='
@@ -172,7 +173,7 @@ LF='
173 # when case-folding filenames
174 u200c=$(printf '\342\200\214')
175
175 -export _x05 _x40 _z40 LF u200c EMPTY_TREE
176 +export _x05 _x40 _z40 LF u200c EMPTY_TREE EMPTY_BLOB
177
178 # Each test should start with something like this, after copyright notices:
179 #