@@ -22,30 +22,25 @@ add_blob() {
22
22
}
23
23
24
24
test_expect_success setup '
25
-
26
- : > file &&
25
+ >file &&
27
26
git add file &&
28
27
test_tick &&
29
28
git commit -m initial &&
30
29
git gc
31
-
32
30
'
33
31
34
32
test_expect_success ' prune stale packs' '
35
-
36
33
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 &&
39
36
test-tool chmtime =-86501 .git/objects/tmp_1.pack &&
40
37
git prune --expire 1.day &&
41
38
test_path_is_file $orig_pack &&
42
39
test_path_is_file .git/objects/tmp_2.pack &&
43
40
test_path_is_missing .git/objects/tmp_1.pack
44
-
45
41
'
46
42
47
43
test_expect_success ' prune --expire' '
48
-
49
44
add_blob &&
50
45
git prune --expire=1.hour.ago &&
51
46
verbose test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
@@ -54,11 +49,9 @@ test_expect_success 'prune --expire' '
54
49
git prune --expire 1.day &&
55
50
verbose test $before = $(git count-objects | sed "s/ .*//") &&
56
51
test_path_is_missing $BLOB_FILE
57
-
58
52
'
59
53
60
54
test_expect_success ' gc: implicit prune --expire' '
61
-
62
55
add_blob &&
63
56
test-tool chmtime =-$((2*$week-30)) $BLOB_FILE &&
64
57
git gc &&
@@ -68,33 +61,25 @@ test_expect_success 'gc: implicit prune --expire' '
68
61
git gc &&
69
62
verbose test $before = $(git count-objects | sed "s/ .*//") &&
70
63
test_path_is_missing $BLOB_FILE
71
-
72
64
'
73
65
74
66
test_expect_success ' gc: refuse to start with invalid gc.pruneExpire' '
75
-
76
67
git config gc.pruneExpire invalid &&
77
68
test_must_fail git gc
78
-
79
69
'
80
70
81
71
test_expect_success ' gc: start with ok gc.pruneExpire' '
82
-
83
72
git config gc.pruneExpire 2.days.ago &&
84
73
git gc
85
-
86
74
'
87
75
88
76
test_expect_success ' prune: prune nonsense parameters' '
89
-
90
77
test_must_fail git prune garbage &&
91
78
test_must_fail git prune --- &&
92
79
test_must_fail git prune --no-such-option
93
-
94
80
'
95
81
96
82
test_expect_success ' prune: prune unreachable heads' '
97
-
98
83
git config core.logAllRefUpdates false &&
99
84
mv .git/logs .git/logs.old &&
100
85
: > file2 &&
@@ -104,105 +89,86 @@ test_expect_success 'prune: prune unreachable heads' '
104
89
git reset HEAD^ &&
105
90
git prune &&
106
91
test_must_fail git reset $tmp_head --
107
-
108
92
'
109
93
110
94
test_expect_success ' prune: do not prune detached HEAD with no reflog' '
111
-
112
95
git checkout --detach --quiet &&
113
96
git commit --allow-empty -m "detached commit" &&
114
97
# verify that there is no reflogs
115
98
# (should be removed and disabled by previous test)
116
99
test_path_is_missing .git/logs &&
117
100
git prune -n >prune_actual &&
118
101
test_must_be_empty prune_actual
119
-
120
102
'
121
103
122
104
test_expect_success ' prune: prune former HEAD after checking out branch' '
123
-
124
105
head_oid=$(git rev-parse HEAD) &&
125
106
git checkout --quiet main &&
126
107
git prune -v >prune_actual &&
127
108
grep "$head_oid" prune_actual
128
-
129
109
'
130
110
131
111
test_expect_success ' prune: do not prune heads listed as an argument' '
132
-
133
- : > file2 &&
112
+ >file2 &&
134
113
git add file2 &&
135
114
git commit -m temporary &&
136
115
tmp_head=$(git rev-list -1 HEAD) &&
137
116
git reset HEAD^ &&
138
117
git prune -- $tmp_head &&
139
118
git reset $tmp_head --
140
-
141
119
'
142
120
143
121
test_expect_success ' gc --no-prune' '
144
-
145
122
add_blob &&
146
123
test-tool chmtime =-$((5001*$day)) $BLOB_FILE &&
147
124
git config gc.pruneExpire 2.days.ago &&
148
125
git gc --no-prune &&
149
126
verbose test 1 = $(git count-objects | sed "s/ .*//") &&
150
127
test_path_is_file $BLOB_FILE
151
-
152
128
'
153
129
154
130
test_expect_success ' gc respects gc.pruneExpire' '
155
-
156
131
git config gc.pruneExpire 5002.days.ago &&
157
132
git gc &&
158
133
test_path_is_file $BLOB_FILE &&
159
134
git config gc.pruneExpire 5000.days.ago &&
160
135
git gc &&
161
136
test_path_is_missing $BLOB_FILE
162
-
163
137
'
164
138
165
139
test_expect_success ' gc --prune=<date>' '
166
-
167
140
add_blob &&
168
141
test-tool chmtime =-$((5001*$day)) $BLOB_FILE &&
169
142
git gc --prune=5002.days.ago &&
170
143
test_path_is_file $BLOB_FILE &&
171
144
git gc --prune=5000.days.ago &&
172
145
test_path_is_missing $BLOB_FILE
173
-
174
146
'
175
147
176
148
test_expect_success ' gc --prune=never' '
177
-
178
149
add_blob &&
179
150
git gc --prune=never &&
180
151
test_path_is_file $BLOB_FILE &&
181
152
git gc --prune=now &&
182
153
test_path_is_missing $BLOB_FILE
183
-
184
154
'
185
155
186
156
test_expect_success ' gc respects gc.pruneExpire=never' '
187
-
188
157
git config gc.pruneExpire never &&
189
158
add_blob &&
190
159
git gc &&
191
160
test_path_is_file $BLOB_FILE &&
192
161
git config gc.pruneExpire now &&
193
162
git gc &&
194
163
test_path_is_missing $BLOB_FILE
195
-
196
164
'
197
165
198
166
test_expect_success ' prune --expire=never' '
199
-
200
167
add_blob &&
201
168
git prune --expire=never &&
202
169
test_path_is_file $BLOB_FILE &&
203
170
git prune &&
204
171
test_path_is_missing $BLOB_FILE
205
-
206
172
'
207
173
208
174
test_expect_success ' gc: prune old objects after local clone' '
@@ -222,16 +188,16 @@ test_expect_success 'gc: prune old objects after local clone' '
222
188
test_expect_success ' garbage report in count-objects -v' '
223
189
test_when_finished "rm -f .git/objects/pack/fake*" &&
224
190
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 &&
235
201
git count-objects -v 2>stderr &&
236
202
grep "index file .git/objects/pack/fake.idx is too small" stderr &&
237
203
grep "^warning:" stderr | sort >actual &&
@@ -250,12 +216,12 @@ EOF
250
216
test_expect_success ' clean pack garbage with gc' '
251
217
test_when_finished "rm -f .git/objects/pack/fake*" &&
252
218
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 &&
259
225
git gc &&
260
226
git count-objects -v 2>stderr &&
261
227
grep "^warning:" stderr | sort >actual &&
0 commit comments