@@ -9,22 +9,19 @@ echo_without_newline() {
9
9
}
10
10
11
11
test_blob_does_not_exist () {
12
- test_expect_success SHA1 ' blob does not exist in database' "
12
+ test_expect_success ' blob does not exist in database' "
13
13
test_must_fail git cat-file blob $1
14
14
"
15
15
}
16
16
17
17
test_blob_exists () {
18
- test_expect_success SHA1 ' blob exists in database' "
18
+ test_expect_success ' blob exists in database' "
19
19
git cat-file blob $1
20
20
"
21
21
}
22
22
23
23
hello_content=" Hello World"
24
- hello_sha1=5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689
25
-
26
24
example_content=" This is an example"
27
- example_sha1=ddd3f836d3e3fbb7ae289aa9ae83536f76956399
28
25
29
26
setup_repo () {
30
27
echo_without_newline " $hello_content " > hello
@@ -44,7 +41,16 @@ pop_repo() {
44
41
rm -rf $test_repo
45
42
}
46
43
47
- setup_repo
44
+ test_expect_success ' setup' '
45
+ setup_repo &&
46
+ test_oid_cache <<-EOF
47
+ hello sha1:5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689
48
+ hello sha256:1e3b6c04d2eeb2b3e45c8a330445404c0b7cc7b257e2b097167d26f5230090c4
49
+
50
+ example sha1:ddd3f836d3e3fbb7ae289aa9ae83536f76956399
51
+ example sha256:b44fe1fe65589848253737db859bd490453510719d7424daab03daf0767b85ae
52
+ EOF
53
+ '
48
54
49
55
# Argument checking
50
56
@@ -73,23 +79,23 @@ test_expect_success "Can't use --path with --no-filters" '
73
79
74
80
push_repo
75
81
76
- test_expect_success SHA1 ' hash a file' '
77
- test $hello_sha1 = $(git hash-object hello)
82
+ test_expect_success ' hash a file' '
83
+ test "$(test_oid hello)" = $(git hash-object hello)
78
84
'
79
85
80
- test_blob_does_not_exist $hello_sha1
86
+ test_blob_does_not_exist " $( test_oid hello ) "
81
87
82
- test_expect_success SHA1 ' hash from stdin' '
83
- test $example_sha1 = $(git hash-object --stdin < example)
88
+ test_expect_success ' hash from stdin' '
89
+ test "$(test_oid example)" = $(git hash-object --stdin < example)
84
90
'
85
91
86
- test_blob_does_not_exist $example_sha1
92
+ test_blob_does_not_exist " $( test_oid example ) "
87
93
88
- test_expect_success SHA1 ' hash a file and write to database' '
89
- test $hello_sha1 = $(git hash-object -w hello)
94
+ test_expect_success ' hash a file and write to database' '
95
+ test "$(test_oid hello)" = $(git hash-object -w hello)
90
96
'
91
97
92
- test_blob_exists $hello_sha1
98
+ test_blob_exists " $( test_oid hello ) "
93
99
94
100
test_expect_success ' git hash-object --stdin file1 <file0 first operates on file0, then file1' '
95
101
echo foo > file1 &&
@@ -161,34 +167,34 @@ pop_repo
161
167
for args in " -w --stdin" " --stdin -w" ; do
162
168
push_repo
163
169
164
- test_expect_success SHA1 " hash from stdin and write to database ($args )" '
165
- test $example_sha1 = $(git hash-object $args < example)
170
+ test_expect_success " hash from stdin and write to database ($args )" '
171
+ test "$(test_oid example)" = $(git hash-object $args < example)
166
172
'
167
173
168
- test_blob_exists $example_sha1
174
+ test_blob_exists " $( test_oid example ) "
169
175
170
176
pop_repo
171
177
done
172
178
173
179
filenames=" hello
174
180
example"
175
181
176
- sha1s =" $hello_sha1
177
- $example_sha1 "
182
+ oids =" $( test_oid hello )
183
+ $( test_oid example ) "
178
184
179
- test_expect_success SHA1 " hash two files with names on stdin" '
180
- test "$sha1s " = "$(echo_without_newline "$filenames" | git hash-object --stdin-paths)"
185
+ test_expect_success " hash two files with names on stdin" '
186
+ test "$oids " = "$(echo_without_newline "$filenames" | git hash-object --stdin-paths)"
181
187
'
182
188
183
189
for args in " -w --stdin-paths" " --stdin-paths -w" ; do
184
190
push_repo
185
191
186
- test_expect_success SHA1 " hash two files with names on stdin and write to database ($args )" '
187
- test "$sha1s " = "$(echo_without_newline "$filenames" | git hash-object $args)"
192
+ test_expect_success " hash two files with names on stdin and write to database ($args )" '
193
+ test "$oids " = "$(echo_without_newline "$filenames" | git hash-object $args)"
188
194
'
189
195
190
- test_blob_exists $hello_sha1
191
- test_blob_exists $example_sha1
196
+ test_blob_exists " $( test_oid hello ) "
197
+ test_blob_exists " $( test_oid example ) "
192
198
193
199
pop_repo
194
200
done
0 commit comments