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

[PATCH 04/10] t/t5304-prune.sh: prepare for `gc --cruft` by default

From
Taylor Blau <me@ttaylorr.com>
Date
Apr 17, 2023, 20:54 UTC
Message-ID
<44006da959eeeaef93a33d73071fb5edc45cd45b.1681764848.git.me@ttaylorr.com>
In-Reply-To
<cover.1681764848.git.me@ttaylorr.com>

Many of the tests in t5304 run `git gc`, and rely on its behavior that unreachable-but-recent objects are written out loose. This is sensible, since t5304 deals specifically with this kind of pruning.

If left unattended, however, this test would break when the default behavior of a bare "git gc" is adjusted to generate a cruft pack by default.

Ensure that these tests continue to work as-is (and continue to provide coverage of loose object pruning) by passing `--no-cruft` explicitly.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 t/t5304-prune.sh | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh
index 5500dd0842..662ae9b152 100755
--- a/t/t5304-prune.sh
+++ b/t/t5304-prune.sh
@@ -62,11 +62,11 @@ test_expect_success 'prune --expire' '
 test_expect_success 'gc: implicit prune --expire' '
 	add_blob &&
 	test-tool chmtime =-$((2*$week-30)) $BLOB_FILE &&
-	git gc &&
+	git gc --no-cruft &&
 	verbose test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
 	test_path_is_file $BLOB_FILE &&
 	test-tool chmtime =-$((2*$week+1)) $BLOB_FILE &&
-	git gc &&
+	git gc --no-cruft &&
 	verbose test $before = $(git count-objects | sed "s/ .*//") &&
 	test_path_is_missing $BLOB_FILE
 '
@@ -86,7 +86,7 @@ test_expect_success 'gc: refuse to start with invalid gc.pruneExpire' '
 
 test_expect_success 'gc: start with ok gc.pruneExpire' '
 	git config gc.pruneExpire 2.days.ago &&
-	git gc
+	git gc --no-cruft
 '
 
 test_expect_success 'prune: prune nonsense parameters' '
@@ -137,44 +137,44 @@ test_expect_success 'gc --no-prune' '
 	add_blob &&
 	test-tool chmtime =-$((5001*$day)) $BLOB_FILE &&
 	git config gc.pruneExpire 2.days.ago &&
-	git gc --no-prune &&
+	git gc --no-prune --no-cruft &&
 	verbose test 1 = $(git count-objects | sed "s/ .*//") &&
 	test_path_is_file $BLOB_FILE
 '
 
 test_expect_success 'gc respects gc.pruneExpire' '
 	git config gc.pruneExpire 5002.days.ago &&
-	git gc &&
+	git gc --no-cruft &&
 	test_path_is_file $BLOB_FILE &&
 	git config gc.pruneExpire 5000.days.ago &&
-	git gc &&
+	git gc --no-cruft &&
 	test_path_is_missing $BLOB_FILE
 '
 
 test_expect_success 'gc --prune=<date>' '
 	add_blob &&
 	test-tool chmtime =-$((5001*$day)) $BLOB_FILE &&
-	git gc --prune=5002.days.ago &&
+	git gc --prune=5002.days.ago --no-cruft &&
 	test_path_is_file $BLOB_FILE &&
-	git gc --prune=5000.days.ago &&
+	git gc --prune=5000.days.ago --no-cruft &&
 	test_path_is_missing $BLOB_FILE
 '
 
 test_expect_success 'gc --prune=never' '
 	add_blob &&
-	git gc --prune=never &&
+	git gc --prune=never --no-cruft &&
 	test_path_is_file $BLOB_FILE &&
-	git gc --prune=now &&
+	git gc --prune=now --no-cruft &&
 	test_path_is_missing $BLOB_FILE
 '
 
 test_expect_success 'gc respects gc.pruneExpire=never' '
 	git config gc.pruneExpire never &&
 	add_blob &&
-	git gc &&
+	git gc --no-cruft &&
 	test_path_is_file $BLOB_FILE &&
 	git config gc.pruneExpire now &&
-	git gc &&
+	git gc --no-cruft &&
 	test_path_is_missing $BLOB_FILE
 '
 
@@ -194,7 +194,7 @@ test_expect_success 'gc: prune old objects after local clone' '
 		cd aclone &&
 		verbose test 1 = $(git count-objects | sed "s/ .*//") &&
 		test_path_is_file $BLOB_FILE &&
-		git gc --prune &&
+		git gc --prune --no-cruft &&
 		verbose test 0 = $(git count-objects | sed "s/ .*//") &&
 		test_path_is_missing $BLOB_FILE
 	)
@@ -237,7 +237,7 @@ test_expect_success 'clean pack garbage with gc' '
 	>.git/objects/pack/fake2.keep &&
 	>.git/objects/pack/fake2.idx &&
 	>.git/objects/pack/fake3.keep &&
-	git gc &&
+	git gc --no-cruft &&
 	git count-objects -v 2>stderr &&
 	grep "^warning:" stderr | sort >actual &&
 	cat >expected <<\EOF &&
-- 
2.38.1
Previous: Derrick StoleeNext: Taylor Blau
Message 11 of 48 in “gc: enable cruft packs by default”
  1. 00/10 gc: enable cruft packs by defaultTaylor Blau, Apr 17, 2023
  2. 01/10 pack-write.c: plug a leak in stage_tmp_packfiles()Taylor Blau, Apr 17, 2023
  3. Jeff KingApr 18, 2023
  4. Taylor BlauApr 18, 2023
  5. 02/10 builtin/repack.c: fix incorrect reference to '-C'Taylor Blau, Apr 17, 2023
  6. 03/10 builtin/gc.c: ignore cruft packs with `--keep-largest-pack`Taylor Blau, Apr 17, 2023
  7. Junio C HamanoApr 17, 2023
  8. Taylor BlauApr 17, 2023
  9. Jeff KingApr 18, 2023
  10. Derrick StoleeApr 18, 2023
  11. 04/10 t/t5304-prune.sh: prepare for `gc --cruft` by defaultTaylor Blau, Apr 17, 2023
  12. 05/10 t/t9300-fast-import.sh: prepare for `gc --cruft` by defaultTaylor Blau, Apr 17, 2023
  13. Jeff KingApr 18, 2023
  14. Taylor BlauApr 18, 2023
  15. 06/10 t/t6500-gc.sh: refactor cruft pack testsTaylor Blau, Apr 17, 2023
  16. 07/10 t/t6500-gc.sh: add additional test casesTaylor Blau, Apr 17, 2023
  17. Jeff KingApr 18, 2023
  18. Taylor BlauApr 18, 2023
  19. 08/10 t/t6501-freshen-objects.sh: prepare for `gc --cruft` by defaultTaylor Blau, Apr 17, 2023
  20. Jeff KingApr 18, 2023
  21. Taylor BlauApr 18, 2023
  22. Jeff KingApr 22, 2023
  23. 09/10 builtin/gc.c: make `gc.cruftPacks` enabled by defaultTaylor Blau, Apr 17, 2023
  24. Jeff KingApr 18, 2023
  25. Taylor BlauApr 18, 2023
  26. 10/10 repository.h: drop unused `gc_cruft_packs`Taylor Blau, Apr 17, 2023
  27. Jeff KingApr 18, 2023
  28. Jeff KingApr 18, 2023
  29. Taylor BlauApr 18, 2023
  30. 00/10 gc: enable cruft packs by defaultTaylor Blau, Apr 18, 2023
  31. 01/10 pack-write.c: plug a leak in stage_tmp_packfiles()Taylor Blau, Apr 18, 2023
  32. Junio C HamanoApr 19, 2023
  33. Taylor BlauApr 20, 2023
  34. Junio C HamanoApr 20, 2023
  35. 02/10 builtin/repack.c: fix incorrect reference to '-C'Taylor Blau, Apr 18, 2023
  36. 03/10 builtin/gc.c: ignore cruft packs with `--keep-largest-pack`Taylor Blau, Apr 18, 2023
  37. 04/10 t/t5304-prune.sh: prepare for `gc --cruft` by defaultTaylor Blau, Apr 18, 2023
  38. 05/10 t/t6501-freshen-objects.sh: prepare for `gc --cruft` by defaultTaylor Blau, Apr 18, 2023
  39. 06/10 t/t6500-gc.sh: refactor cruft pack testsTaylor Blau, Apr 18, 2023
  40. 07/10 t/t6500-gc.sh: add additional test casesTaylor Blau, Apr 18, 2023
  41. 08/10 t/t9300-fast-import.sh: prepare for `gc --cruft` by defaultTaylor Blau, Apr 18, 2023
  42. 09/10 builtin/gc.c: make `gc.cruftPacks` enabled by defaultTaylor Blau, Apr 18, 2023
  43. Junio C HamanoApr 19, 2023
  44. Taylor BlauApr 20, 2023
  45. Junio C HamanoApr 20, 2023
  46. Taylor BlauApr 20, 2023
  47. 10/10 repository.h: drop unused `gc_cruft_packs`Taylor Blau, Apr 18, 2023
  48. Junio C HamanoApr 19, 2023

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.