@@ -95,6 +95,52 @@ test_expect_success 'gc --keep-largest-pack' '
95
95
)
96
96
'
97
97
98
+ test_expect_success ' pre-auto-gc hook can stop auto gc' '
99
+ cat >err.expect <<-\EOF &&
100
+ no gc for you
101
+ EOF
102
+
103
+ git init pre-auto-gc-hook &&
104
+ (
105
+ cd pre-auto-gc-hook &&
106
+ write_script ".git/hooks/pre-auto-gc" <<-\EOF &&
107
+ echo >&2 no gc for you &&
108
+ exit 1
109
+ EOF
110
+
111
+ git config gc.auto 3 &&
112
+ git config gc.autoDetach false &&
113
+
114
+ # We need to create two object whose sha1s start with 17
115
+ # since this is what git gc counts. As it happens, these
116
+ # two blobs will do so.
117
+ test_commit "$(test_oid obj1)" &&
118
+ test_commit "$(test_oid obj2)" &&
119
+
120
+ git gc --auto >../out.actual 2>../err.actual
121
+ ) &&
122
+ test_must_be_empty out.actual &&
123
+ test_cmp err.expect err.actual &&
124
+
125
+ cat >err.expect <<-\EOF &&
126
+ will gc for you
127
+ Auto packing the repository for optimum performance.
128
+ See "git help gc" for manual housekeeping.
129
+ EOF
130
+
131
+ (
132
+ cd pre-auto-gc-hook &&
133
+ write_script ".git/hooks/pre-auto-gc" <<-\EOF &&
134
+ echo >&2 will gc for you &&
135
+ exit 0
136
+ EOF
137
+ git gc --auto >../out.actual 2>../err.actual
138
+ ) &&
139
+
140
+ test_must_be_empty out.actual &&
141
+ test_cmp err.expect err.actual
142
+ '
143
+
98
144
test_expect_success ' auto gc with too many loose objects does not attempt to create bitmaps' '
99
145
test_config gc.auto 3 &&
100
146
test_config gc.autodetach false &&
0 commit comments