{"thread":{"id":"60567","subject":"[PATCH 00/10] t: more compatibility fixes with reftables","startedAt":"2023-11-29T07:24:44Z","lastAt":"2023-11-30T07:06:52Z","messageCount":16,"participants":["Patrick Steinhardt","Taylor Blau"],"isPatch":true,"patchVersion":1,"patchTotal":10},"messages":[{"id":"485226","messageId":"cover.1701242407.git.ps@pks.im","threadId":"60567","inReplyTo":null,"subject":"[PATCH 00/10] t: more compatibility fixes with reftables","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2023-11-29T07:24:36Z","receivedAt":"2023-11-29T07:24:44Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis is the second patch series that refactors tests to become\ncompatible with the upcoming reftables backend. It's in the same spirit\nas the first round of patches [1], where most of the refactorings are to\nuse plumbing tools to access refs or the reflog instead of modifying\non-disk data structures directly.\n\nPatrick\n\n[1]: <cover.1697607222.git.ps@pks.im>\n\nPatrick Steinhardt (10):\n  t0410: mark tests to require the reffiles backend\n  t1400: split up generic reflog tests from the reffile-specific ones\n  t1401: stop treating FETCH_HEAD as real reference\n  t1410: use test-tool to create empty reflog\n  t1417: make `reflog --updateref` tests backend agnostic\n  t3310: stop checking for reference existence via `test -f`\n  t4013: simplify magic parsing and drop \"failure\"\n  t5401: speed up creation of many branches\n  t5551: stop writing packed-refs directly\n  t6301: write invalid object ID via `test-tool ref-store`\n\n t/t0410-partial-clone.sh              |  4 +--\n t/t1400-update-ref.sh                 | 41 +++++++++++++++++++++++----\n t/t1401-symbolic-ref.sh               |  4 +--\n t/t1410-reflog.sh                     |  4 +--\n t/t1417-reflog-updateref.sh           | 10 +++++--\n t/t3310-notes-merge-manual-resolve.sh |  6 ++--\n t/t4013-diff-various.sh               | 27 ++++++++----------\n t/t5401-update-hooks.sh               |  6 ++--\n t/t5551-http-fetch-smart.sh           |  4 ++-\n t/t6301-for-each-ref-errors.sh        | 13 ++++-----\n 10 files changed, 74 insertions(+), 45 deletions(-)\n\n-- \n2.43.0\n\n"},{"id":"485227","messageId":"53c6348035360912a9d720448dceb17895703da2.1701242407.git.ps@pks.im","threadId":"60567","inReplyTo":"cover.1701242407.git.ps@pks.im","subject":"[PATCH 01/10] t0410: mark tests to require the reffiles backend","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2023-11-29T07:24:40Z","receivedAt":"2023-11-29T07:24:51Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Two of our tests in t0410 verify whether partial clones end up with the\ncorrect repository format version and extensions. These checks require\nthe reffiles backend because every other backend would by necessity bump\nthe repository format version to be at least 1.\n\nMark the tests accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n t/t0410-partial-clone.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh\nindex 5b7bee888d..6b6424b3df 100755\n--- a/t/t0410-partial-clone.sh\n+++ b/t/t0410-partial-clone.sh\n@@ -49,7 +49,7 @@ test_expect_success 'convert shallow clone to partial clone' '\n \ttest_cmp_config -C client 1 core.repositoryformatversion\n '\n \n-test_expect_success SHA1 'convert to partial clone with noop extension' '\n+test_expect_success SHA1,REFFILES 'convert to partial clone with noop extension' '\n \trm -fr server client &&\n \ttest_create_repo server &&\n \ttest_commit -C server my_commit 1 &&\n@@ -60,7 +60,7 @@ test_expect_success SHA1 'convert to partial clone with noop extension' '\n \tgit -C client fetch --unshallow --filter=\"blob:none\"\n '\n \n-test_expect_success SHA1 'converting to partial clone fails with unrecognized extension' '\n+test_expect_success SHA1,REFFILES 'converting to partial clone fails with unrecognized extension' '\n \trm -fr server client &&\n \ttest_create_repo server &&\n \ttest_commit -C server my_commit 1 &&\n-- \n2.43.0\n\n"},{"id":"485228","messageId":"f07ddfaf2cca7f2afdfbc21319584ef68333680d.1701242407.git.ps@pks.im","threadId":"60567","inReplyTo":"cover.1701242407.git.ps@pks.im","subject":"[PATCH 02/10] t1400: split up generic reflog tests from the reffile-specific ones","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2023-11-29T07:24:44Z","receivedAt":"2023-11-29T07:24:52Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"We have a bunch of tests in t1400 that check whether we correctly read\nreflog entries. These tests create the reflog by manually writing to the\nrespective loose file, which makes them specific to the files backend.\nBut while some of them do indeed exercise very specific edge cases in\nthe reffiles backend, most of the tests exercise generic functionality\nthat should be common to all backends.\n\nUnfortunately, we can't easily adapt all of the tests to work with all\nbackends. Instead, split out the reffile-specific tests from the ones\nthat should work with all backends and refactor the generic ones to not\nwrite to the on-disk files directly anymore.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n t/t1400-update-ref.sh | 41 +++++++++++++++++++++++++++++++++++------\n 1 file changed, 35 insertions(+), 6 deletions(-)\n\ndiff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh\nindex 9ac4b7036b..c41cd9b6bf 100755\n--- a/t/t1400-update-ref.sh\n+++ b/t/t1400-update-ref.sh\n@@ -354,14 +354,28 @@ test_expect_success \"verifying $m's log (logged by config)\" '\n '\n \n test_expect_success 'set up for querying the reflog' '\n+\tgit update-ref -d $m &&\n+\ttest-tool ref-store main delete-reflog $m &&\n+\n+\tGIT_COMMITTER_DATE=\"1117150320 -0500\" git update-ref $m $C &&\n+\tGIT_COMMITTER_DATE=\"1117150350 -0500\" git update-ref $m $A &&\n+\tGIT_COMMITTER_DATE=\"1117150380 -0500\" git update-ref $m $B &&\n+\tGIT_COMMITTER_DATE=\"1117150680 -0500\" git update-ref $m $F &&\n+\tGIT_COMMITTER_DATE=\"1117150980 -0500\" git update-ref $m $E &&\n \tgit update-ref $m $D &&\n-\tcat >.git/logs/$m <<-EOF\n+\t# Delete the last reflog entry so that the tip of m and the reflog for\n+\t# it disagree.\n+\tgit reflog delete $m@{0} &&\n+\n+\tcat >expect <<-EOF &&\n \t$Z $C $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500\n \t$C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150350 -0500\n \t$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500\n-\t$F $Z $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500\n-\t$Z $E $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 -0500\n+\t$B $F $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500\n+\t$F $E $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 -0500\n \tEOF\n+\ttest-tool ref-store main for-each-reflog-ent $m >actual &&\n+\ttest_cmp expect actual\n '\n \n ed=\"Thu, 26 May 2005 18:32:00 -0500\"\n@@ -409,13 +423,12 @@ test_expect_success 'Query \"main@{2005-05-26 23:33:01}\" (middle of history with\n \ttest_when_finished \"rm -f o e\" &&\n \tgit rev-parse --verify \"main@{2005-05-26 23:33:01}\" >o 2>e &&\n \techo \"$B\" >expect &&\n-\ttest_cmp expect o &&\n-\ttest_grep -F \"warning: log for ref $m has gap after $gd\" e\n+\ttest_cmp expect o\n '\n test_expect_success 'Query \"main@{2005-05-26 23:38:00}\" (middle of history)' '\n \ttest_when_finished \"rm -f o e\" &&\n \tgit rev-parse --verify \"main@{2005-05-26 23:38:00}\" >o 2>e &&\n-\techo \"$Z\" >expect &&\n+\techo \"$F\" >expect &&\n \ttest_cmp expect o &&\n \ttest_must_be_empty e\n '\n@@ -436,6 +449,22 @@ test_expect_success 'Query \"main@{2005-05-28}\" (past end of history)' '\n \n rm -f .git/$m .git/logs/$m expect\n \n+test_expect_success REFFILES 'query reflog with gap' '\n+\ttest_when_finished \"git update-ref -d $m\" &&\n+\n+\tgit update-ref $m $F &&\n+\tcat >.git/logs/$m <<-EOF &&\n+\t$Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500\n+\t$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500\n+\t$D $F $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500\n+\tEOF\n+\n+\tgit rev-parse --verify \"main@{2005-05-26 23:33:01}\" >actual 2>stderr &&\n+\techo \"$B\" >expect &&\n+\ttest_cmp expect actual &&\n+\ttest_grep -F \"warning: log for ref $m has gap after $gd\" stderr\n+'\n+\n test_expect_success 'creating initial files' '\n \ttest_when_finished rm -f M &&\n \techo TEST >F &&\n-- \n2.43.0\n\n"},{"id":"485229","messageId":"d905952a1bcbce9f1d96d303d325849901f4af13.1701242407.git.ps@pks.im","threadId":"60567","inReplyTo":"cover.1701242407.git.ps@pks.im","subject":"[PATCH 03/10] t1401: stop treating FETCH_HEAD as real reference","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2023-11-29T07:24:49Z","receivedAt":"2023-11-29T07:24:52Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"One of the tests in t1401 asserts that we can create a symref from a\nsymbolic reference to a top-level reference, which is done by linking\nfrom `refs/heads/top-level` to `FETCH_HEAD`. But `FETCH_HEAD` is not a\nproper reference and doesn't even follow the loose reference format, so\nit is not a good candidate for the logic under test.\n\nRefactor the test to use `ORIG_HEAD` instead of `FETCH_HEAD`. This also\nworks with other backends than the reffiles one.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n t/t1401-symbolic-ref.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh\nindex c7745e1bf6..3241d35917 100755\n--- a/t/t1401-symbolic-ref.sh\n+++ b/t/t1401-symbolic-ref.sh\n@@ -171,8 +171,8 @@ test_expect_success 'symbolic-ref refuses invalid target for non-HEAD' '\n '\n \n test_expect_success 'symbolic-ref allows top-level target for non-HEAD' '\n-\tgit symbolic-ref refs/heads/top-level FETCH_HEAD &&\n-\tgit update-ref FETCH_HEAD HEAD &&\n+\tgit symbolic-ref refs/heads/top-level ORIG_HEAD &&\n+\tgit update-ref ORIG_HEAD HEAD &&\n \ttest_cmp_rev top-level HEAD\n '\n \n-- \n2.43.0\n\n"},{"id":"485230","messageId":"c06a5192aea94152639cbf7ac8d72172727b902d.1701242407.git.ps@pks.im","threadId":"60567","inReplyTo":"cover.1701242407.git.ps@pks.im","subject":"[PATCH 04/10] t1410: use test-tool to create empty reflog","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2023-11-29T07:24:53Z","receivedAt":"2023-11-29T07:24:56Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"One of the tests in t1410 is marked to be specific to the files\nreference backend, which is because we create a reflog manually by\ncreating the respective file. Refactor the test to instead use our\n`test-tool ref-store` helper to create the reflog so that it works with\nother reference backends, as well.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n t/t1410-reflog.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh\nindex aeddc2fb3f..a0ff8d51f0 100755\n--- a/t/t1410-reflog.sh\n+++ b/t/t1410-reflog.sh\n@@ -469,11 +469,11 @@ test_expect_success 'expire one of multiple worktrees' '\n \t)\n '\n \n-test_expect_success REFFILES 'empty reflog' '\n+test_expect_success 'empty reflog' '\n \ttest_when_finished \"rm -rf empty\" &&\n \tgit init empty &&\n \ttest_commit -C empty A &&\n-\t>empty/.git/logs/refs/heads/foo &&\n+\ttest-tool ref-store main create-reflog refs/heads/foo &&\n \tgit -C empty reflog expire --all 2>err &&\n \ttest_must_be_empty err\n '\n-- \n2.43.0\n\n"},{"id":"485231","messageId":"6db2f07045ae424d3b4eeb482d9608f38ef4c956.1701242407.git.ps@pks.im","threadId":"60567","inReplyTo":"cover.1701242407.git.ps@pks.im","subject":"[PATCH 05/10] t1417: make `reflog --updateref` tests backend agnostic","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2023-11-29T07:24:57Z","receivedAt":"2023-11-29T07:25:00Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The tests for `git reflog delete --updateref` are currently marked to\nonly run with the reffiles backend. There is no inherent reason that\nthis should be the case other than the fact that the setup messes with\nthe on-disk reflogs directly.\n\nRefactor the test to stop doing so and drop the REFFILES prerequisite.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n t/t1417-reflog-updateref.sh | 10 +++++++---\n 1 file changed, 7 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t1417-reflog-updateref.sh b/t/t1417-reflog-updateref.sh\nindex 14f13b57c6..0eb5e674bc 100755\n--- a/t/t1417-reflog-updateref.sh\n+++ b/t/t1417-reflog-updateref.sh\n@@ -14,9 +14,13 @@ test_expect_success 'setup' '\n \t\ttest_commit B &&\n \t\ttest_commit C &&\n \n-\t\tcp .git/logs/HEAD HEAD.old &&\n+\t\tgit reflog HEAD >expect &&\n \t\tgit reset --hard HEAD~ &&\n-\t\tcp HEAD.old .git/logs/HEAD\n+\t\t# Make sure that the reflog does not point to the same commit\n+\t\t# as HEAD.\n+\t\tgit reflog delete HEAD@{0} &&\n+\t\tgit reflog HEAD >actual &&\n+\t\ttest_cmp expect actual\n \t)\n '\n \n@@ -25,7 +29,7 @@ test_reflog_updateref () {\n \tshift\n \targs=\"$@\"\n \n-\ttest_expect_success REFFILES \"get '$exp' with '$args'\"  '\n+\ttest_expect_success \"get '$exp' with '$args'\"  '\n \t\ttest_when_finished \"rm -rf copy\" &&\n \t\tcp -R repo copy &&\n \n-- \n2.43.0\n\n"},{"id":"485232","messageId":"58c1f0ba47110fd452d83cb6f72871abd7891c3a.1701242407.git.ps@pks.im","threadId":"60567","inReplyTo":"cover.1701242407.git.ps@pks.im","subject":"[PATCH 06/10] t3310: stop checking for reference existence via `test -f`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2023-11-29T07:25:01Z","receivedAt":"2023-11-29T07:25:04Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"One of the tests in t3310 exercises whether the special references\n`NOTES_MERGE_PARTIAL` and `NOTES_MERGE_REF` exist as expected when the\nnotes subsystem runs into a merge conflict. This is done by checking\non-disk data structures directly though instead of asking the reference\nbackend.\n\nRefactor the test to use git-rev-parse(1) instead.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n t/t3310-notes-merge-manual-resolve.sh | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t3310-notes-merge-manual-resolve.sh b/t/t3310-notes-merge-manual-resolve.sh\nindex 60d6ed2dc8..597df5ebc0 100755\n--- a/t/t3310-notes-merge-manual-resolve.sh\n+++ b/t/t3310-notes-merge-manual-resolve.sh\n@@ -561,9 +561,9 @@ y and z notes on 4th commit\n EOF\n \t# Fail to finalize merge\n \ttest_must_fail git notes merge --commit >output 2>&1 &&\n-\t# .git/NOTES_MERGE_* must remain\n-\ttest -f .git/NOTES_MERGE_PARTIAL &&\n-\ttest -f .git/NOTES_MERGE_REF &&\n+\t# NOTES_MERGE_* refs and .git/NOTES_MERGE_* state files must remain\n+\tgit rev-parse --verify NOTES_MERGE_PARTIAL &&\n+\tgit rev-parse --verify NOTES_MERGE_REF &&\n \ttest -f .git/NOTES_MERGE_WORKTREE/$commit_sha1 &&\n \ttest -f .git/NOTES_MERGE_WORKTREE/$commit_sha2 &&\n \ttest -f .git/NOTES_MERGE_WORKTREE/$commit_sha3 &&\n-- \n2.43.0\n\n"},{"id":"485233","messageId":"3b16c2cd7bd66c0eb56d33a6b91914500a1c24dd.1701242407.git.ps@pks.im","threadId":"60567","inReplyTo":"cover.1701242407.git.ps@pks.im","subject":"[PATCH 07/10] t4013: simplify magic parsing and drop \"failure\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2023-11-29T07:25:05Z","receivedAt":"2023-11-29T07:25:09Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"In t14013, we have various different tests that verify whether certain\ndiffs are generated as expected. As much of the logic is the same across\nmany of the tests we some common code in there that generates the actual\ntest cases for us.\n\nAs some diffs are more special than others depending on the command line\nparameters passed to git-diff(1), these tests need to adapt behaviour to\nthe specific test case sometimes. This is done via colon-prefixed magic\ncommands, of which we currently know \"failure\" and \"noellipses\". The\nlogic to parse this magic is a bit convoluted though and hard to grasp,\nalso due to the rather unnecessary nesting.\n\nUn-nest the cases so that it becomes a bit more straightfoward. The\nlogic is further simplified by removing support for the \"failure\" magic,\nwhich is not actually used anymore.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n t/t4013-diff-various.sh | 27 ++++++++++++---------------\n 1 file changed, 12 insertions(+), 15 deletions(-)\n\ndiff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh\nindex 5cc17c2e0d..76b8619e2e 100755\n--- a/t/t4013-diff-various.sh\n+++ b/t/t4013-diff-various.sh\n@@ -178,32 +178,29 @@ process_diffs () {\n V=$(git version | sed -e 's/^git version //' -e 's/\\./\\\\./g')\n while read magic cmd\n do\n-\tstatus=success\n \tcase \"$magic\" in\n \t'' | '#'*)\n \t\tcontinue ;;\n-\t:*)\n-\t\tmagic=${magic#:}\n+\t:noellipses)\n+\t\tmagic=noellipses\n \t\tlabel=\"$magic-$cmd\"\n-\t\tcase \"$magic\" in\n-\t\tnoellipses) ;;\n-\t\tfailure)\n-\t\t\tstatus=failure\n-\t\t\tmagic=\n-\t\t\tlabel=\"$cmd\" ;;\n-\t\t*)\n-\t\t\tBUG \"unknown magic $magic\" ;;\n-\t\tesac ;;\n+\t\t;;\n+\t:*)\n+\t\tBUG \"unknown magic $magic\"\n+\t\t;;\n \t*)\n-\t\tcmd=\"$magic $cmd\" magic=\n-\t\tlabel=\"$cmd\" ;;\n+\t\tcmd=\"$magic $cmd\"\n+\t\tmagic=\n+\t\tlabel=\"$cmd\"\n+\t\t;;\n \tesac\n+\n \ttest=$(echo \"$label\" | sed -e 's|[/ ][/ ]*|_|g')\n \tpfx=$(printf \"%04d\" $test_count)\n \texpect=\"$TEST_DIRECTORY/t4013/diff.$test\"\n \tactual=\"$pfx-diff.$test\"\n \n-\ttest_expect_$status \"git $cmd # magic is ${magic:-(not used)}\" '\n+\ttest_expect_success \"git $cmd # magic is ${magic:-(not used)}\" '\n \t\t{\n \t\t\techo \"$ git $cmd\"\n \t\t\tcase \"$magic\" in\n-- \n2.43.0\n\n"},{"id":"485234","messageId":"f674119c7801e355cd08a651450abd67947d7456.1701242407.git.ps@pks.im","threadId":"60567","inReplyTo":"cover.1701242407.git.ps@pks.im","subject":"[PATCH 08/10] t5401: speed up creation of many branches","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2023-11-29T07:25:09Z","receivedAt":"2023-11-29T07:25:13Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"One of the tests in t5401 creates a bunch of branches by calling\ngit-branch(1) for every one of them. This is quite inefficient and takes\na comparatively long time even on Unix systems where spawning processes\nis comparatively fast. Refactor it to instead use git-update-ref(1),\nwhich leads to an almost 10-fold speedup:\n\n```\nBenchmark 1: ./t5401-update-hooks.sh (rev = HEAD)\n  Time (mean ± σ):     983.2 ms ±  97.6 ms    [User: 328.8 ms, System: 679.2 ms]\n  Range (min … max):   882.9 ms … 1078.0 ms    3 runs\n\nBenchmark 2: ./t5401-update-hooks.sh (rev = HEAD~)\n  Time (mean ± σ):      9.312 s ±  0.398 s    [User: 2.766 s, System: 6.617 s]\n  Range (min … max):    8.885 s …  9.674 s    3 runs\n\nSummary\n  ./t5401-update-hooks.sh (rev = HEAD) ran\n    9.47 ± 1.02 times faster than ./t5401-update-hooks.sh (rev = HEAD~)\n```\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n t/t5401-update-hooks.sh | 6 ++----\n 1 file changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh\nindex 001b7a17ad..8b8bc47dc0 100755\n--- a/t/t5401-update-hooks.sh\n+++ b/t/t5401-update-hooks.sh\n@@ -133,10 +133,8 @@ test_expect_success 'pre-receive hook that forgets to read its input' '\n \tEOF\n \trm -f victim.git/hooks/update victim.git/hooks/post-update &&\n \n-\tfor v in $(test_seq 100 999)\n-\tdo\n-\t\tgit branch branch_$v main || return\n-\tdone &&\n+\tprintf \"create refs/heads/branch_%d main\\n\" $(test_seq 100 999) >input &&\n+\tgit update-ref --stdin <input &&\n \tgit push ./victim.git \"+refs/heads/*:refs/heads/*\"\n '\n \n-- \n2.43.0\n\n"},{"id":"485235","messageId":"2ab24ea5633be6b4855567d126a184d54c624f62.1701242407.git.ps@pks.im","threadId":"60567","inReplyTo":"cover.1701242407.git.ps@pks.im","subject":"[PATCH 09/10] t5551: stop writing packed-refs directly","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2023-11-29T07:25:14Z","receivedAt":"2023-11-29T07:25:16Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"We have multiple tests in t5551 that write thousands of tags. To do so\nefficiently we generate the tags by writing the `packed-refs` file\ndirectly, which of course assumes that the reference database is backed\nby the files backend.\n\nRefactor the code to instead use a single `git update-ref --stdin`\ncommand to write the tags. While the on-disk end result is not the same\nas we now have a bunch of loose refs instead of a single packed-refs\nfile, the distinction shouldn't really matter for any of the tests that\nuse this helper.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n t/t5551-http-fetch-smart.sh | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh\nindex 8a41adf1e1..e069737b80 100755\n--- a/t/t5551-http-fetch-smart.sh\n+++ b/t/t5551-http-fetch-smart.sh\n@@ -359,7 +359,9 @@ create_tags () {\n \n \t# now assign tags to all the dangling commits we created above\n \ttag=$(perl -e \"print \\\"bla\\\" x 30\") &&\n-\tsed -e \"s|^:\\([^ ]*\\) \\(.*\\)$|\\2 refs/tags/$tag-\\1|\" <marks >>packed-refs\n+\tsed -e \"s|^:\\([^ ]*\\) \\(.*\\)$|create refs/tags/$tag-\\1 \\2|\" <marks >input &&\n+\tgit update-ref --stdin <input &&\n+\trm input\n }\n \n test_expect_success 'create 2,000 tags in the repo' '\n-- \n2.43.0\n\n"},{"id":"485236","messageId":"281d9a719d39c03572de53bce5388acc7236b274.1701242407.git.ps@pks.im","threadId":"60567","inReplyTo":"cover.1701242407.git.ps@pks.im","subject":"[PATCH 10/10] t6301: write invalid object ID via `test-tool ref-store`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2023-11-29T07:25:18Z","receivedAt":"2023-11-29T07:25:21Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"One of the tests in t6301 verifies that the reference backend correctly\nwarns about the case where a reference points to a non-existent object.\nThis is done by writing the object ID into the loose reference directly,\nwhich is quite intimate with how the files backend works.\n\nRefactor the code to instead use `test-tool ref-store` to write the\nreference, which is backend-agnostic.\n\nThere are two more tests in this file which write loose files directly,\nas well. But both of them are indeed quite specific to the loose files\nbackend and cannot be easily ported to other backends. We thus mark them\nas requiring the REFFILES prerequisite.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n t/t6301-for-each-ref-errors.sh | 13 ++++++-------\n 1 file changed, 6 insertions(+), 7 deletions(-)\n\ndiff --git a/t/t6301-for-each-ref-errors.sh b/t/t6301-for-each-ref-errors.sh\nindex 2667dd13fe..83b8a19d94 100755\n--- a/t/t6301-for-each-ref-errors.sh\n+++ b/t/t6301-for-each-ref-errors.sh\n@@ -15,7 +15,7 @@ test_expect_success setup '\n \tgit for-each-ref --format=\"%(objectname) %(refname)\" >brief-list\n '\n \n-test_expect_success 'Broken refs are reported correctly' '\n+test_expect_success REFFILES 'Broken refs are reported correctly' '\n \tr=refs/heads/bogus &&\n \t: >.git/$r &&\n \ttest_when_finished \"rm -f .git/$r\" &&\n@@ -25,7 +25,7 @@ test_expect_success 'Broken refs are reported correctly' '\n \ttest_cmp broken-err err\n '\n \n-test_expect_success 'NULL_SHA1 refs are reported correctly' '\n+test_expect_success REFFILES 'NULL_SHA1 refs are reported correctly' '\n \tr=refs/heads/zeros &&\n \techo $ZEROS >.git/$r &&\n \ttest_when_finished \"rm -f .git/$r\" &&\n@@ -39,15 +39,14 @@ test_expect_success 'NULL_SHA1 refs are reported correctly' '\n '\n \n test_expect_success 'Missing objects are reported correctly' '\n-\tr=refs/heads/missing &&\n-\techo $MISSING >.git/$r &&\n-\ttest_when_finished \"rm -f .git/$r\" &&\n-\techo \"fatal: missing object $MISSING for $r\" >missing-err &&\n+\ttest_when_finished \"git update-ref -d refs/heads/missing\" &&\n+\ttest-tool ref-store main update-ref msg refs/heads/missing \"$MISSING\" \"$ZERO_OID\" REF_SKIP_OID_VERIFICATION &&\n+\techo \"fatal: missing object $MISSING for refs/heads/missing\" >missing-err &&\n \ttest_must_fail git for-each-ref 2>err &&\n \ttest_cmp missing-err err &&\n \t(\n \t\tcat brief-list &&\n-\t\techo \"$MISSING $r\"\n+\t\techo \"$MISSING refs/heads/missing\"\n \t) | sort -k 2 >missing-brief-expected &&\n \tgit for-each-ref --format=\"%(objectname) %(refname)\" >brief-out 2>brief-err &&\n \ttest_cmp missing-brief-expected brief-out &&\n-- \n2.43.0\n\n"},{"id":"485250","messageId":"ZWe44hBxBCX50TIs@nand.local","threadId":"60567","inReplyTo":"53c6348035360912a9d720448dceb17895703da2.1701242407.git.ps@pks.im","subject":"Re: [PATCH 01/10] t0410: mark tests to require the reffiles backend","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2023-11-29T22:19:14Z","receivedAt":"2023-11-29T22:19:16Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Wed, Nov 29, 2023 at 08:24:40AM +0100, Patrick Steinhardt wrote:\n> Two of our tests in t0410 verify whether partial clones end up with the\n> correct repository format version and extensions. These checks require\n> the reffiles backend because every other backend would by necessity bump\n> the repository format version to be at least 1.\n>\n> Mark the tests accordingly.\n>\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  t/t0410-partial-clone.sh | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh\n> index 5b7bee888d..6b6424b3df 100755\n> --- a/t/t0410-partial-clone.sh\n> +++ b/t/t0410-partial-clone.sh\n> @@ -49,7 +49,7 @@ test_expect_success 'convert shallow clone to partial clone' '\n>  \ttest_cmp_config -C client 1 core.repositoryformatversion\n>  '\n>\n> -test_expect_success SHA1 'convert to partial clone with noop extension' '\n> +test_expect_success SHA1,REFFILES 'convert to partial clone with noop extension' '\n\nI thought for a second that the SHA1 prerequisite would cover this\nalready, but that's not right since you can be in SHA1 mode even if your\nrepositoryformatversion is 1. So this change makes sense to me and is\nwell-reasoned.\n\nThanks,\nTaylor\n"},{"id":"485252","messageId":"ZWe6VDZqW8zCzMNJ@nand.local","threadId":"60567","inReplyTo":"f674119c7801e355cd08a651450abd67947d7456.1701242407.git.ps@pks.im","subject":"Re: [PATCH 08/10] t5401: speed up creation of many branches","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2023-11-29T22:25:24Z","receivedAt":"2023-11-29T22:25:26Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Wed, Nov 29, 2023 at 08:25:09AM +0100, Patrick Steinhardt wrote:\n> One of the tests in t5401 creates a bunch of branches by calling\n> git-branch(1) for every one of them. This is quite inefficient and takes\n> a comparatively long time even on Unix systems where spawning processes\n> is comparatively fast. Refactor it to instead use git-update-ref(1),\n> which leads to an almost 10-fold speedup:\n>\n> ```\n> Benchmark 1: ./t5401-update-hooks.sh (rev = HEAD)\n>   Time (mean ± σ):     983.2 ms ±  97.6 ms    [User: 328.8 ms, System: 679.2 ms]\n>   Range (min … max):   882.9 ms … 1078.0 ms    3 runs\n>\n> Benchmark 2: ./t5401-update-hooks.sh (rev = HEAD~)\n>   Time (mean ± σ):      9.312 s ±  0.398 s    [User: 2.766 s, System: 6.617 s]\n>   Range (min … max):    8.885 s …  9.674 s    3 runs\n>\n> Summary\n>   ./t5401-update-hooks.sh (rev = HEAD) ran\n>     9.47 ± 1.02 times faster than ./t5401-update-hooks.sh (rev = HEAD~)\n\nVery nice ;-).\n\n> diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh\n> index 001b7a17ad..8b8bc47dc0 100755\n> --- a/t/t5401-update-hooks.sh\n> +++ b/t/t5401-update-hooks.sh\n> @@ -133,10 +133,8 @@ test_expect_success 'pre-receive hook that forgets to read its input' '\n>  \tEOF\n>  \trm -f victim.git/hooks/update victim.git/hooks/post-update &&\n>\n> -\tfor v in $(test_seq 100 999)\n> -\tdo\n> -\t\tgit branch branch_$v main || return\n> -\tdone &&\n> +\tprintf \"create refs/heads/branch_%d main\\n\" $(test_seq 100 999) >input &&\n> +\tgit update-ref --stdin <input &&\n\nNot that it really matters here, but you could pipe the output of your\nprintf directly into git update-ref. I don't think we rely on the value\nof \"input\" after this point, and git is on the right-hand side of the\npipe, so this is safe to do.\n\nBut it doesn't matter much either way, just something I noticed while\nreading.\n\nThanks,\nTaylor\n"},{"id":"485251","messageId":"ZWe6goJHliFZrOAZ@nand.local","threadId":"60567","inReplyTo":"2ab24ea5633be6b4855567d126a184d54c624f62.1701242407.git.ps@pks.im","subject":"Re: [PATCH 09/10] t5551: stop writing packed-refs directly","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2023-11-29T22:26:10Z","receivedAt":"2023-11-29T22:26:12Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Wed, Nov 29, 2023 at 08:25:14AM +0100, Patrick Steinhardt wrote:\n> We have multiple tests in t5551 that write thousands of tags. To do so\n> efficiently we generate the tags by writing the `packed-refs` file\n> directly, which of course assumes that the reference database is backed\n> by the files backend.\n>\n> Refactor the code to instead use a single `git update-ref --stdin`\n> command to write the tags. While the on-disk end result is not the same\n> as we now have a bunch of loose refs instead of a single packed-refs\n> file, the distinction shouldn't really matter for any of the tests that\n> use this helper.\n>\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  t/t5551-http-fetch-smart.sh | 4 +++-\n>  1 file changed, 3 insertions(+), 1 deletion(-)\n>\n> diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh\n> index 8a41adf1e1..e069737b80 100755\n> --- a/t/t5551-http-fetch-smart.sh\n> +++ b/t/t5551-http-fetch-smart.sh\n> @@ -359,7 +359,9 @@ create_tags () {\n>\n>  \t# now assign tags to all the dangling commits we created above\n>  \ttag=$(perl -e \"print \\\"bla\\\" x 30\") &&\n> -\tsed -e \"s|^:\\([^ ]*\\) \\(.*\\)$|\\2 refs/tags/$tag-\\1|\" <marks >>packed-refs\n> +\tsed -e \"s|^:\\([^ ]*\\) \\(.*\\)$|create refs/tags/$tag-\\1 \\2|\" <marks >input &&\n> +\tgit update-ref --stdin <input &&\n> +\trm input\n\nSame note here as in the previous patch, although here I think we'd\nprefer to pipe from sed to git update-ref directly, rather than writing\nan intermediate file which we have to clean up afterwords.\n\nThanks,\nTaylor\n"},{"id":"485253","messageId":"ZWfJp80vzVhbdH89@nand.local","threadId":"60567","inReplyTo":"cover.1701242407.git.ps@pks.im","subject":"Re: [PATCH 00/10] t: more compatibility fixes with reftables","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2023-11-29T23:30:47Z","receivedAt":"2023-11-29T23:30:49Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Wed, Nov 29, 2023 at 08:24:36AM +0100, Patrick Steinhardt wrote:\n> Hi,\n>\n> this is the second patch series that refactors tests to become\n> compatible with the upcoming reftables backend. It's in the same spirit\n> as the first round of patches [1], where most of the refactorings are to\n> use plumbing tools to access refs or the reflog instead of modifying\n> on-disk data structures directly.\n\nAll looks good to me. Thanks for a pleasant read :-).\n\nThanks,\nTaylor\n"},{"id":"485255","messageId":"ZWg0hJNsIR---SVI@tanuki","threadId":"60567","inReplyTo":"ZWfJp80vzVhbdH89@nand.local","subject":"Re: [PATCH 00/10] t: more compatibility fixes with reftables","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2023-11-30T07:06:44Z","receivedAt":"2023-11-30T07:06:52Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Nov 29, 2023 at 06:30:47PM -0500, Taylor Blau wrote:\n> On Wed, Nov 29, 2023 at 08:24:36AM +0100, Patrick Steinhardt wrote:\n> > Hi,\n> >\n> > this is the second patch series that refactors tests to become\n> > compatible with the upcoming reftables backend. It's in the same spirit\n> > as the first round of patches [1], where most of the refactorings are to\n> > use plumbing tools to access refs or the reflog instead of modifying\n> > on-disk data structures directly.\n> \n> All looks good to me. Thanks for a pleasant read :-).\n> \n> Thanks,\n> Taylor\n\nIf you don't mind, I'll refrain from sending a v2 only to start piping\noutput into git-update-ref(1) directly. I'll incorporate that feedback\nthough if there is a need for v2 due to other reasons.\n\nThanks for your review!\n\nPatrick\n"}]}