Skip to content

Commit c02ce75

Browse files
john-caigitster
authored andcommitted
t1410: move reffiles specific tests to t0600
Move these tests to t0600 with other reffiles specific tests since they do things like take a lock on an individual ref, and write directly into the reflog refs. Signed-off-by: John Cai <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e74d9f5 commit c02ce75

File tree

2 files changed

+51
-42
lines changed

2 files changed

+51
-42
lines changed

t/t0600-reffiles-backend.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,55 @@ test_expect_success 'for_each_reflog()' '
308308
test_cmp expected actual
309309
'
310310

311+
# Triggering the bug detected by this test requires a newline to fall
312+
# exactly BUFSIZ-1 bytes from the end of the file. We don't know
313+
# what that value is, since it's platform dependent. However, if
314+
# we choose some value N, we also catch any D which divides N evenly
315+
# (since we will read backwards in chunks of D). So we choose 8K,
316+
# which catches glibc (with an 8K BUFSIZ) and *BSD (1K).
317+
#
318+
# Each line is 114 characters, so we need 75 to still have a few before the
319+
# last 8K. The 89-character padding on the final entry lines up our
320+
# newline exactly.
321+
test_expect_success SHA1 'parsing reverse reflogs at BUFSIZ boundaries' '
322+
git checkout -b reflogskip &&
323+
zf=$(test_oid zero_2) &&
324+
ident="abc <xyz> 0000000001 +0000" &&
325+
for i in $(test_seq 1 75); do
326+
printf "$zf%02d $zf%02d %s\t" $i $(($i+1)) "$ident" &&
327+
if test $i = 75; then
328+
for j in $(test_seq 1 89); do
329+
printf X || return 1
330+
done
331+
else
332+
printf X
333+
fi &&
334+
printf "\n" || return 1
335+
done >.git/logs/refs/heads/reflogskip &&
336+
git rev-parse reflogskip@{73} >actual &&
337+
echo ${zf}03 >expect &&
338+
test_cmp expect actual
339+
'
340+
341+
# This test takes a lock on an individual ref; this is not supported in
342+
# reftable.
343+
test_expect_success 'reflog expire operates on symref not referrent' '
344+
git branch --create-reflog the_symref &&
345+
git branch --create-reflog referrent &&
346+
git update-ref referrent HEAD &&
347+
git symbolic-ref refs/heads/the_symref refs/heads/referrent &&
348+
test_when_finished "rm -f .git/refs/heads/referrent.lock" &&
349+
touch .git/refs/heads/referrent.lock &&
350+
git reflog expire --expire=all the_symref
351+
'
352+
353+
test_expect_success 'empty reflog' '
354+
test_when_finished "rm -rf empty" &&
355+
git init empty &&
356+
test_commit -C empty A &&
357+
>empty/.git/logs/refs/heads/foo &&
358+
git -C empty reflog expire --all 2>err &&
359+
test_must_be_empty err
360+
'
361+
311362
test_done

t/t1410-reflog.sh

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -354,36 +354,6 @@ test_expect_success 'stale dirs do not cause d/f conflicts (reflogs off)' '
354354
test_must_be_empty actual
355355
'
356356

357-
# Triggering the bug detected by this test requires a newline to fall
358-
# exactly BUFSIZ-1 bytes from the end of the file. We don't know
359-
# what that value is, since it's platform dependent. However, if
360-
# we choose some value N, we also catch any D which divides N evenly
361-
# (since we will read backwards in chunks of D). So we choose 8K,
362-
# which catches glibc (with an 8K BUFSIZ) and *BSD (1K).
363-
#
364-
# Each line is 114 characters, so we need 75 to still have a few before the
365-
# last 8K. The 89-character padding on the final entry lines up our
366-
# newline exactly.
367-
test_expect_success REFFILES,SHA1 'parsing reverse reflogs at BUFSIZ boundaries' '
368-
git checkout -b reflogskip &&
369-
zf=$(test_oid zero_2) &&
370-
ident="abc <xyz> 0000000001 +0000" &&
371-
for i in $(test_seq 1 75); do
372-
printf "$zf%02d $zf%02d %s\t" $i $(($i+1)) "$ident" &&
373-
if test $i = 75; then
374-
for j in $(test_seq 1 89); do
375-
printf X || return 1
376-
done
377-
else
378-
printf X
379-
fi &&
380-
printf "\n" || return 1
381-
done >.git/logs/refs/heads/reflogskip &&
382-
git rev-parse reflogskip@{73} >actual &&
383-
echo ${zf}03 >expect &&
384-
test_cmp expect actual
385-
'
386-
387357
test_expect_success 'no segfaults for reflog containing non-commit sha1s' '
388358
git update-ref --create-reflog -m "Creating ref" \
389359
refs/tests/tree-in-reflog HEAD &&
@@ -397,18 +367,6 @@ test_expect_failure 'reflog with non-commit entries displays all entries' '
397367
test_line_count = 3 actual
398368
'
399369

400-
# This test takes a lock on an individual ref; this is not supported in
401-
# reftable.
402-
test_expect_success REFFILES 'reflog expire operates on symref not referrent' '
403-
git branch --create-reflog the_symref &&
404-
git branch --create-reflog referrent &&
405-
git update-ref referrent HEAD &&
406-
git symbolic-ref refs/heads/the_symref refs/heads/referrent &&
407-
test_when_finished "rm -f .git/refs/heads/referrent.lock" &&
408-
touch .git/refs/heads/referrent.lock &&
409-
git reflog expire --expire=all the_symref
410-
'
411-
412370
test_expect_success 'continue walking past root commits' '
413371
git init orphanage &&
414372
(

0 commit comments

Comments
 (0)