scalar: only warn when background maintenance fails

A user reported issues with 'scalar clone' and 'scalar register' when working in an environment that had locked down the ability to run 'crontab' or 'systemctl' in that those commands registered as _failures_ instead of opportunistically reporting a success with just a warning about background maintenance. As a workaround, they can use GIT_TEST_MAINT_SCHEDULER to fake a successful background maintenance, but this is not a viable strategy for long-term. Update 'scalar register' and 'scalar clone' to no longer fail by modifying register_dir() to only warn when toggle_maintenance(1) fails. Since background maintenance is a "nice to have" and not a requirement for a working repository, it is best to move this from hard error to gentle warning. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Jan 27, 2023 at 20:06 UTC dea63088928cde2fd264a852a9b14c05178e0838
3 files changed +5 -5
scalar.c
+1 -1
@@ -262,7 +262,7 @@ static int register_dir(void)
262 return error(_("could not set recommended config"));
263
264 if (toggle_maintenance(1))
265 - return error(_("could not turn on maintenance"));
265 + warning(_("could not turn on maintenance"));
266
267 if (have_fsmonitor_support() && start_fsmonitor_daemon()) {
268 return error(_("could not start the FSMonitor daemon"));
t/t9210-scalar.sh
+2 -2
@@ -104,10 +104,10 @@ test_expect_success FSMONITOR_DAEMON 'scalar register starts fsmon daemon' '
104 test_cmp_config -C test/src true core.fsmonitor
105 '
106
107 -test_expect_success 'scalar register fails when background maintenance fails' '
107 +test_expect_success 'scalar register warns when background maintenance fails' '
108 git init register-repo &&
109 GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
110 - test_must_fail scalar register register-repo 2>err &&
110 + scalar register register-repo 2>err &&
111 grep "could not turn on maintenance" err
112 '
113
t/t9211-scalar-clone.sh
+2 -2
@@ -174,9 +174,9 @@ test_expect_success 'progress without tty' '
174 cleanup_clone $enlistment
175 '
176
177 -test_expect_success 'scalar clone fails when background maintenance fails' '
177 +test_expect_success 'scalar clone warns when background maintenance fails' '
178 GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
179 - test_must_fail scalar clone "file://$(pwd)/to-clone" maint-fail 2>err &&
179 + scalar clone "file://$(pwd)/to-clone" maint-fail 2>err &&
180 grep "could not turn on maintenance" err
181 '
182