Skip to content

Commit 3474b60

Browse files
hanwengitster
authored andcommitted
test-ref-store: tweaks to for-each-reflog-ent format
We have some tests that read from files in .git/logs/ hierarchy when checking if correct reflog entries are created, but that is too specific to the files backend. Other backends like reftable may not store its reflog entries in such a "one line per entry" format. Update for-each-reflog-ent test helper to produce output that is identical to lines in a reflog file files backend uses. That way, (1) the current tests can be updated to use the test helper to read the reflog entries instead of (parts of) reflog files, and perform the same inspection for correctness, and (2) when the ref backend is swapped to another backend, the updated test can be used as-is to check the correctness. Adapt t1400 to use the for-each-reflog-ent test helper. Signed-off-by: Han-Wen Nienhuys <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6887f69 commit 3474b60

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

t/helper/test-ref-store.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,9 @@ static int each_reflog(struct object_id *old_oid, struct object_id *new_oid,
152152
const char *committer, timestamp_t timestamp,
153153
int tz, const char *msg, void *cb_data)
154154
{
155-
printf("%s %s %s %" PRItime " %d %s", oid_to_hex(old_oid),
156-
oid_to_hex(new_oid), committer, timestamp, tz, msg);
155+
printf("%s %s %s %" PRItime " %+05d%s%s", oid_to_hex(old_oid),
156+
oid_to_hex(new_oid), committer, timestamp, tz,
157+
*msg == '\n' ? "" : "\t", msg);
157158
return 0;
158159
}
159160

t/t1400-update-ref.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,9 @@ $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150260 +0000 Switch
321321
$B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000
322322
EOF
323323
test_expect_success "verifying $m's log (logged by touch)" '
324-
test_when_finished "rm -rf .git/$m .git/logs expect" &&
325-
test_cmp expect .git/logs/$m
324+
test_when_finished "git update-ref -d $m && rm -rf .git/logs actual expect" &&
325+
test-tool ref-store main for-each-reflog-ent $m >actual &&
326+
test_cmp actual expect
326327
'
327328

328329
test_expect_success "create $m (logged by config)" '
@@ -350,8 +351,9 @@ $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 +0000 Switch
350351
$B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 +0000
351352
EOF
352353
test_expect_success "verifying $m's log (logged by config)" '
353-
test_when_finished "rm -f .git/$m .git/logs/$m expect" &&
354-
test_cmp expect .git/logs/$m
354+
test_when_finished "git update-ref -d $m && rm -rf .git/logs actual expect" &&
355+
test-tool ref-store main for-each-reflog-ent $m >actual &&
356+
test_cmp actual expect
355357
'
356358

357359
test_expect_success 'set up for querying the reflog' '
@@ -467,7 +469,8 @@ $h_OTHER $h_FIXED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151040 +0000 co
467469
$h_FIXED $h_MERGED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151100 +0000 commit (merge): Merged initial commit and a later commit.
468470
EOF
469471
test_expect_success 'git commit logged updates' '
470-
test_cmp expect .git/logs/$m
472+
test-tool ref-store main for-each-reflog-ent $m >actual &&
473+
test_cmp expect actual
471474
'
472475
unset h_TEST h_OTHER h_FIXED h_MERGED
473476

0 commit comments

Comments
 (0)