X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-checkout.c;h=793542eb062e7a17ac7bf9331c578ab4dff00aab;hb=e3d42c4773bccebb50f01b108d20b06c6a11e615;hp=64f3a11ae1d415c466def8eccefe9dbc5b6b3926;hpb=a24a32ddb30c904d244fe911f4d9e7e3924fdac7;p=git.git diff --git a/builtin-checkout.c b/builtin-checkout.c index 64f3a11ae..793542eb0 100644 --- a/builtin-checkout.c +++ b/builtin-checkout.c @@ -397,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)); @@ -422,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 */ @@ -690,7 +696,10 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) * case 3: git checkout [] * * With no paths, if is a commit, that is to - * switch to the branch or detach HEAD at it. + * switch to the branch or detach HEAD at it. As a special case, + * if is A...B (missing A or B means HEAD but you can + * omit at most one side), and if there is a unique merge base + * between A and B, A...B names that merge base. * * With no paths, if is _not_ a commit, no -t nor -b * was given, and there is a tracking branch whose name is @@ -716,7 +725,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) if (!strcmp(arg, "-")) arg = "@{-1}"; - if (get_sha1(arg, rev)) { + if (get_sha1_mb(arg, rev)) { if (has_dash_dash) /* case (1) */ die("invalid reference: %s", arg); if (!patch_mode &&