builtin/maintenance: improve readability of strategies

Our maintenance strategies are essentially a large array of structures, where each of the tasks can be enabled and scheduled individually. With the current layout though all the configuration sits on the same nesting layer, which makes it a bit hard to discern which initialized fields belong to what task. Improve readability of the individual tasks by using nested designated initializers instead. Suggested-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Patrick Steinhardt <ps@pks.im> Acked-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Oct 24, 2025 at 08:57 UTC e83e92e87672def24d971cdfef801bb0de0d5955
1 file changed +25 -11
builtin/gc.c
+25 -11
@@ -1835,23 +1835,37 @@ struct maintenance_strategy {
1835 };
1836
1837 static const struct maintenance_strategy none_strategy = { 0 };
1838 +
1839 static const struct maintenance_strategy default_strategy = {
1840 .tasks = {
1840 - [TASK_GC].enabled = 1,
1841 + [TASK_GC] = {
1842 + .enabled = 1,
1843 + },
1844 },
1845 };
1846 +
1847 static const struct maintenance_strategy incremental_strategy = {
1848 .tasks = {
1845 - [TASK_COMMIT_GRAPH].enabled = 1,
1846 - [TASK_COMMIT_GRAPH].schedule = SCHEDULE_HOURLY,
1847 - [TASK_PREFETCH].enabled = 1,
1848 - [TASK_PREFETCH].schedule = SCHEDULE_HOURLY,
1849 - [TASK_INCREMENTAL_REPACK].enabled = 1,
1850 - [TASK_INCREMENTAL_REPACK].schedule = SCHEDULE_DAILY,
1851 - [TASK_LOOSE_OBJECTS].enabled = 1,
1852 - [TASK_LOOSE_OBJECTS].schedule = SCHEDULE_DAILY,
1853 - [TASK_PACK_REFS].enabled = 1,
1854 - [TASK_PACK_REFS].schedule = SCHEDULE_WEEKLY,
1849 + [TASK_COMMIT_GRAPH] = {
1850 + .enabled = 1,
1851 + .schedule = SCHEDULE_HOURLY,
1852 + },
1853 + [TASK_PREFETCH] = {
1854 + .enabled = 1,
1855 + .schedule = SCHEDULE_HOURLY,
1856 + },
1857 + [TASK_INCREMENTAL_REPACK] = {
1858 + .enabled = 1,
1859 + .schedule = SCHEDULE_DAILY,
1860 + },
1861 + [TASK_LOOSE_OBJECTS] = {
1862 + .enabled = 1,
1863 + .schedule = SCHEDULE_DAILY,
1864 + },
1865 + [TASK_PACK_REFS] = {
1866 + .enabled = 1,
1867 + .schedule = SCHEDULE_WEEKLY,
1868 + },
1869 },
1870 };
1871