From 21f0e8506119dc18c0b2396b5854d850cba7b00d Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 2 Dec 2021 17:36:30 +0000 Subject: test-ref-store: don't add newline to reflog message By convention, reflog messages always end in '\n', so before we would print blank lines between entries. Signed-off-by: Han-Wen Nienhuys Signed-off-by: Junio C Hamano --- t/helper/test-ref-store.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 't/helper/test-ref-store.c') diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index 3986665037..5ac33dfb59 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -152,9 +152,8 @@ static int each_reflog(struct object_id *old_oid, struct object_id *new_oid, const char *committer, timestamp_t timestamp, int tz, const char *msg, void *cb_data) { - printf("%s %s %s %"PRItime" %d %s\n", - oid_to_hex(old_oid), oid_to_hex(new_oid), - committer, timestamp, tz, msg); + printf("%s %s %s %" PRItime " %d %s", oid_to_hex(old_oid), + oid_to_hex(new_oid), committer, timestamp, tz, msg); return 0; } -- cgit v1.2.3 From 3474b602a5387df459a25c3e35747c11f1b08da7 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 2 Dec 2021 17:36:32 +0000 Subject: 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 Signed-off-by: Junio C Hamano --- t/helper/test-ref-store.c | 5 +++-- t/t1400-update-ref.sh | 13 ++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 't/helper/test-ref-store.c') diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index 5ac33dfb59..775e5da5b9 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -152,8 +152,9 @@ static int each_reflog(struct object_id *old_oid, struct object_id *new_oid, const char *committer, timestamp_t timestamp, int tz, const char *msg, void *cb_data) { - printf("%s %s %s %" PRItime " %d %s", oid_to_hex(old_oid), - oid_to_hex(new_oid), committer, timestamp, tz, msg); + printf("%s %s %s %" PRItime " %+05d%s%s", oid_to_hex(old_oid), + oid_to_hex(new_oid), committer, timestamp, tz, + *msg == '\n' ? "" : "\t", msg); return 0; } diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 0d4f73acaa..ef8fdcef46 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -321,8 +321,9 @@ $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150260 +0000 Switch $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000 EOF test_expect_success "verifying $m's log (logged by touch)" ' - test_when_finished "rm -rf .git/$m .git/logs expect" && - test_cmp expect .git/logs/$m + test_when_finished "git update-ref -d $m && rm -rf .git/logs actual expect" && + test-tool ref-store main for-each-reflog-ent $m >actual && + test_cmp actual expect ' test_expect_success "create $m (logged by config)" ' @@ -350,8 +351,9 @@ $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 +0000 Switch $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 +0000 EOF test_expect_success "verifying $m's log (logged by config)" ' - test_when_finished "rm -f .git/$m .git/logs/$m expect" && - test_cmp expect .git/logs/$m + test_when_finished "git update-ref -d $m && rm -rf .git/logs actual expect" && + test-tool ref-store main for-each-reflog-ent $m >actual && + test_cmp actual expect ' 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 $h_FIXED $h_MERGED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151100 +0000 commit (merge): Merged initial commit and a later commit. EOF test_expect_success 'git commit logged updates' ' - test_cmp expect .git/logs/$m + test-tool ref-store main for-each-reflog-ent $m >actual && + test_cmp expect actual ' unset h_TEST h_OTHER h_FIXED h_MERGED -- cgit v1.2.3