@@ -114,10 +114,11 @@ strlen () {
114
114
run_tests () {
115
115
type=$1
116
116
object_name=" $2 "
117
- size=$3
118
- content=$4
119
- pretty_content=$5
120
- oid=${6:- " $object_name " }
117
+ mode=$3
118
+ size=$4
119
+ content=$5
120
+ pretty_content=$6
121
+ oid=${7:- " $object_name " }
121
122
122
123
batch_output=" $oid $type $size
123
124
$content "
@@ -209,6 +210,12 @@ $content"
209
210
test_cmp expect actual
210
211
'
211
212
213
+ test_expect_success ' --batch-check with %(objectmode)' '
214
+ echo "$mode $oid" >expect &&
215
+ echo $object_name | git cat-file --batch-check="%(objectmode) %(objectname)" >actual &&
216
+ test_cmp expect actual
217
+ '
218
+
212
219
test -z " $content " ||
213
220
test_expect_success " --batch without type ($type )" '
214
221
{
@@ -247,8 +254,7 @@ test_expect_success "setup" '
247
254
248
255
run_blob_tests () {
249
256
oid=$1
250
-
251
- run_tests ' blob' $oid $hello_size " $hello_content " " $hello_content "
257
+ run_tests ' blob' $oid " " $hello_size " $hello_content " " $hello_content "
252
258
253
259
test_expect_success ' --batch-command --buffer with flush for blob info' '
254
260
echo "$oid blob $hello_size" >expect &&
@@ -286,12 +292,12 @@ tree_compat_size=$((2 * $(test_oid --hash=compat rawsz) + 13 + 24))
286
292
tree_pretty_content=" 100644 blob $hello_oid hello${LF} 100755 blob $hello_oid path with spaces${LF} "
287
293
tree_compat_pretty_content=" 100644 blob $hello_compat_oid hello${LF} 100755 blob $hello_compat_oid path with spaces${LF} "
288
294
289
- run_tests ' tree' $tree_oid $tree_size " " " $tree_pretty_content "
290
- run_tests ' tree' $tree_compat_oid $tree_compat_size " " " $tree_compat_pretty_content "
291
- run_tests ' blob' " $tree_oid :hello" $hello_size " " " $hello_content " $hello_oid
292
- run_tests ' blob' " $tree_compat_oid :hello" $hello_size " " " $hello_content " $hello_compat_oid
293
- run_tests ' blob' " $tree_oid :path with spaces" $hello_size " " " $hello_content " $hello_oid
294
- run_tests ' blob' " $tree_compat_oid :path with spaces" $hello_size " " " $hello_content " $hello_compat_oid
295
+ run_tests ' tree' $tree_oid " " $tree_size " " " $tree_pretty_content "
296
+ run_tests ' tree' $tree_compat_oid " " $tree_compat_size " " " $tree_compat_pretty_content "
297
+ run_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
299
+ run_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
295
301
296
302
commit_message=" Initial commit"
297
303
commit_oid=$( echo_without_newline " $commit_message " | git commit-tree $tree_oid )
@@ -310,8 +316,8 @@ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
310
316
311
317
$commit_message "
312
318
313
- run_tests ' commit' $commit_oid $commit_size " $commit_content " " $commit_content "
314
- run_tests ' commit' $commit_compat_oid $commit_compat_size " $commit_compat_content " " $commit_compat_content "
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 "
315
321
316
322
tag_header_without_oid=" type blob
317
323
tag hellotag
@@ -334,8 +340,8 @@ tag_size=$(strlen "$tag_content")
334
340
tag_compat_oid=$( git rev-parse --output-object-format=$test_compat_hash_algo $tag_oid )
335
341
tag_compat_size=$( strlen " $tag_compat_content " )
336
342
337
- run_tests ' tag' $tag_oid $tag_size " $tag_content " " $tag_content "
338
- run_tests ' tag' $tag_compat_oid $tag_compat_size " $tag_compat_content " " $tag_compat_content "
343
+ run_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 "
339
345
340
346
test_expect_success " Reach a blob from a tag pointing to it" '
341
347
echo_without_newline "$hello_content" >expect &&
0 commit comments