summaryrefslogtreecommitdiffstats
path: root/builtin/gc.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-11-11 00:01:20 +0100
committerJunio C Hamano <gitster@pobox.com>2021-11-11 00:01:20 +0100
commitc1d16cedd4024884064b9d0834cae4f5506d6221 (patch)
treee02291347381af38e6b39268d0b4351cf43503bd /builtin/gc.c
parentMerge branch 'jc/fix-pull-ff-only-when-already-up-to-date' (diff)
parentmaintenance: disable cron on macOS (diff)
downloadgit-c1d16cedd4024884064b9d0834cae4f5506d6221.tar.xz
git-c1d16cedd4024884064b9d0834cae4f5506d6221.zip
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
Diffstat (limited to 'builtin/gc.c')
-rw-r--r--builtin/gc.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/builtin/gc.c b/builtin/gc.c
index 2670931160..bcef6a4c8d 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -1999,15 +1999,11 @@ static int schtasks_update_schedule(int run_maintenance, int fd)
return schtasks_remove_tasks();
}
-static int is_crontab_available(void)
+MAYBE_UNUSED
+static int check_crontab_process(const char *cmd)
{
- const char *cmd = "crontab";
- int is_available;
struct child_process child = CHILD_PROCESS_INIT;
- if (get_schedule_cmd(&cmd, &is_available))
- return is_available;
-
strvec_split(&child.args, cmd);
strvec_push(&child.args, "-l");
child.no_stdin = 1;
@@ -2022,6 +2018,25 @@ static int is_crontab_available(void)
return 1;
}
+static int is_crontab_available(void)
+{
+ const char *cmd = "crontab";
+ int is_available;
+
+ if (get_schedule_cmd(&cmd, &is_available))
+ return is_available;
+
+#ifdef __APPLE__
+ /*
+ * macOS has cron, but it requires special permissions and will
+ * create a UI alert when attempting to run this command.
+ */
+ return 0;
+#else
+ return check_crontab_process(cmd);
+#endif
+}
+
#define BEGIN_LINE "# BEGIN GIT MAINTENANCE SCHEDULE"
#define END_LINE "# END GIT MAINTENANCE SCHEDULE"