Skip to content

Commit f9e7d9f

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 05219a1 commit f9e7d9f

File tree

6 files changed

+11
-13
lines changed

6 files changed

+11
-13
lines changed

t/t0000-basic.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ test_expect_success 'git write-tree should be able to write an empty tree' '
834834
'
835835

836836
test_expect_success 'validate object ID of a known tree' '
837-
test "$tree" = 4b825dc642cb6eb9a060e54bf8d69288fbee4904
837+
test "$tree" = $EMPTY_TREE
838838
'
839839

840840
# Various types of objects

t/t1100-commit-tree-options.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Also make sure that command line parser understands the normal
1515
. ./test-lib.sh
1616

1717
cat >expected <<EOF
18-
tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
18+
tree $EMPTY_TREE
1919
author Author Name <author@email> 1117148400 +0000
2020
committer Committer Name <committer@email> 1117150200 +0000
2121

t/t4010-diff-pathspec.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ test_expect_success 'diff-tree pathspec' '
7878
test_cmp expected current
7979
'
8080

81-
EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
82-
8381
test_expect_success 'diff-tree with wildcard shows dir also matches' '
8482
git diff-tree --name-only $EMPTY_TREE $tree -- "f*" >result &&
8583
echo file0 >expected &&

t/t4054-diff-bogus-tree.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
test_description='test diff with a bogus tree containing the null sha1'
44
. ./test-lib.sh
55

6-
empty_tree=4b825dc642cb6eb9a060e54bf8d69288fbee4904
7-
86
test_expect_success 'create bogus tree' '
97
bogus_tree=$(
108
printf "100644 fooQQQQQQQQQQQQQQQQQQQQQ" |
@@ -22,13 +20,13 @@ test_expect_success 'create tree with matching file' '
2220

2321
test_expect_success 'raw diff shows null sha1 (addition)' '
2422
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 &&
2624
test_cmp expect actual
2725
'
2826

2927
test_expect_success 'raw diff shows null sha1 (removal)' '
3028
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 &&
3230
test_cmp expect actual
3331
'
3432

@@ -57,11 +55,11 @@ test_expect_success 'raw diff shows null sha1 (index)' '
5755
'
5856

5957
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
6159
'
6260

6361
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
6563
'
6664

6765
test_expect_success 'patch fails due to bogus sha1 (modification)' '

t/t5504-fetch-receive-strict.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ test_expect_success 'push with transfer.fsckobjects' '
115115
test_cmp exp act
116116
'
117117

118-
cat >bogus-commit <<\EOF
119-
tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
118+
cat >bogus-commit <<EOF
119+
tree $EMPTY_TREE
120120
author Bugs Bunny 1234567890 +0000
121121
committer Bugs Bunny <[email protected]> 1234567890 +0000
122122

t/test-lib.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ _x40="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05"
162162
# Zero SHA-1
163163
_z40=0000000000000000000000000000000000000000
164164

165+
EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
166+
165167
# Line feed
166168
LF='
167169
'
@@ -170,7 +172,7 @@ LF='
170172
# when case-folding filenames
171173
u200c=$(printf '\342\200\214')
172174

173-
export _x05 _x40 _z40 LF u200c
175+
export _x05 _x40 _z40 LF u200c EMPTY_TREE
174176

175177
# Each test should start with something like this, after copyright notices:
176178
#

0 commit comments

Comments
 (0)