{"thread":{"id":"55924","subject":"[PATCH] gc tests: add a test for the \"pre-auto-gc\" hook","startedAt":"2021-06-14T10:46:29Z","lastAt":"2021-06-14T10:46:29Z","messageCount":1,"participants":["Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"427316","messageId":"patch-1.1-17f520ad5ac-20210614T103814Z-avarab@gmail.com","threadId":"55924","inReplyTo":null,"subject":"[PATCH] gc tests: add a test for the \"pre-auto-gc\" hook","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-06-14T10:39:25Z","receivedAt":"2021-06-14T10:46:29Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a missing test for the behavior of the pre-auto-gc hook added in\n0b85d92661e (Documentation/hooks: add pre-auto-gc hook, 2008-04-02).\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n\nA missing pre-auto-gc test that the in-flight hook refactoring\ntopic(s) benefit from. Split off from v2 of my\nhttps://lore.kernel.org/git/cover-00.30-00000000000-20210614T101920Z-avarab@gmail.com/\n\n t/t6500-gc.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 46 insertions(+)\n\ndiff --git a/t/t6500-gc.sh b/t/t6500-gc.sh\nindex 60d961b5260..10c7ae7f09c 100755\n--- a/t/t6500-gc.sh\n+++ b/t/t6500-gc.sh\n@@ -95,6 +95,52 @@ test_expect_success 'gc --keep-largest-pack' '\n \t)\n '\n \n+test_expect_success 'pre-auto-gc hook can stop auto gc' '\n+\tcat >err.expect <<-\\EOF &&\n+\tno gc for you\n+\tEOF\n+\n+\tgit init pre-auto-gc-hook &&\n+\t(\n+\t\tcd pre-auto-gc-hook &&\n+\t\twrite_script \".git/hooks/pre-auto-gc\" <<-\\EOF &&\n+\t\techo >&2 no gc for you &&\n+\t\texit 1\n+\t\tEOF\n+\n+\t\tgit config gc.auto 3 &&\n+\t\tgit config gc.autoDetach false &&\n+\n+\t\t# We need to create two object whose sha1s start with 17\n+\t\t# since this is what git gc counts.  As it happens, these\n+\t\t# two blobs will do so.\n+\t\ttest_commit \"$(test_oid obj1)\" &&\n+\t\ttest_commit \"$(test_oid obj2)\" &&\n+\n+\t\tgit gc --auto >../out.actual 2>../err.actual\n+\t) &&\n+\ttest_must_be_empty out.actual &&\n+\ttest_cmp err.expect err.actual &&\n+\n+\tcat >err.expect <<-\\EOF &&\n+\twill gc for you\n+\tAuto packing the repository for optimum performance.\n+\tSee \"git help gc\" for manual housekeeping.\n+\tEOF\n+\n+\t(\n+\t\tcd pre-auto-gc-hook &&\n+\t\twrite_script \".git/hooks/pre-auto-gc\" <<-\\EOF &&\n+\t\techo >&2 will gc for you &&\n+\t\texit 0\n+\t\tEOF\n+\t\tgit gc --auto >../out.actual 2>../err.actual\n+\t) &&\n+\n+\ttest_must_be_empty out.actual &&\n+\ttest_cmp err.expect err.actual\n+'\n+\n test_expect_success 'auto gc with too many loose objects does not attempt to create bitmaps' '\n \ttest_config gc.auto 3 &&\n \ttest_config gc.autodetach false &&\n-- \n2.32.0.rc3.434.gd8aed1f08a7\n\n"}]}