From: Junio C Hamano Date: Thu, 21 Jan 2010 04:28:51 +0000 (-0800) Subject: Merge branch 'jc/checkout-merge-base' X-Git-Tag: v1.7.0-rc0~51 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b3ce9a0874cc7ec1d0fd5ead97d78a428d1fdd75?hp=-c Merge branch 'jc/checkout-merge-base' * jc/checkout-merge-base: Fix "checkout A..." synonym for "checkout A...HEAD" on Windows --- b3ce9a0874cc7ec1d0fd5ead97d78a428d1fdd75 diff --combined builtin-checkout.c index d0b1a728cb,ad3c01fdd9..527781728e --- a/builtin-checkout.c +++ b/builtin-checkout.c @@@ -17,7 -17,6 +17,7 @@@ #include "blob.h" #include "xdiff-interface.h" #include "ll-merge.h" +#include "resolve-undo.h" static const char * const checkout_usage[] = { "git checkout [options] ", @@@ -168,7 -167,7 +168,7 @@@ static int checkout_merged(int pos, str fill_mm(active_cache[pos+2]->sha1, &theirs); status = ll_merge(&result_buf, path, &ancestor, - &ours, "ours", &theirs, "theirs", 1); + &ours, "ours", &theirs, "theirs", 0); free(ancestor.ptr); free(ours.ptr); free(theirs.ptr); @@@ -235,10 -234,6 +235,10 @@@ static int checkout_paths(struct tree * if (report_path_error(ps_matched, pathspec, 0)) return 1; + /* "checkout -m path" to recreate conflicted state */ + if (opts->merge) + unmerge_cache(pathspec); + /* Any unmerged paths? */ for (pos = 0; pos < active_nr; pos++) { struct cache_entry *ce = active_cache[pos]; @@@ -307,9 -302,8 +307,9 @@@ static void show_local_changes(struct o 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); @@@ -375,7 -369,6 +375,7 @@@ static int merge_working_tree(struct ch if (read_cache_preload(NULL) < 0) return error("corrupt index file"); + resolve_undo_clear(); if (opts->force) { ret = reset_tree(new->commit->tree, opts, 1); if (ret) @@@ -403,7 -396,7 +403,7 @@@ 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)); @@@ -428,13 -421,7 +428,13 @@@ 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 */ @@@ -758,8 -745,10 +758,10 @@@ int cmd_checkout(int argc, const char * new.name = arg; if ((new.commit = lookup_commit_reference_gently(rev, 1))) { setup_branch_path(&new); - if (resolve_ref(new.path, rev, 1, NULL)) - new.commit = lookup_commit_reference(rev); + + if ((check_ref_format(new.path) == CHECK_REF_FORMAT_OK) && + resolve_ref(new.path, rev, 1, NULL)) + ; else new.path = NULL; parse_commit(new.commit);