@@ -22,30 +22,25 @@ add_blob() {
2222}
2323
2424test_expect_success setup '
25-
26- : > file &&
25+ >file &&
2726 git add file &&
2827 test_tick &&
2928 git commit -m initial &&
3029 git gc
31-
3230'
3331
3432test_expect_success ' prune stale packs' '
35-
3633 orig_pack=$(echo .git/objects/pack/*.pack) &&
37- : > .git/objects/tmp_1.pack &&
38- : > .git/objects/tmp_2.pack &&
34+ > .git/objects/tmp_1.pack &&
35+ > .git/objects/tmp_2.pack &&
3936 test-tool chmtime =-86501 .git/objects/tmp_1.pack &&
4037 git prune --expire 1.day &&
4138 test_path_is_file $orig_pack &&
4239 test_path_is_file .git/objects/tmp_2.pack &&
4340 test_path_is_missing .git/objects/tmp_1.pack
44-
4541'
4642
4743test_expect_success ' prune --expire' '
48-
4944 add_blob &&
5045 git prune --expire=1.hour.ago &&
5146 verbose test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
@@ -54,11 +49,9 @@ test_expect_success 'prune --expire' '
5449 git prune --expire 1.day &&
5550 verbose test $before = $(git count-objects | sed "s/ .*//") &&
5651 test_path_is_missing $BLOB_FILE
57-
5852'
5953
6054test_expect_success ' gc: implicit prune --expire' '
61-
6255 add_blob &&
6356 test-tool chmtime =-$((2*$week-30)) $BLOB_FILE &&
6457 git gc &&
@@ -68,33 +61,25 @@ test_expect_success 'gc: implicit prune --expire' '
6861 git gc &&
6962 verbose test $before = $(git count-objects | sed "s/ .*//") &&
7063 test_path_is_missing $BLOB_FILE
71-
7264'
7365
7466test_expect_success ' gc: refuse to start with invalid gc.pruneExpire' '
75-
7667 git config gc.pruneExpire invalid &&
7768 test_must_fail git gc
78-
7969'
8070
8171test_expect_success ' gc: start with ok gc.pruneExpire' '
82-
8372 git config gc.pruneExpire 2.days.ago &&
8473 git gc
85-
8674'
8775
8876test_expect_success ' prune: prune nonsense parameters' '
89-
9077 test_must_fail git prune garbage &&
9178 test_must_fail git prune --- &&
9279 test_must_fail git prune --no-such-option
93-
9480'
9581
9682test_expect_success ' prune: prune unreachable heads' '
97-
9883 git config core.logAllRefUpdates false &&
9984 mv .git/logs .git/logs.old &&
10085 : > file2 &&
@@ -104,105 +89,86 @@ test_expect_success 'prune: prune unreachable heads' '
10489 git reset HEAD^ &&
10590 git prune &&
10691 test_must_fail git reset $tmp_head --
107-
10892'
10993
11094test_expect_success ' prune: do not prune detached HEAD with no reflog' '
111-
11295 git checkout --detach --quiet &&
11396 git commit --allow-empty -m "detached commit" &&
11497 # verify that there is no reflogs
11598 # (should be removed and disabled by previous test)
11699 test_path_is_missing .git/logs &&
117100 git prune -n >prune_actual &&
118101 test_must_be_empty prune_actual
119-
120102'
121103
122104test_expect_success ' prune: prune former HEAD after checking out branch' '
123-
124105 head_oid=$(git rev-parse HEAD) &&
125106 git checkout --quiet main &&
126107 git prune -v >prune_actual &&
127108 grep "$head_oid" prune_actual
128-
129109'
130110
131111test_expect_success ' prune: do not prune heads listed as an argument' '
132-
133- : > file2 &&
112+ >file2 &&
134113 git add file2 &&
135114 git commit -m temporary &&
136115 tmp_head=$(git rev-list -1 HEAD) &&
137116 git reset HEAD^ &&
138117 git prune -- $tmp_head &&
139118 git reset $tmp_head --
140-
141119'
142120
143121test_expect_success ' gc --no-prune' '
144-
145122 add_blob &&
146123 test-tool chmtime =-$((5001*$day)) $BLOB_FILE &&
147124 git config gc.pruneExpire 2.days.ago &&
148125 git gc --no-prune &&
149126 verbose test 1 = $(git count-objects | sed "s/ .*//") &&
150127 test_path_is_file $BLOB_FILE
151-
152128'
153129
154130test_expect_success ' gc respects gc.pruneExpire' '
155-
156131 git config gc.pruneExpire 5002.days.ago &&
157132 git gc &&
158133 test_path_is_file $BLOB_FILE &&
159134 git config gc.pruneExpire 5000.days.ago &&
160135 git gc &&
161136 test_path_is_missing $BLOB_FILE
162-
163137'
164138
165139test_expect_success ' gc --prune=<date>' '
166-
167140 add_blob &&
168141 test-tool chmtime =-$((5001*$day)) $BLOB_FILE &&
169142 git gc --prune=5002.days.ago &&
170143 test_path_is_file $BLOB_FILE &&
171144 git gc --prune=5000.days.ago &&
172145 test_path_is_missing $BLOB_FILE
173-
174146'
175147
176148test_expect_success ' gc --prune=never' '
177-
178149 add_blob &&
179150 git gc --prune=never &&
180151 test_path_is_file $BLOB_FILE &&
181152 git gc --prune=now &&
182153 test_path_is_missing $BLOB_FILE
183-
184154'
185155
186156test_expect_success ' gc respects gc.pruneExpire=never' '
187-
188157 git config gc.pruneExpire never &&
189158 add_blob &&
190159 git gc &&
191160 test_path_is_file $BLOB_FILE &&
192161 git config gc.pruneExpire now &&
193162 git gc &&
194163 test_path_is_missing $BLOB_FILE
195-
196164'
197165
198166test_expect_success ' prune --expire=never' '
199-
200167 add_blob &&
201168 git prune --expire=never &&
202169 test_path_is_file $BLOB_FILE &&
203170 git prune &&
204171 test_path_is_missing $BLOB_FILE
205-
206172'
207173
208174test_expect_success ' gc: prune old objects after local clone' '
@@ -222,16 +188,16 @@ test_expect_success 'gc: prune old objects after local clone' '
222188test_expect_success ' garbage report in count-objects -v' '
223189 test_when_finished "rm -f .git/objects/pack/fake*" &&
224190 test_when_finished "rm -f .git/objects/pack/foo*" &&
225- : >.git/objects/pack/foo &&
226- : >.git/objects/pack/foo.bar &&
227- : >.git/objects/pack/foo.keep &&
228- : >.git/objects/pack/foo.pack &&
229- : >.git/objects/pack/fake.bar &&
230- : >.git/objects/pack/fake.keep &&
231- : >.git/objects/pack/fake.pack &&
232- : >.git/objects/pack/fake.idx &&
233- : >.git/objects/pack/fake2.keep &&
234- : >.git/objects/pack/fake3.idx &&
191+ >.git/objects/pack/foo &&
192+ >.git/objects/pack/foo.bar &&
193+ >.git/objects/pack/foo.keep &&
194+ >.git/objects/pack/foo.pack &&
195+ >.git/objects/pack/fake.bar &&
196+ >.git/objects/pack/fake.keep &&
197+ >.git/objects/pack/fake.pack &&
198+ >.git/objects/pack/fake.idx &&
199+ >.git/objects/pack/fake2.keep &&
200+ >.git/objects/pack/fake3.idx &&
235201 git count-objects -v 2>stderr &&
236202 grep "index file .git/objects/pack/fake.idx is too small" stderr &&
237203 grep "^warning:" stderr | sort >actual &&
@@ -250,12 +216,12 @@ EOF
250216test_expect_success ' clean pack garbage with gc' '
251217 test_when_finished "rm -f .git/objects/pack/fake*" &&
252218 test_when_finished "rm -f .git/objects/pack/foo*" &&
253- : >.git/objects/pack/foo.keep &&
254- : >.git/objects/pack/foo.pack &&
255- : >.git/objects/pack/fake.idx &&
256- : >.git/objects/pack/fake2.keep &&
257- : >.git/objects/pack/fake2.idx &&
258- : >.git/objects/pack/fake3.keep &&
219+ >.git/objects/pack/foo.keep &&
220+ >.git/objects/pack/foo.pack &&
221+ >.git/objects/pack/fake.idx &&
222+ >.git/objects/pack/fake2.keep &&
223+ >.git/objects/pack/fake2.idx &&
224+ >.git/objects/pack/fake3.keep &&
259225 git gc &&
260226 git count-objects -v 2>stderr &&
261227 grep "^warning:" stderr | sort >actual &&
0 commit comments