summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2021-07-13 16:52:52 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-07-13 16:52:52 -0700
commitd2992c6bc075e577301c629adee9880164be3027 (patch)
tree99fd1c0d556ceac989864db81ba15a3029a2d1af /t
parentMerge branch 'jk/union-merge-binary' (diff)
parentgc tests: add a test for the "pre-auto-gc" hook (diff)
downloadtgif-d2992c6bc075e577301c629adee9880164be3027.tar.xz
Merge branch 'ab/pre-auto-gc-hook-test'
Test fix. * ab/pre-auto-gc-hook-test: gc tests: add a test for the "pre-auto-gc" hook
Diffstat (limited to 't')
-rwxr-xr-xt/t6500-gc.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh
index 60d961b526..10c7ae7f09 100755
--- a/t/t6500-gc.sh
+++ b/t/t6500-gc.sh
@@ -95,6 +95,52 @@ test_expect_success 'gc --keep-largest-pack' '
)
'
+test_expect_success 'pre-auto-gc hook can stop auto gc' '
+ cat >err.expect <<-\EOF &&
+ no gc for you
+ EOF
+
+ git init pre-auto-gc-hook &&
+ (
+ cd pre-auto-gc-hook &&
+ write_script ".git/hooks/pre-auto-gc" <<-\EOF &&
+ echo >&2 no gc for you &&
+ exit 1
+ EOF
+
+ git config gc.auto 3 &&
+ git config gc.autoDetach false &&
+
+ # We need to create two object whose sha1s start with 17
+ # since this is what git gc counts. As it happens, these
+ # two blobs will do so.
+ test_commit "$(test_oid obj1)" &&
+ test_commit "$(test_oid obj2)" &&
+
+ git gc --auto >../out.actual 2>../err.actual
+ ) &&
+ test_must_be_empty out.actual &&
+ test_cmp err.expect err.actual &&
+
+ cat >err.expect <<-\EOF &&
+ will gc for you
+ Auto packing the repository for optimum performance.
+ See "git help gc" for manual housekeeping.
+ EOF
+
+ (
+ cd pre-auto-gc-hook &&
+ write_script ".git/hooks/pre-auto-gc" <<-\EOF &&
+ echo >&2 will gc for you &&
+ exit 0
+ EOF
+ git gc --auto >../out.actual 2>../err.actual
+ ) &&
+
+ test_must_be_empty out.actual &&
+ test_cmp err.expect err.actual
+'
+
test_expect_success 'auto gc with too many loose objects does not attempt to create bitmaps' '
test_config gc.auto 3 &&
test_config gc.autodetach false &&