Skip to content

Commit c1d16ce

Browse files
committed
Merge branch 'ds/no-usable-cron-on-macos'
"git maintenance run" learned to use system supplied scheduler backend, but cron on macOS turns out to be unusable for this purpose. * ds/no-usable-cron-on-macos: maintenance: disable cron on macOS
2 parents 7c7cf62 + 689a2aa commit c1d16ce

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

builtin/gc.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,15 +1999,11 @@ static int schtasks_update_schedule(int run_maintenance, int fd)
19991999
return schtasks_remove_tasks();
20002000
}
20012001

2002-
static int is_crontab_available(void)
2002+
MAYBE_UNUSED
2003+
static int check_crontab_process(const char *cmd)
20032004
{
2004-
const char *cmd = "crontab";
2005-
int is_available;
20062005
struct child_process child = CHILD_PROCESS_INIT;
20072006

2008-
if (get_schedule_cmd(&cmd, &is_available))
2009-
return is_available;
2010-
20112007
strvec_split(&child.args, cmd);
20122008
strvec_push(&child.args, "-l");
20132009
child.no_stdin = 1;
@@ -2022,6 +2018,25 @@ static int is_crontab_available(void)
20222018
return 1;
20232019
}
20242020

2021+
static int is_crontab_available(void)
2022+
{
2023+
const char *cmd = "crontab";
2024+
int is_available;
2025+
2026+
if (get_schedule_cmd(&cmd, &is_available))
2027+
return is_available;
2028+
2029+
#ifdef __APPLE__
2030+
/*
2031+
* macOS has cron, but it requires special permissions and will
2032+
* create a UI alert when attempting to run this command.
2033+
*/
2034+
return 0;
2035+
#else
2036+
return check_crontab_process(cmd);
2037+
#endif
2038+
}
2039+
20252040
#define BEGIN_LINE "# BEGIN GIT MAINTENANCE SCHEDULE"
20262041
#define END_LINE "# END GIT MAINTENANCE SCHEDULE"
20272042

0 commit comments

Comments
 (0)