]> git.ipfire.org Git - thirdparty/git.git/commitdiff
scalar: only warn when background maintenance fails
authorDerrick Stolee <derrickstolee@github.com>
Fri, 27 Jan 2023 20:06:03 +0000 (20:06 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Jan 2023 20:38:26 +0000 (12:38 -0800)
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>
scalar.c
t/t9210-scalar.sh
t/t9211-scalar-clone.sh

index f25d5f1d0ef1d9710dbdd0f3d7d6ea21c5ace828..ca19b95ce46cfdaa6f501eb487d4ba869fd0c5bd 100644 (file)
--- a/scalar.c
+++ b/scalar.c
@@ -262,7 +262,7 @@ static int register_dir(void)
                return error(_("could not set recommended config"));
 
        if (toggle_maintenance(1))
-               return error(_("could not turn on maintenance"));
+               warning(_("could not turn on maintenance"));
 
        if (have_fsmonitor_support() && start_fsmonitor_daemon()) {
                return error(_("could not start the FSMonitor daemon"));
index 13a4f6dbcf437c03d28d5be36b1945bd962e0fba..4432a30d10b69a168ca477f222bfa52d36447006 100755 (executable)
@@ -104,10 +104,10 @@ test_expect_success FSMONITOR_DAEMON 'scalar register starts fsmon daemon' '
        test_cmp_config -C test/src true core.fsmonitor
 '
 
-test_expect_success 'scalar register fails when background maintenance fails' '
+test_expect_success 'scalar register warns when background maintenance fails' '
        git init register-repo &&
        GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
-               test_must_fail scalar register register-repo 2>err &&
+               scalar register register-repo 2>err &&
        grep "could not turn on maintenance" err
 '
 
index a6156da29acaf1314f235f26d64c18942057e62e..872ad1c9c2b156bf25797b2651c69e9749cf391e 100755 (executable)
@@ -174,9 +174,9 @@ test_expect_success 'progress without tty' '
        cleanup_clone $enlistment
 '
 
-test_expect_success 'scalar clone fails when background maintenance fails' '
+test_expect_success 'scalar clone warns when background maintenance fails' '
        GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
-               test_must_fail scalar clone "file://$(pwd)/to-clone" maint-fail 2>err &&
+               scalar clone "file://$(pwd)/to-clone" maint-fail 2>err &&
        grep "could not turn on maintenance" err
 '