X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-checkout.c;h=527781728e0706b906a94ddfb8ee2e8bb06fa05e;hb=9be3614eff36271d5f1cd460a568a219902cb044;hp=e44e238c39a7d4c276edf3bfe054b5929c009eda;hpb=e33fd3c326831e70f6ca078e0f1c26ec147cb5b3;p=git.git diff --git a/builtin-checkout.c b/builtin-checkout.c index e44e238c3..527781728 100644 --- a/builtin-checkout.c +++ b/builtin-checkout.c @@ -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] ", @@ -234,6 +235,10 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec, 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]; @@ -370,6 +375,7 @@ static int merge_working_tree(struct checkout_opts *opts, 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) @@ -752,8 +758,10 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) 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);