t0601: merge tests for auto-packing of refs

We have two tests in t0601 which exercise the same underlying logic, once via `git pack-refs --auto` and once via `git maintenance run --auto`. Merge these two tests into one such that it becomes easier to extend test coverage for both commands at the same time. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Sep 4, 2024 at 10:53 UTC bd51dca36e0afcff36789bd6eb0135ebe66fcd81
1 file changed +20 -16
t/t0601-reffiles-pack-refs.sh
+20 -16
@@ -161,13 +161,6 @@ test_expect_success 'test --exclude takes precedence over --include' '
161 git pack-refs --include "refs/heads/pack*" --exclude "refs/heads/pack*" &&
162 test -f .git/refs/heads/dont_pack5'
163
164 -test_expect_success '--auto packs and prunes refs as usual' '
165 - git branch auto &&
166 - test_path_is_file .git/refs/heads/auto &&
167 - git pack-refs --auto --all &&
168 - test_path_is_missing .git/refs/heads/auto
169 -'
170 -
164 test_expect_success 'see if up-to-date packed refs are preserved' '
165 git branch q &&
166 git pack-refs --all --prune &&
@@ -367,14 +360,25 @@ test_expect_success 'pack-refs does not drop broken refs during deletion' '
360 test_cmp expect actual
361 '
362
370 -test_expect_success 'maintenance --auto unconditionally packs loose refs' '
371 - git update-ref refs/heads/something HEAD &&
372 - test_path_is_file .git/refs/heads/something &&
373 - git rev-parse refs/heads/something >expect &&
374 - git maintenance run --task=pack-refs --auto &&
375 - test_path_is_missing .git/refs/heads/something &&
376 - git rev-parse refs/heads/something >actual &&
377 - test_cmp expect actual
378 -'
363 +for command in "git pack-refs --all --auto" "git maintenance run --task=pack-refs --auto"
364 +do
365 + test_expect_success "$command unconditionally packs loose refs" '
366 + test_when_finished "rm -rf repo" &&
367 + git init repo &&
368 + (
369 + cd repo &&
370 + git config set maintenance.auto false &&
371 + test_commit initial &&
372 +
373 + git update-ref refs/heads/something HEAD &&
374 + test_path_is_file .git/refs/heads/something &&
375 + git rev-parse refs/heads/something >expect &&
376 + $command &&
377 + test_path_is_missing .git/refs/heads/something &&
378 + git rev-parse refs/heads/something >actual &&
379 + test_cmp expect actual
380 + )
381 + '
382 +done
383
384 test_done