Skip to content

Commit db7288b

Browse files
pks-tgitster
authored andcommitted
t1400: split up generic reflog tests from the reffile-specific ones
We have a bunch of tests in t1400 that check whether we correctly read reflog entries. These tests create the reflog by manually writing to the respective loose file, which makes them specific to the files backend. But while some of them do indeed exercise very specific edge cases in the reffiles backend, most of the tests exercise generic functionality that should be common to all backends. Unfortunately, we can't easily adapt all of the tests to work with all backends. Instead, split out the reffile-specific tests from the ones that should work with all backends and refactor the generic ones to not write to the on-disk files directly anymore. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 54087dd commit db7288b

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

t/t1400-update-ref.sh

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,28 @@ test_expect_success "verifying $m's log (logged by config)" '
354354
'
355355

356356
test_expect_success 'set up for querying the reflog' '
357+
git update-ref -d $m &&
358+
test-tool ref-store main delete-reflog $m &&
359+
360+
GIT_COMMITTER_DATE="1117150320 -0500" git update-ref $m $C &&
361+
GIT_COMMITTER_DATE="1117150350 -0500" git update-ref $m $A &&
362+
GIT_COMMITTER_DATE="1117150380 -0500" git update-ref $m $B &&
363+
GIT_COMMITTER_DATE="1117150680 -0500" git update-ref $m $F &&
364+
GIT_COMMITTER_DATE="1117150980 -0500" git update-ref $m $E &&
357365
git update-ref $m $D &&
358-
cat >.git/logs/$m <<-EOF
366+
# Delete the last reflog entry so that the tip of m and the reflog for
367+
# it disagree.
368+
git reflog delete $m@{0} &&
369+
370+
cat >expect <<-EOF &&
359371
$Z $C $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500
360372
$C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150350 -0500
361373
$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500
362-
$F $Z $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500
363-
$Z $E $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 -0500
374+
$B $F $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500
375+
$F $E $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 -0500
364376
EOF
377+
test-tool ref-store main for-each-reflog-ent $m >actual &&
378+
test_cmp expect actual
365379
'
366380

367381
ed="Thu, 26 May 2005 18:32:00 -0500"
@@ -409,13 +423,12 @@ test_expect_success 'Query "main@{2005-05-26 23:33:01}" (middle of history with
409423
test_when_finished "rm -f o e" &&
410424
git rev-parse --verify "main@{2005-05-26 23:33:01}" >o 2>e &&
411425
echo "$B" >expect &&
412-
test_cmp expect o &&
413-
test_grep -F "warning: log for ref $m has gap after $gd" e
426+
test_cmp expect o
414427
'
415428
test_expect_success 'Query "main@{2005-05-26 23:38:00}" (middle of history)' '
416429
test_when_finished "rm -f o e" &&
417430
git rev-parse --verify "main@{2005-05-26 23:38:00}" >o 2>e &&
418-
echo "$Z" >expect &&
431+
echo "$F" >expect &&
419432
test_cmp expect o &&
420433
test_must_be_empty e
421434
'
@@ -436,6 +449,22 @@ test_expect_success 'Query "main@{2005-05-28}" (past end of history)' '
436449

437450
rm -f .git/$m .git/logs/$m expect
438451

452+
test_expect_success REFFILES 'query reflog with gap' '
453+
test_when_finished "git update-ref -d $m" &&
454+
455+
git update-ref $m $F &&
456+
cat >.git/logs/$m <<-EOF &&
457+
$Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500
458+
$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500
459+
$D $F $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500
460+
EOF
461+
462+
git rev-parse --verify "main@{2005-05-26 23:33:01}" >actual 2>stderr &&
463+
echo "$B" >expect &&
464+
test_cmp expect actual &&
465+
test_grep -F "warning: log for ref $m has gap after $gd" stderr
466+
'
467+
439468
test_expect_success 'creating initial files' '
440469
test_when_finished rm -f M &&
441470
echo TEST >F &&

0 commit comments

Comments
 (0)