@@ -241,10 +241,16 @@ hello_content="Hello World"
241241hello_size=$( strlen " $hello_content " )
242242hello_oid=$( echo_without_newline " $hello_content " | git hash-object --stdin)
243243
244- test_expect_success " setup" '
244+ test_expect_success " setup part 1 " '
245245 git config core.repositoryformatversion 1 &&
246- git config extensions.objectformat $test_hash_algo &&
247- git config extensions.compatobjectformat $test_compat_hash_algo &&
246+ git config extensions.objectformat $test_hash_algo
247+ '
248+
249+ test_expect_success RUST ' compat setup' '
250+ git config extensions.compatobjectformat $test_compat_hash_algo
251+ '
252+
253+ test_expect_success ' setup part 2' '
248254 echo_without_newline "$hello_content" > hello &&
249255 git update-index --add hello &&
250256 echo_without_newline "$hello_content" > "path with spaces" &&
@@ -273,9 +279,13 @@ run_blob_tests () {
273279 '
274280}
275281
276- hello_compat_oid=$( git rev-parse --output-object-format=$test_compat_hash_algo $hello_oid )
277282run_blob_tests $hello_oid
278- run_blob_tests $hello_compat_oid
283+
284+ if test_have_prereq RUST
285+ then
286+ hello_compat_oid=$( git rev-parse --output-object-format=$test_compat_hash_algo $hello_oid )
287+ run_blob_tests $hello_compat_oid
288+ fi
279289
280290test_expect_success ' --batch-check without %(rest) considers whole line' '
281291 echo "$hello_oid blob $hello_size" >expect &&
@@ -286,62 +296,76 @@ test_expect_success '--batch-check without %(rest) considers whole line' '
286296'
287297
288298tree_oid=$( git write-tree)
289- tree_compat_oid=$( git rev-parse --output-object-format=$test_compat_hash_algo $tree_oid )
290299tree_size=$(( 2 * $(test_oid rawsz) + 13 + 24 ))
291- tree_compat_size=$(( 2 * $(test_oid -- hash= compat rawsz) + 13 + 24 ))
292300tree_pretty_content=" 100644 blob $hello_oid hello${LF} 100755 blob $hello_oid path with spaces${LF} "
293- tree_compat_pretty_content=" 100644 blob $hello_compat_oid hello${LF} 100755 blob $hello_compat_oid path with spaces${LF} "
294301
295302run_tests ' tree' $tree_oid " " $tree_size " " " $tree_pretty_content "
296- run_tests ' tree' $tree_compat_oid " " $tree_compat_size " " " $tree_compat_pretty_content "
297303run_tests ' blob' " $tree_oid :hello" " 100644" $hello_size " " " $hello_content " $hello_oid
298- run_tests ' blob' " $tree_compat_oid :hello" " 100644" $hello_size " " " $hello_content " $hello_compat_oid
299304run_tests ' blob' " $tree_oid :path with spaces" " 100755" $hello_size " " " $hello_content " $hello_oid
300- run_tests ' blob' " $tree_compat_oid :path with spaces" " 100755" $hello_size " " " $hello_content " $hello_compat_oid
305+
306+ if test_have_prereq RUST
307+ then
308+ tree_compat_oid=$( git rev-parse --output-object-format=$test_compat_hash_algo $tree_oid )
309+ tree_compat_size=$(( 2 * $(test_oid -- hash= compat rawsz) + 13 + 24 ))
310+ tree_compat_pretty_content=" 100644 blob $hello_compat_oid hello${LF} 100755 blob $hello_compat_oid path with spaces${LF} "
311+
312+ run_tests ' tree' $tree_compat_oid " " $tree_compat_size " " " $tree_compat_pretty_content "
313+ run_tests ' blob' " $tree_compat_oid :hello" " 100644" $hello_size " " " $hello_content " $hello_compat_oid
314+ run_tests ' blob' " $tree_compat_oid :path with spaces" " 100755" $hello_size " " " $hello_content " $hello_compat_oid
315+ fi
301316
302317commit_message=" Initial commit"
303318commit_oid=$( echo_without_newline " $commit_message " | git commit-tree $tree_oid )
304- commit_compat_oid=$( git rev-parse --output-object-format=$test_compat_hash_algo $commit_oid )
305319commit_size=$(( $(test_oid hexsz) + 137 ))
306- commit_compat_size=$(( $(test_oid -- hash= compat hexsz) + 137 ))
307320commit_content=" tree $tree_oid
308321author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL > $GIT_AUTHOR_DATE
309322committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL > $GIT_COMMITTER_DATE
310323
311324$commit_message "
312325
313- commit_compat_content=" tree $tree_compat_oid
326+ run_tests ' commit' $commit_oid " " $commit_size " $commit_content " " $commit_content "
327+
328+ if test_have_prereq RUST
329+ then
330+ commit_compat_oid=$( git rev-parse --output-object-format=$test_compat_hash_algo $commit_oid )
331+ commit_compat_size=$(( $(test_oid -- hash= compat hexsz) + 137 ))
332+ commit_compat_content=" tree $tree_compat_oid
314333author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL > $GIT_AUTHOR_DATE
315334committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL > $GIT_COMMITTER_DATE
316335
317336$commit_message "
318337
319- run_tests ' commit' $commit_oid " " $commit_size " $commit_content " " $commit_content "
320- run_tests ' commit ' $commit_compat_oid " " $commit_compat_size " $commit_compat_content " " $commit_compat_content "
338+ run_tests ' commit' $commit_compat_oid " " $commit_compat_size " $commit_compat_content " " $commit_compat_content "
339+ fi
321340
322341tag_header_without_oid=" type blob
323342tag hellotag
324343tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL >"
325344tag_header_without_timestamp=" object $hello_oid
326345$tag_header_without_oid "
327- tag_compat_header_without_timestamp=" object $hello_compat_oid
328- $tag_header_without_oid "
329346tag_description=" This is a tag"
330347tag_content=" $tag_header_without_timestamp 0 +0000
331348
332- $tag_description "
333- tag_compat_content=" $tag_compat_header_without_timestamp 0 +0000
334-
335349$tag_description "
336350
337351tag_oid=$( echo_without_newline " $tag_content " | git hash-object -t tag --stdin -w)
338352tag_size=$( strlen " $tag_content " )
339353
340- tag_compat_oid=$( git rev-parse --output-object-format=$test_compat_hash_algo $tag_oid )
341- tag_compat_size=$( strlen " $tag_compat_content " )
342-
343354run_tests ' tag' $tag_oid " " $tag_size " $tag_content " " $tag_content "
344- run_tests ' tag' $tag_compat_oid " " $tag_compat_size " $tag_compat_content " " $tag_compat_content "
355+
356+ if test_have_prereq RUST
357+ then
358+ tag_compat_header_without_timestamp=" object $hello_compat_oid
359+ $tag_header_without_oid "
360+ tag_compat_content=" $tag_compat_header_without_timestamp 0 +0000
361+
362+ $tag_description "
363+
364+ tag_compat_oid=$( git rev-parse --output-object-format=$test_compat_hash_algo $tag_oid )
365+ tag_compat_size=$( strlen " $tag_compat_content " )
366+
367+ run_tests ' tag' $tag_compat_oid " " $tag_compat_size " $tag_compat_content " " $tag_compat_content "
368+ fi
345369
346370test_expect_success " Reach a blob from a tag pointing to it" '
347371 echo_without_newline "$hello_content" >expect &&
@@ -590,7 +614,8 @@ flush"
590614}
591615
592616batch_tests $hello_oid $tree_oid $tree_size $commit_oid $commit_size " $commit_content " $tag_oid $tag_size " $tag_content "
593- batch_tests $hello_compat_oid $tree_compat_oid $tree_compat_size $commit_compat_oid $commit_compat_size " $commit_compat_content " $tag_compat_oid $tag_compat_size " $tag_compat_content "
617+
618+ test_have_prereq RUST && batch_tests $hello_compat_oid $tree_compat_oid $tree_compat_size $commit_compat_oid $commit_compat_size " $commit_compat_content " $tag_compat_oid $tag_compat_size " $tag_compat_content "
594619
595620
596621test_expect_success FUNNYNAMES ' setup with newline in input' '
@@ -1226,7 +1251,10 @@ test_expect_success 'batch-check with a submodule' '
12261251 test_unconfig extensions.compatobjectformat &&
12271252 printf "160000 commit $(test_oid deadbeef)\tsub\n" >tree-with-sub &&
12281253 tree=$(git mktree <tree-with-sub) &&
1229- test_config extensions.compatobjectformat $test_compat_hash_algo &&
1254+ if test_have_prereq RUST
1255+ then
1256+ test_config extensions.compatobjectformat $test_compat_hash_algo
1257+ fi &&
12301258
12311259 git cat-file --batch-check >actual <<-EOF &&
12321260 $tree:sub
0 commit comments