Skip to content

Commit

Permalink
maintenance: incremental strategy runs pack-refs weekly
Browse files Browse the repository at this point in the history
When the 'maintenance.strategy' config option is set to 'incremental',
a default maintenance schedule is enabled. Add the 'pack-refs' task to
that strategy at the weekly cadence.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
derrickstolee authored and gitster committed Feb 10, 2021
1 parent 41abfe1 commit acc1c4d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Documentation/config/maintenance.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ maintenance.strategy::
* `none`: This default setting implies no task are run at any schedule.
* `incremental`: This setting optimizes for performing small maintenance
activities that do not delete any data. This does not schedule the `gc`
task, but runs the `prefetch` and `commit-graph` tasks hourly and the
`loose-objects` and `incremental-repack` tasks daily.
task, but runs the `prefetch` and `commit-graph` tasks hourly, the
`loose-objects` and `incremental-repack` tasks daily, and the `pack-refs`
task weekly.

maintenance.<task>.enabled::
This boolean config option controls whether the maintenance task
Expand Down
2 changes: 2 additions & 0 deletions builtin/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,8 @@ static void initialize_maintenance_strategy(void)
tasks[TASK_INCREMENTAL_REPACK].schedule = SCHEDULE_DAILY;
tasks[TASK_LOOSE_OBJECTS].enabled = 1;
tasks[TASK_LOOSE_OBJECTS].schedule = SCHEDULE_DAILY;
tasks[TASK_PACK_REFS].enabled = 1;
tasks[TASK_PACK_REFS].schedule = SCHEDULE_WEEKLY;
}
}

Expand Down
14 changes: 14 additions & 0 deletions t/t7900-maintenance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -408,18 +408,32 @@ test_expect_success 'maintenance.strategy inheritance' '
git maintenance run --schedule=hourly --quiet &&
GIT_TRACE2_EVENT="$(pwd)/incremental-daily.txt" \
git maintenance run --schedule=daily --quiet &&
GIT_TRACE2_EVENT="$(pwd)/incremental-weekly.txt" \
git maintenance run --schedule=weekly --quiet &&
test_subcommand git commit-graph write --split --reachable \
--no-progress <incremental-hourly.txt &&
test_subcommand ! git prune-packed --quiet <incremental-hourly.txt &&
test_subcommand ! git multi-pack-index write --no-progress \
<incremental-hourly.txt &&
test_subcommand ! git pack-refs --all --prune \
<incremental-hourly.txt &&
test_subcommand git commit-graph write --split --reachable \
--no-progress <incremental-daily.txt &&
test_subcommand git prune-packed --quiet <incremental-daily.txt &&
test_subcommand git multi-pack-index write --no-progress \
<incremental-daily.txt &&
test_subcommand ! git pack-refs --all --prune \
<incremental-daily.txt &&
test_subcommand git commit-graph write --split --reachable \
--no-progress <incremental-weekly.txt &&
test_subcommand git prune-packed --quiet <incremental-weekly.txt &&
test_subcommand git multi-pack-index write --no-progress \
<incremental-weekly.txt &&
test_subcommand git pack-refs --all --prune \
<incremental-weekly.txt &&
# Modify defaults
git config maintenance.commit-graph.schedule daily &&
Expand Down

0 comments on commit acc1c4d

Please sign in to comment.