maintenance: disable cron on macOS
commit689a2aa719c1e08e501a11c6c22b6697b30efdd9
authorDerrick Stolee <dstolee@microsoft.com>
Wed, 10 Nov 2021 18:35:59 +0000 (10 18:35 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Nov 2021 19:20:20 +0000 (10 11:20 -0800)
treee54155eacc787b65f853ae7fc642564b9ea8d15c
parent670e5973992b6126aa0841c3c6bc183f0cec749f
maintenance: disable cron on macOS

In eba1ba9 (maintenance: `git maintenance run` learned
`--scheduler=<scheduler>`, 2021-09-04), we introduced the ability to
specify a scheduler explicitly. This led to some extra checks around
whether an alternative scheduler was available. This added the
functionality of removing background maintenance from schedulers other
than the one selected.

On macOS, cron is technically available, but running 'crontab' triggers
a UI prompt asking for special permissions. This is the major reason why
launchctl is used as the default scheduler. The is_crontab_available()
method triggers this UI prompt, causing user disruption.

Remove this disruption by using an #ifdef to prevent running crontab
this way on macOS. This has the unfortunate downside that if a user
manually selects cron via the '--scheduler' option, then adjusting the
scheduler later will not remove the schedule from cron. The
'--scheduler' option ignores the is_available checks, which is how we
can get into this situation.

Extract the new check_crontab_process() method to avoid making the
'child' variable unused on macOS. The method is marked MAYBE_UNUSED
because it has no callers on macOS.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/gc.c