test-lib.sh: introduce and use $EMPTY_TREE
This is a special SHA1. Let's keep it at one place, easier to replace later when the hash change comes, easier to recognize. 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
f9e7d9f8c3e32280418a0bedd9d37f2a0cc2e2b9
6 files changed
+11
-13
t/t0000-basic.sh
+1
-1
@@ -834,7 +834,7 @@ test_expect_success 'git write-tree should be able to write an empty tree' '
834
'
835
836
test_expect_success 'validate object ID of a known tree' '
837
- test "$tree" = 4b825dc642cb6eb9a060e54bf8d69288fbee4904
837
+ test "$tree" = $EMPTY_TREE
838
'
839
840
# Various types of objects
t/t1100-commit-tree-options.sh
+1
-1
@@ -15,7 +15,7 @@ Also make sure that command line parser understands the normal
15
. ./test-lib.sh
16
17
cat >expected <<EOF
18
-tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
18
+tree $EMPTY_TREE
19
author Author Name <author@email> 1117148400 +0000
20
committer Committer Name <committer@email> 1117150200 +0000
21
t/t4010-diff-pathspec.sh
-2
@@ -78,8 +78,6 @@ test_expect_success 'diff-tree pathspec' '
78
test_cmp expected current
79
'
80
81
-EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
82
-
81
test_expect_success 'diff-tree with wildcard shows dir also matches' '
82
git diff-tree --name-only $EMPTY_TREE $tree -- "f*" >result &&
83
echo file0 >expected &&
t/t4054-diff-bogus-tree.sh
+4
-6
@@ -3,8 +3,6 @@
3
test_description='test diff with a bogus tree containing the null sha1'
4
. ./test-lib.sh
5
6
-empty_tree=4b825dc642cb6eb9a060e54bf8d69288fbee4904
7
-
6
test_expect_success 'create bogus tree' '
7
bogus_tree=$(
8
printf "100644 fooQQQQQQQQQQQQQQQQQQQQQ" |
@@ -22,13 +20,13 @@ test_expect_success 'create tree with matching file' '
20
21
test_expect_success 'raw diff shows null sha1 (addition)' '
22
echo ":000000 100644 $_z40 $_z40 A foo" >expect &&
25
- git diff-tree $empty_tree $bogus_tree >actual &&
23
+ git diff-tree $EMPTY_TREE $bogus_tree >actual &&
24
test_cmp expect actual
25
'
26
27
test_expect_success 'raw diff shows null sha1 (removal)' '
28
echo ":100644 000000 $_z40 $_z40 D foo" >expect &&
31
- git diff-tree $bogus_tree $empty_tree >actual &&
29
+ git diff-tree $bogus_tree $EMPTY_TREE >actual &&
30
test_cmp expect actual
31
'
32
@@ -57,11 +55,11 @@ test_expect_success 'raw diff shows null sha1 (index)' '
55
'
56
57
test_expect_success 'patch fails due to bogus sha1 (addition)' '
60
- test_must_fail git diff-tree -p $empty_tree $bogus_tree
58
+ test_must_fail git diff-tree -p $EMPTY_TREE $bogus_tree
59
'
60
61
test_expect_success 'patch fails due to bogus sha1 (removal)' '
64
- test_must_fail git diff-tree -p $bogus_tree $empty_tree
62
+ test_must_fail git diff-tree -p $bogus_tree $EMPTY_TREE
63
'
64
65
test_expect_success 'patch fails due to bogus sha1 (modification)' '
t/t5504-fetch-receive-strict.sh
+2
-2
@@ -115,8 +115,8 @@ test_expect_success 'push with transfer.fsckobjects' '
115
test_cmp exp act
116
'
117
118
-cat >bogus-commit <<\EOF
119
-tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
118
+cat >bogus-commit <<EOF
119
+tree $EMPTY_TREE
120
author Bugs Bunny 1234567890 +0000
121
committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000
122
t/test-lib.sh
+3
-1
@@ -162,6 +162,8 @@ _x40="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05"
162
# Zero SHA-1
163
_z40=0000000000000000000000000000000000000000
164
165
+EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
166
+
167
# Line feed
168
LF='
169
'
@@ -170,7 +172,7 @@ LF='
172
# when case-folding filenames
173
u200c=$(printf '\342\200\214')
174
173
-export _x05 _x40 _z40 LF u200c
175
+export _x05 _x40 _z40 LF u200c EMPTY_TREE
176
177
# Each test should start with something like this, after copyright notices:
178
#