diff options
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/fsck.c | 3 | ||||
-rw-r--r-- | builtin/gc.c | 27 | ||||
-rw-r--r-- | builtin/pull.c | 29 |
3 files changed, 51 insertions, 8 deletions
diff --git a/builtin/fsck.c b/builtin/fsck.c index d87c28a1cc..27b9e78094 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -605,7 +605,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data) struct object *obj; enum object_type type = OBJ_NONE; unsigned long size; - void *contents; + void *contents = NULL; int eaten; struct object_info oi = OBJECT_INFO_INIT; struct object_id real_oid = *null_oid(); @@ -630,6 +630,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data) path); if (err < 0) { errors_found |= ERROR_OBJECT; + free(contents); return 0; /* keep checking other objects */ } 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" diff --git a/builtin/pull.c b/builtin/pull.c index efe4f4a81f..127798ba84 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -937,6 +937,33 @@ static int get_can_ff(struct object_id *orig_head, return ret; } +/* + * Is orig_head a descendant of _all_ merge_heads? + * Unfortunately is_descendant_of() cannot be used as it asks + * if orig_head is a descendant of at least one of them. + */ +static int already_up_to_date(struct object_id *orig_head, + struct oid_array *merge_heads) +{ + int i; + struct commit *ours; + + ours = lookup_commit_reference(the_repository, orig_head); + for (i = 0; i < merge_heads->nr; i++) { + struct commit_list *list = NULL; + struct commit *theirs; + int ok; + + theirs = lookup_commit_reference(the_repository, &merge_heads->oid[i]); + commit_list_insert(theirs, &list); + ok = repo_is_descendant_of(the_repository, ours, list); + free_commit_list(list); + if (!ok) + return 0; + } + return 1; +} + static void show_advice_pull_non_ff(void) { advise(_("You have divergent branches and need to specify how to reconcile them.\n" @@ -1078,7 +1105,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix) /* ff-only takes precedence over rebase */ if (opt_ff && !strcmp(opt_ff, "--ff-only")) { - if (!can_ff) + if (!can_ff && !already_up_to_date(&orig_head, &merge_heads)) die_ff_impossible(); opt_rebase = REBASE_FALSE; } |