diff options
Diffstat (limited to 'builtin/gc.c')
-rw-r--r-- | builtin/gc.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/builtin/gc.c b/builtin/gc.c index b00b396f55..bcef6a4c8d 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -1049,12 +1049,11 @@ static int maintenance_task_loose_objects(struct maintenance_run_opts *opts) static int incremental_repack_auto_condition(void) { struct packed_git *p; - int enabled; int incremental_repack_auto_limit = 10; int count = 0; - if (git_config_get_bool("core.multiPackIndex", &enabled) || - !enabled) + prepare_repo_settings(the_repository); + if (!the_repository->settings.core_multi_pack_index) return 0; git_config_get_int("maintenance.incremental-repack.auto", @@ -1681,9 +1680,7 @@ static int launchctl_remove_plists(void) static int launchctl_list_contains_plist(const char *name, const char *cmd) { - int result; struct child_process child = CHILD_PROCESS_INIT; - char *uid = launchctl_get_uid(); strvec_split(&child.args, cmd); strvec_pushl(&child.args, "list", name, NULL); @@ -1694,12 +1691,8 @@ static int launchctl_list_contains_plist(const char *name, const char *cmd) if (start_command(&child)) die(_("failed to start launchctl")); - result = finish_command(&child); - - free(uid); - /* Returns failure if 'name' doesn't exist. */ - return !result; + return !finish_command(&child); } static int launchctl_schedule_plist(const char *exec_path, enum schedule_priority schedule) @@ -2006,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; @@ -2029,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" |