Code

Merge branch 'jc/checkout-merge-base'
authorJunio C Hamano <gitster@pobox.com>
Thu, 21 Jan 2010 04:28:51 +0000 (20:28 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 21 Jan 2010 04:28:51 +0000 (20:28 -0800)
* jc/checkout-merge-base:
  Fix "checkout A..." synonym for "checkout A...HEAD" on Windows

1  2 
builtin-checkout.c

diff --combined builtin-checkout.c
index d0b1a728cb81e041c685b37014688f0684779132,ad3c01fdd9d5cd8587661e835e7d4c56a07702a6..527781728e0706b906a94ddfb8ee2e8bb06fa05e
@@@ -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] <branch>",
@@@ -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)
                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));
                        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);