git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] t0601: merge tests for auto-packing of refs

From
Patrick Steinhardt <ps@pks.im>
Date
Sep 2, 2024, 13:48 UTC
Message-ID
<3a8063e8b2c05315a5cbe8159a6acae43c12d39c.1725280479.git.ps@pks.im>
In-Reply-To
<cover.1725280479.git.ps@pks.im>

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>
---
 t/t0601-reffiles-pack-refs.sh | 36 +++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/t/t0601-reffiles-pack-refs.sh b/t/t0601-reffiles-pack-refs.sh
index 60a544b8ee8..ed9652bb829 100755
--- a/t/t0601-reffiles-pack-refs.sh
+++ b/t/t0601-reffiles-pack-refs.sh
@@ -161,13 +161,6 @@ test_expect_success 'test --exclude takes precedence over --include' '
 	git pack-refs --include "refs/heads/pack*" --exclude "refs/heads/pack*" &&
 	test -f .git/refs/heads/dont_pack5'
 
-test_expect_success '--auto packs and prunes refs as usual' '
-	git branch auto &&
-	test_path_is_file .git/refs/heads/auto &&
-	git pack-refs --auto --all &&
-	test_path_is_missing .git/refs/heads/auto
-'
-
 test_expect_success 'see if up-to-date packed refs are preserved' '
 	git branch q &&
 	git pack-refs --all --prune &&
@@ -367,14 +360,25 @@ test_expect_success 'pack-refs does not drop broken refs during deletion' '
 	test_cmp expect actual
 '
 
-test_expect_success 'maintenance --auto unconditionally packs loose refs' '
-	git update-ref refs/heads/something HEAD &&
-	test_path_is_file .git/refs/heads/something &&
-	git rev-parse refs/heads/something >expect &&
-	git maintenance run --task=pack-refs --auto &&
-	test_path_is_missing .git/refs/heads/something &&
-	git rev-parse refs/heads/something >actual &&
-	test_cmp expect actual
-'
+for command in "git pack-refs --all --auto" "git maintenance run --task=pack-refs --auto"
+do
+	test_expect_success "$command unconditionally packs loose refs" '
+		test_when_finished "rm -rf repo" &&
+		git init repo &&
+		(
+			cd repo &&
+			git config set maintenance.auto false &&
+			test_commit initial &&
+
+			git update-ref refs/heads/something HEAD &&
+			test_path_is_file .git/refs/heads/something &&
+			git rev-parse refs/heads/something >expect &&
+			$command &&
+			test_path_is_missing .git/refs/heads/something &&
+			git rev-parse refs/heads/something >actual &&
+			test_cmp expect actual
+		)
+	'
+done
 
 test_done
-- 
2.46.0.421.g159f2d50e7.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 2 of 16 in “refs/files: use heuristic to decide whether to repack with `--auto`”
  1. 0/2 refs/files: use heuristic to decide whether to repack with `--auto`Patrick Steinhardt, Sep 2, 2024
  2. 1/2 t0601: merge tests for auto-packing of refsPatrick Steinhardt, Sep 2, 2024
  3. 2/2 refs/files: use heuristic to decide whether to repack with `--auto`Patrick Steinhardt, Sep 2, 2024
  4. karthik nayakSep 3, 2024
  5. Patrick SteinhardtSep 3, 2024
  6. Junio C HamanoSep 3, 2024
  7. Patrick SteinhardtSep 4, 2024
  8. Junio C HamanoSep 4, 2024
  9. Patrick SteinhardtSep 4, 2024
  10. karthik nayakSep 5, 2024
  11. 0/3 refs/files: use heuristics to decide whether to repack with `--auto`Patrick Steinhardt, Sep 4, 2024
  12. 1/3 wrapper: introduce `log2u()`Patrick Steinhardt, Sep 4, 2024
  13. 2/3 t0601: merge tests for auto-packing of refsPatrick Steinhardt, Sep 4, 2024
  14. 3/3 refs/files: use heuristic to decide whether to repack with `--auto`Patrick Steinhardt, Sep 4, 2024
  15. Junio C HamanoSep 4, 2024
  16. Patrick SteinhardtSep 5, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.