Message ID | 62f5cb8a8243f9e5c2af5c148ed586a2504c8cee.1637855872.git.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Inspect reflog data programmatically in more tests | expand |
"Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com> writes: > - 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); So, we used to show the timezone as an integer casually, but now we make sure we use the +/- prefix, with 0 filled 4 digits, that is consistent with how we record the tz in different places (like the low-level object header, or the user-visible header lines in commit and tag objects). > return 0; > } > > diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh > index 0d4f73acaa8..0d46a488032 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 && micronit: lose SP between redirection '>' and its target 'actual'. > + test_cmp actual expect And the +0000 will be checked by comparing with "expect" file. Nice. > ' > > 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 && Ditto. > + 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 && This one is good. > + test_cmp expect actual > ' > unset h_TEST h_OTHER h_FIXED h_MERGED Thanks.
diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index ef244aa6b27..2b13d09a0be 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -151,8 +151,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 0d4f73acaa8..0d46a488032 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