@@ -202,6 +202,102 @@ test_expect_success 'one of gc.reflogExpire{Unreachable,}=never does not skip "e
202202 grep -E "^trace: (built-in|exec|run_command): git reflog expire --" trace.out
203203'
204204
205+ prepare_cruft_history () {
206+ test_commit base &&
207+
208+ test_commit --no-tag foo &&
209+ test_commit --no-tag bar &&
210+ git reset HEAD^^
211+ }
212+
213+ assert_cruft_packs () {
214+ find .git/objects/pack -name " *.mtimes" > mtimes &&
215+ sed -e ' s/\.mtimes$/\.pack/g' mtimes > packs &&
216+
217+ test_file_not_empty packs &&
218+ while read pack
219+ do
220+ test_path_is_file " $pack " || return 1
221+ done < packs
222+ }
223+
224+ assert_no_cruft_packs () {
225+ find .git/objects/pack -name " *.mtimes" > mtimes &&
226+ test_must_be_empty mtimes
227+ }
228+
229+ test_expect_success ' gc --cruft generates a cruft pack' '
230+ test_when_finished "rm -fr crufts" &&
231+ git init crufts &&
232+ (
233+ cd crufts &&
234+
235+ prepare_cruft_history &&
236+ git gc --cruft &&
237+ assert_cruft_packs
238+ )
239+ '
240+
241+ test_expect_success ' gc.cruftPacks=true generates a cruft pack' '
242+ test_when_finished "rm -fr crufts" &&
243+ git init crufts &&
244+ (
245+ cd crufts &&
246+
247+ prepare_cruft_history &&
248+ git -c gc.cruftPacks=true gc &&
249+ assert_cruft_packs
250+ )
251+ '
252+
253+ test_expect_success ' feature.experimental=true generates a cruft pack' '
254+ git init crufts &&
255+ test_when_finished "rm -fr crufts" &&
256+ (
257+ cd crufts &&
258+
259+ prepare_cruft_history &&
260+ git -c feature.experimental=true gc &&
261+ assert_cruft_packs
262+ )
263+ '
264+
265+ test_expect_success ' feature.experimental=false allows explicit cruft packs' '
266+ git init crufts &&
267+ test_when_finished "rm -fr crufts" &&
268+ (
269+ cd crufts &&
270+
271+ prepare_cruft_history &&
272+ git -c gc.cruftPacks=true -c feature.experimental=false gc &&
273+ assert_cruft_packs
274+ )
275+ '
276+
277+ test_expect_success ' feature.experimental=true can be overridden' '
278+ git init crufts &&
279+ test_when_finished "rm -fr crufts" &&
280+ (
281+ cd crufts &&
282+
283+ prepare_cruft_history &&
284+ git -c feature.expiremental=true -c gc.cruftPacks=false gc &&
285+ assert_no_cruft_packs
286+ )
287+ '
288+
289+ test_expect_success ' feature.experimental=false avoids cruft packs by default' '
290+ git init crufts &&
291+ test_when_finished "rm -fr crufts" &&
292+ (
293+ cd crufts &&
294+
295+ prepare_cruft_history &&
296+ git -c feature.experimental=false gc &&
297+ assert_no_cruft_packs
298+ )
299+ '
300+
205301run_and_wait_for_auto_gc () {
206302 # We read stdout from gc for the side effect of waiting until the
207303 # background gc process exits, closing its fd 9. Furthermore, the
0 commit comments