X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=inline;f=builtin-checkout.c;h=2708669383e21f038a1404e061b34bc4302e8a93;hb=e07fd15b1295393ddf954b9fdd0c3a961e5509c5;hp=da04eed39104446c7c82dd846f8ddfd785d761e2;hpb=46148dd7ea41de10fc784c247924f73ddb21121b;p=git.git diff --git a/builtin-checkout.c b/builtin-checkout.c index da04eed39..270866938 100644 --- a/builtin-checkout.c +++ b/builtin-checkout.c @@ -302,8 +302,9 @@ static void show_local_changes(struct object *head) static void describe_detached_head(char *msg, struct commit *commit) { struct strbuf sb = STRBUF_INIT; + struct pretty_print_context ctx = {0}; parse_commit(commit); - pretty_print_commit(CMIT_FMT_ONELINE, commit, &sb, 0, NULL, NULL, 0, 0); + pretty_print_commit(CMIT_FMT_ONELINE, commit, &sb, &ctx); fprintf(stderr, "%s %s... %s\n", msg, find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV), sb.buf); strbuf_release(&sb); @@ -396,7 +397,7 @@ static int merge_working_tree(struct checkout_opts *opts, topts.initial_checkout = is_cache_unborn(); topts.update = 1; topts.merge = 1; - topts.gently = opts->merge; + topts.gently = opts->merge && old->commit; topts.verbose_update = !opts->quiet; topts.fn = twoway_merge; topts.dir = xcalloc(1, sizeof(*topts.dir)); @@ -421,7 +422,13 @@ static int merge_working_tree(struct checkout_opts *opts, struct merge_options o; if (!opts->merge) return 1; - parse_commit(old->commit); + + /* + * Without old->commit, the below is the same as + * the two-tree unpack we already tried and failed. + */ + if (!old->commit) + return 1; /* Do more real merge */