File tree Expand file tree Collapse file tree 3 files changed +72
-0
lines changed Expand file tree Collapse file tree 3 files changed +72
-0
lines changed Original file line number Diff line number Diff line change @@ -21,3 +21,12 @@ maintenance.loose-objects.auto::
21
21
positive value implies the command should run when the number of
22
22
loose objects is at least the value of `maintenance.loose-objects.auto`.
23
23
The default value is 100.
24
+
25
+ maintenance.incremental-repack.auto::
26
+ This integer config option controls how often the `incremental-repack`
27
+ task should be run as part of `git maintenance run --auto`. If zero,
28
+ then the `incremental-repack` task will not run with the `--auto`
29
+ option. A negative value will force the task to run every time.
30
+ Otherwise, a positive value implies the command should run when the
31
+ number of pack-files not in the multi-pack-index is at least the value
32
+ of `maintenance.incremental-repack.auto`. The default value is 10.
Original file line number Diff line number Diff line change 31
31
#include "refs.h"
32
32
#include "remote.h"
33
33
#include "midx.h"
34
+ #include "object-store.h"
34
35
35
36
#define FAILED_RUN "failed to run %s"
36
37
@@ -1030,6 +1031,35 @@ static int maintenance_task_loose_objects(struct maintenance_opts *opts)
1030
1031
return prune_packed (opts ) || pack_loose (opts );
1031
1032
}
1032
1033
1034
+ static int incremental_repack_auto_condition (void )
1035
+ {
1036
+ struct packed_git * p ;
1037
+ int enabled ;
1038
+ int incremental_repack_auto_limit = 10 ;
1039
+ int count = 0 ;
1040
+
1041
+ if (git_config_get_bool ("core.multiPackIndex" , & enabled ) ||
1042
+ !enabled )
1043
+ return 0 ;
1044
+
1045
+ git_config_get_int ("maintenance.incremental-repack.auto" ,
1046
+ & incremental_repack_auto_limit );
1047
+
1048
+ if (!incremental_repack_auto_limit )
1049
+ return 0 ;
1050
+ if (incremental_repack_auto_limit < 0 )
1051
+ return 1 ;
1052
+
1053
+ for (p = get_packed_git (the_repository );
1054
+ count < incremental_repack_auto_limit && p ;
1055
+ p = p -> next ) {
1056
+ if (!p -> multi_pack_index )
1057
+ count ++ ;
1058
+ }
1059
+
1060
+ return count >= incremental_repack_auto_limit ;
1061
+ }
1062
+
1033
1063
static int multi_pack_index_write (struct maintenance_opts * opts )
1034
1064
{
1035
1065
struct child_process child = CHILD_PROCESS_INIT ;
@@ -1220,6 +1250,7 @@ static struct maintenance_task tasks[] = {
1220
1250
[TASK_INCREMENTAL_REPACK ] = {
1221
1251
"incremental-repack" ,
1222
1252
maintenance_task_incremental_repack ,
1253
+ incremental_repack_auto_condition ,
1223
1254
},
1224
1255
[TASK_GC ] = {
1225
1256
"gc" ,
Original file line number Diff line number Diff line change @@ -187,6 +187,7 @@ test_expect_success 'incremental-repack task' '
187
187
'
188
188
189
189
test_expect_success EXPENSIVE ' incremental-repack 2g limit' '
190
+
190
191
for i in $(test_seq 1 5)
191
192
do
192
193
test-tool genrandom foo$i $((512 * 1024 * 1024 + 1)) >>big ||
@@ -217,4 +218,35 @@ test_expect_success EXPENSIVE 'incremental-repack 2g limit' '
217
218
--no-progress --batch-size=2147483647 <run-2g.txt
218
219
'
219
220
221
+ test_expect_success ' maintenance.incremental-repack.auto' '
222
+ git repack -adk &&
223
+ git config core.multiPackIndex true &&
224
+ git multi-pack-index write &&
225
+ GIT_TRACE2_EVENT="$(pwd)/midx-init.txt" git \
226
+ -c maintenance.incremental-repack.auto=1 \
227
+ maintenance run --auto --task=incremental-repack 2>/dev/null &&
228
+ test_subcommand ! git multi-pack-index write --no-progress <midx-init.txt &&
229
+ for i in 1 2
230
+ do
231
+ test_commit A-$i &&
232
+ git pack-objects --revs .git/objects/pack/pack <<-\EOF &&
233
+ HEAD
234
+ ^HEAD~1
235
+ EOF
236
+ GIT_TRACE2_EVENT=$(pwd)/trace-A-$i git \
237
+ -c maintenance.incremental-repack.auto=2 \
238
+ maintenance run --auto --task=incremental-repack 2>/dev/null &&
239
+ test_subcommand ! git multi-pack-index write --no-progress <trace-A-$i &&
240
+ test_commit B-$i &&
241
+ git pack-objects --revs .git/objects/pack/pack <<-\EOF &&
242
+ HEAD
243
+ ^HEAD~1
244
+ EOF
245
+ GIT_TRACE2_EVENT=$(pwd)/trace-B-$i git \
246
+ -c maintenance.incremental-repack.auto=2 \
247
+ maintenance run --auto --task=incremental-repack 2>/dev/null &&
248
+ test_subcommand git multi-pack-index write --no-progress <trace-B-$i || return 1
249
+ done
250
+ '
251
+
220
252
test_done
You can’t perform that action at this time.
0 commit comments