t/t5304-prune.sh: prepare for `gc --cruft` by default

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Apr 18, 2023 at 16:40 UTC b934207a223a846e98c693c4c6a9ca32bf995688
1 file changed +14 -14
t/t5304-prune.sh
+14 -14
@@ -62,11 +62,11 @@ test_expect_success 'prune --expire' '
62 test_expect_success 'gc: implicit prune --expire' '
63 add_blob &&
64 test-tool chmtime =-$((2*$week-30)) $BLOB_FILE &&
65 - git gc &&
65 + git gc --no-cruft &&
66 verbose test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
67 test_path_is_file $BLOB_FILE &&
68 test-tool chmtime =-$((2*$week+1)) $BLOB_FILE &&
69 - git gc &&
69 + git gc --no-cruft &&
70 verbose test $before = $(git count-objects | sed "s/ .*//") &&
71 test_path_is_missing $BLOB_FILE
72 '
@@ -86,7 +86,7 @@ test_expect_success 'gc: refuse to start with invalid gc.pruneExpire' '
86
87 test_expect_success 'gc: start with ok gc.pruneExpire' '
88 git config gc.pruneExpire 2.days.ago &&
89 - git gc
89 + git gc --no-cruft
90 '
91
92 test_expect_success 'prune: prune nonsense parameters' '
@@ -137,44 +137,44 @@ test_expect_success 'gc --no-prune' '
137 add_blob &&
138 test-tool chmtime =-$((5001*$day)) $BLOB_FILE &&
139 git config gc.pruneExpire 2.days.ago &&
140 - git gc --no-prune &&
140 + git gc --no-prune --no-cruft &&
141 verbose test 1 = $(git count-objects | sed "s/ .*//") &&
142 test_path_is_file $BLOB_FILE
143 '
144
145 test_expect_success 'gc respects gc.pruneExpire' '
146 git config gc.pruneExpire 5002.days.ago &&
147 - git gc &&
147 + git gc --no-cruft &&
148 test_path_is_file $BLOB_FILE &&
149 git config gc.pruneExpire 5000.days.ago &&
150 - git gc &&
150 + git gc --no-cruft &&
151 test_path_is_missing $BLOB_FILE
152 '
153
154 test_expect_success 'gc --prune=<date>' '
155 add_blob &&
156 test-tool chmtime =-$((5001*$day)) $BLOB_FILE &&
157 - git gc --prune=5002.days.ago &&
157 + git gc --prune=5002.days.ago --no-cruft &&
158 test_path_is_file $BLOB_FILE &&
159 - git gc --prune=5000.days.ago &&
159 + git gc --prune=5000.days.ago --no-cruft &&
160 test_path_is_missing $BLOB_FILE
161 '
162
163 test_expect_success 'gc --prune=never' '
164 add_blob &&
165 - git gc --prune=never &&
165 + git gc --prune=never --no-cruft &&
166 test_path_is_file $BLOB_FILE &&
167 - git gc --prune=now &&
167 + git gc --prune=now --no-cruft &&
168 test_path_is_missing $BLOB_FILE
169 '
170
171 test_expect_success 'gc respects gc.pruneExpire=never' '
172 git config gc.pruneExpire never &&
173 add_blob &&
174 - git gc &&
174 + git gc --no-cruft &&
175 test_path_is_file $BLOB_FILE &&
176 git config gc.pruneExpire now &&
177 - git gc &&
177 + git gc --no-cruft &&
178 test_path_is_missing $BLOB_FILE
179 '
180
@@ -194,7 +194,7 @@ test_expect_success 'gc: prune old objects after local clone' '
194 cd aclone &&
195 verbose test 1 = $(git count-objects | sed "s/ .*//") &&
196 test_path_is_file $BLOB_FILE &&
197 - git gc --prune &&
197 + git gc --prune --no-cruft &&
198 verbose test 0 = $(git count-objects | sed "s/ .*//") &&
199 test_path_is_missing $BLOB_FILE
200 )
@@ -237,7 +237,7 @@ test_expect_success 'clean pack garbage with gc' '
237 >.git/objects/pack/fake2.keep &&
238 >.git/objects/pack/fake2.idx &&
239 >.git/objects/pack/fake3.keep &&
240 - git gc &&
240 + git gc --no-cruft &&
241 git count-objects -v 2>stderr &&
242 grep "^warning:" stderr | sort >actual &&
243 cat >expected <<\EOF &&