maintenance: running maintenance should not stop on errors

In https://github.com/microsoft/git/issues/623, it was reported that maintenance stops on a missing repository, omitting the remaining repositories that were scheduled for maintenance. This is undesirable, as it should be a best effort type of operation. It should still fail due to the missing repository, of course, but not leave the non-missing repositories in unmaintained shapes. Let's use `for-each-repo`'s shiny new `--keep-going` option that we just introduced for that very purpose. This change will be picked up when running `git maintenance start`, which is run implicitly by `scalar reconfigure`. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Apr 24, 2024 at 16:14 UTC c75662bfc963fb3e776e4a863bbb726819352cfd
2 files changed +7 -6
builtin/gc.c
+4 -3
@@ -1858,6 +1858,7 @@ static int launchctl_schedule_plist(const char *exec_path, enum schedule_priorit
1858 "<string>%s/git</string>\n"
1859 "<string>--exec-path=%s</string>\n"
1860 "<string>for-each-repo</string>\n"
1861 + "<string>--keep-going</string>\n"
1862 "<string>--config=maintenance.repo</string>\n"
1863 "<string>maintenance</string>\n"
1864 "<string>run</string>\n"
@@ -2100,7 +2101,7 @@ static int schtasks_schedule_task(const char *exec_path, enum schedule_priority
2101 "<Actions Context=\"Author\">\n"
2102 "<Exec>\n"
2103 "<Command>\"%s\\headless-git.exe\"</Command>\n"
2103 - "<Arguments>--exec-path=\"%s\" for-each-repo --config=maintenance.repo maintenance run --schedule=%s</Arguments>\n"
2104 + "<Arguments>--exec-path=\"%s\" for-each-repo --keep-going --config=maintenance.repo maintenance run --schedule=%s</Arguments>\n"
2105 "</Exec>\n"
2106 "</Actions>\n"
2107 "</Task>\n";
@@ -2245,7 +2246,7 @@ static int crontab_update_schedule(int run_maintenance, int fd)
2246 "# replaced in the future by a Git command.\n\n");
2247
2248 strbuf_addf(&line_format,
2248 - "%%d %%s * * %%s \"%s/git\" --exec-path=\"%s\" for-each-repo --config=maintenance.repo maintenance run --schedule=%%s\n",
2249 + "%%d %%s * * %%s \"%s/git\" --exec-path=\"%s\" for-each-repo --keep-going --config=maintenance.repo maintenance run --schedule=%%s\n",
2250 exec_path, exec_path);
2251 fprintf(cron_in, line_format.buf, minute, "1-23", "*", "hourly");
2252 fprintf(cron_in, line_format.buf, minute, "0", "1-6", "daily");
@@ -2446,7 +2447,7 @@ static int systemd_timer_write_service_template(const char *exec_path)
2447 "\n"
2448 "[Service]\n"
2449 "Type=oneshot\n"
2449 - "ExecStart=\"%s/git\" --exec-path=\"%s\" for-each-repo --config=maintenance.repo maintenance run --schedule=%%i\n"
2450 + "ExecStart=\"%s/git\" --exec-path=\"%s\" for-each-repo --keep-going --config=maintenance.repo maintenance run --schedule=%%i\n"
2451 "LockPersonality=yes\n"
2452 "MemoryDenyWriteExecute=yes\n"
2453 "NoNewPrivileges=yes\n"
t/t7900-maintenance.sh
+3 -3
@@ -639,9 +639,9 @@ test_expect_success 'start from empty cron table' '
639 # start registers the repo
640 git config --get --global --fixed-value maintenance.repo "$(pwd)" &&
641
642 - grep "for-each-repo --config=maintenance.repo maintenance run --schedule=daily" cron.txt &&
643 - grep "for-each-repo --config=maintenance.repo maintenance run --schedule=hourly" cron.txt &&
644 - grep "for-each-repo --config=maintenance.repo maintenance run --schedule=weekly" cron.txt
642 + grep "for-each-repo --keep-going --config=maintenance.repo maintenance run --schedule=daily" cron.txt &&
643 + grep "for-each-repo --keep-going --config=maintenance.repo maintenance run --schedule=hourly" cron.txt &&
644 + grep "for-each-repo --keep-going --config=maintenance.repo maintenance run --schedule=weekly" cron.txt
645 '
646
647 test_expect_success 'stop from existing schedule' '