git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] maintenance: incremental strategy runs pack-refs weekly

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Feb 8, 2021, 14:52 UTC
Message-ID
<8012d2dc1420b71404b8db23a88474b5fabaed83.1612795943.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.871.git.1612795943.gitgitgadget@gmail.com>
From: Derrick Stolee <dstolee@microsoft.com>

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>
---
 Documentation/config/maintenance.txt |  5 +++--
 builtin/gc.c                         |  2 ++
 t/t7900-maintenance.sh               | 14 ++++++++++++++
 3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/Documentation/config/maintenance.txt b/Documentation/config/maintenance.txt
index a5ead09e4bc2..18f056213145 100644
--- a/Documentation/config/maintenance.txt
+++ b/Documentation/config/maintenance.txt
@@ -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
diff --git a/builtin/gc.c b/builtin/gc.c
index 8f13c3bb8607..8d365a59d027 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -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;
 	}
 }
 
diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh
index ef4527823d29..fa92e01fb2c5 100755
--- a/t/t7900-maintenance.sh
+++ b/t/t7900-maintenance.sh
@@ -406,18 +406,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 &&
-- 
gitgitgadget
Previous: Derrick Stolee via GitGitGadgetNext: Derrick Stolee via GitGitGadget
Message 2 of 12 in “Maintenance: add pack-refs task”
  1. 0/2 Maintenance: add pack-refs taskDerrick Stolee via GitGitGadget, Feb 8, 2021
  2. 2/2 maintenance: incremental strategy runs pack-refs weeklyDerrick Stolee via GitGitGadget, Feb 8, 2021
  3. 1/2 maintenance: add pack-refs taskDerrick Stolee via GitGitGadget, Feb 8, 2021
  4. Taylor BlauFeb 8, 2021
  5. Derrick StoleeFeb 9, 2021
  6. Eric SunshineFeb 8, 2021
  7. Derrick StoleeFeb 9, 2021
  8. Taylor BlauFeb 8, 2021
  9. 0/2 Maintenance: add pack-refs taskDerrick Stolee via GitGitGadget, Feb 9, 2021
  10. 1/2 maintenance: add pack-refs taskDerrick Stolee via GitGitGadget, Feb 9, 2021
  11. 2/2 maintenance: incremental strategy runs pack-refs weeklyDerrick Stolee via GitGitGadget, Feb 9, 2021
  12. Taylor BlauFeb 10, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.