@@ -109,26 +109,12 @@ strlen () {
109
109
echo_without_newline " $1 " | wc -c | sed -e ' s/^ *//'
110
110
}
111
111
112
- maybe_remove_timestamp () {
113
- if test -z " $2 " ; then
114
- echo_without_newline " $1 "
115
- else
116
- echo_without_newline " $( printf ' %s\n' " $1 " | remove_timestamp) "
117
- fi
118
- }
119
-
120
- remove_timestamp () {
121
- sed -e ' s/ [0-9][0-9]* [-+][0-9][0-9][0-9][0-9]$//'
122
- }
123
-
124
-
125
112
run_tests () {
126
113
type=$1
127
114
sha1=$2
128
115
size=$3
129
116
content=$4
130
117
pretty_content=$5
131
- no_ts=$6
132
118
133
119
batch_output=" $sha1 $type $size
134
120
$content "
@@ -163,21 +149,21 @@ $content"
163
149
164
150
test -z " $content " ||
165
151
test_expect_success " Content of $type is correct" '
166
- maybe_remove_timestamp "$content" $no_ts >expect &&
167
- maybe_remove_timestamp "$( git cat-file $type $sha1)" $no_ts >actual &&
152
+ echo_without_newline "$content" >expect &&
153
+ git cat-file $type $sha1 >actual &&
168
154
test_cmp expect actual
169
155
'
170
156
171
157
test_expect_success " Pretty content of $type is correct" '
172
- maybe_remove_timestamp "$pretty_content" $no_ts >expect &&
173
- maybe_remove_timestamp "$( git cat-file -p $sha1)" $no_ts >actual &&
158
+ echo_without_newline "$pretty_content" >expect &&
159
+ git cat-file -p $sha1 >actual &&
174
160
test_cmp expect actual
175
161
'
176
162
177
163
test -z " $content " ||
178
164
test_expect_success " --batch output of $type is correct" '
179
- maybe_remove_timestamp "$batch_output" $no_ts >expect &&
180
- maybe_remove_timestamp "$( echo $sha1 | git cat-file --batch)" $no_ts >actual &&
165
+ echo "$batch_output" >expect &&
166
+ echo $sha1 | git cat-file --batch >actual &&
181
167
test_cmp expect actual
182
168
'
183
169
@@ -191,9 +177,8 @@ $content"
191
177
do
192
178
test -z " $content " ||
193
179
test_expect_success " --batch-command $opt output of $type content is correct" '
194
- maybe_remove_timestamp "$batch_output" $no_ts >expect &&
195
- maybe_remove_timestamp "$(test_write_lines "contents $sha1" |
196
- git cat-file --batch-command $opt)" $no_ts >actual &&
180
+ echo "$batch_output" >expect &&
181
+ test_write_lines "contents $sha1" | git cat-file --batch-command $opt >actual &&
197
182
test_cmp expect actual
198
183
'
199
184
@@ -228,21 +213,19 @@ $content"
228
213
test_expect_success " --batch without type ($type )" '
229
214
{
230
215
echo "$size" &&
231
- maybe_remove_timestamp "$content" $no_ts
216
+ echo "$content"
232
217
} >expect &&
233
- echo $sha1 | git cat-file --batch="%(objectsize)" >actual.full &&
234
- maybe_remove_timestamp "$(cat actual.full)" $no_ts >actual &&
218
+ echo $sha1 | git cat-file --batch="%(objectsize)" >actual &&
235
219
test_cmp expect actual
236
220
'
237
221
238
222
test -z " $content " ||
239
223
test_expect_success " --batch without size ($type )" '
240
224
{
241
225
echo "$type" &&
242
- maybe_remove_timestamp "$content" $no_ts
226
+ echo "$content"
243
227
} >expect &&
244
- echo $sha1 | git cat-file --batch="%(objecttype)" >actual.full &&
245
- maybe_remove_timestamp "$(cat actual.full)" $no_ts >actual &&
228
+ echo $sha1 | git cat-file --batch="%(objecttype)" >actual &&
246
229
test_cmp expect actual
247
230
'
248
231
}
@@ -284,20 +267,20 @@ test_expect_success '--batch-check without %(rest) considers whole line' '
284
267
285
268
tree_sha1=$( git write-tree)
286
269
tree_size=$(( $(test_oid rawsz) + 13 ))
287
- tree_pretty_content=" 100644 blob $hello_sha1 hello"
270
+ tree_pretty_content=" 100644 blob $hello_sha1 hello${LF} "
288
271
289
272
run_tests ' tree' $tree_sha1 $tree_size " " " $tree_pretty_content "
290
273
291
274
commit_message=" Initial commit"
292
275
commit_sha1=$( echo_without_newline " $commit_message " | git commit-tree $tree_sha1 )
293
276
commit_size=$(( $(test_oid hexsz) + 137 ))
294
277
commit_content=" tree $tree_sha1
295
- author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL > 0 +0000
296
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL > 0 +0000
278
+ author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL > $GIT_AUTHOR_DATE
279
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL > $GIT_COMMITTER_DATE
297
280
298
281
$commit_message "
299
282
300
- run_tests ' commit' $commit_sha1 $commit_size " $commit_content " " $commit_content " 1
283
+ run_tests ' commit' $commit_sha1 $commit_size " $commit_content " " $commit_content "
301
284
302
285
tag_header_without_timestamp=" object $hello_sha1
303
286
type blob
@@ -311,7 +294,7 @@ $tag_description"
311
294
tag_sha1=$( echo_without_newline " $tag_content " | git hash-object -t tag --stdin -w)
312
295
tag_size=$( strlen " $tag_content " )
313
296
314
- run_tests ' tag' $tag_sha1 $tag_size " $tag_content " " $tag_content " 1
297
+ run_tests ' tag' $tag_sha1 $tag_size " $tag_content " " $tag_content "
315
298
316
299
test_expect_success \
317
300
" Reach a blob from a tag pointing to it" \
@@ -400,13 +383,16 @@ deadbeef missing
400
383
missing"
401
384
402
385
test_expect_success ' --batch with multiple sha1s gives correct format' '
403
- test "$(maybe_remove_timestamp "$batch_output" 1)" = "$(maybe_remove_timestamp "$(echo_without_newline "$batch_input" | git cat-file --batch)" 1)"
386
+ echo "$batch_output" >expect &&
387
+ echo_without_newline "$batch_input" | git cat-file --batch >actual &&
388
+ test_cmp expect actual
404
389
'
405
390
406
391
test_expect_success ' --batch, -z with multiple sha1s gives correct format' '
407
392
echo_without_newline_nul "$batch_input" >in &&
408
- test "$(maybe_remove_timestamp "$batch_output" 1)" = \
409
- "$(maybe_remove_timestamp "$(git cat-file --batch -z <in)" 1)"
393
+ echo "$batch_output" >expect &&
394
+ git cat-file --batch -z <in >actual &&
395
+ test_cmp expect actual
410
396
'
411
397
412
398
batch_check_input=" $hello_sha1
@@ -480,7 +466,7 @@ contents deadbeef
480
466
flush"
481
467
482
468
test_expect_success ' --batch-command with multiple command calls gives correct format' '
483
- remove_timestamp >expect <<-EOF &&
469
+ cat >expect <<-EOF &&
484
470
$hello_sha1 blob $hello_size
485
471
$hello_content
486
472
$commit_sha1 commit $commit_size
@@ -491,15 +477,13 @@ test_expect_success '--batch-command with multiple command calls gives correct f
491
477
EOF
492
478
493
479
echo "$batch_command_multiple_contents" >in &&
494
- git cat-file --batch-command --buffer <in >actual_raw &&
480
+ git cat-file --batch-command --buffer <in >actual &&
495
481
496
- remove_timestamp <actual_raw >actual &&
497
482
test_cmp expect actual &&
498
483
499
484
echo "$batch_command_multiple_contents" | tr "\n" "\0" >in &&
500
- git cat-file --batch-command --buffer -z <in >actual_raw &&
485
+ git cat-file --batch-command --buffer -z <in >actual &&
501
486
502
- remove_timestamp <actual_raw >actual &&
503
487
test_cmp expect actual
504
488
'
505
489
0 commit comments