@@ -9,22 +9,19 @@ echo_without_newline() {
99}
1010
1111test_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' "
1313 test_must_fail git cat-file blob $1
1414 "
1515}
1616
1717test_blob_exists () {
18- test_expect_success SHA1 ' blob exists in database' "
18+ test_expect_success ' blob exists in database' "
1919 git cat-file blob $1
2020 "
2121}
2222
2323hello_content=" Hello World"
24- hello_sha1=5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689
25-
2624example_content=" This is an example"
27- example_sha1=ddd3f836d3e3fbb7ae289aa9ae83536f76956399
2825
2926setup_repo () {
3027 echo_without_newline " $hello_content " > hello
@@ -44,7 +41,16 @@ pop_repo() {
4441 rm -rf $test_repo
4542}
4643
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+ '
4854
4955# Argument checking
5056
@@ -73,23 +79,23 @@ test_expect_success "Can't use --path with --no-filters" '
7379
7480push_repo
7581
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)
7884'
7985
80- test_blob_does_not_exist $hello_sha1
86+ test_blob_does_not_exist " $( test_oid hello ) "
8187
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)
8490'
8591
86- test_blob_does_not_exist $example_sha1
92+ test_blob_does_not_exist " $( test_oid example ) "
8793
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)
9096'
9197
92- test_blob_exists $hello_sha1
98+ test_blob_exists " $( test_oid hello ) "
9399
94100test_expect_success ' git hash-object --stdin file1 <file0 first operates on file0, then file1' '
95101 echo foo > file1 &&
@@ -161,34 +167,34 @@ pop_repo
161167for args in " -w --stdin" " --stdin -w" ; do
162168 push_repo
163169
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)
166172 '
167173
168- test_blob_exists $example_sha1
174+ test_blob_exists " $( test_oid example ) "
169175
170176 pop_repo
171177done
172178
173179filenames=" hello
174180example"
175181
176- sha1s =" $hello_sha1
177- $example_sha1 "
182+ oids =" $( test_oid hello )
183+ $( test_oid example ) "
178184
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)"
181187'
182188
183189for args in " -w --stdin-paths" " --stdin-paths -w" ; do
184190 push_repo
185191
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)"
188194 '
189195
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 ) "
192198
193199 pop_repo
194200done
0 commit comments