Merge branch 'maint-1.6.2' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 12 May 2009 16:58:34 +0000 (09:58 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 12 May 2009 16:58:34 +0000 (09:58 -0700)
* maint-1.6.2:
Revert "checkout branch: prime cache-tree fully"

1  2 
builtin-checkout.c
diff --combined builtin-checkout.c
index 15f0c32c7a7ed62afe31e3bafb2d7306ba4a3402,ffdb33aef596740890362a0e237d33131a906f45..dc4bfb5fc08d51644435f158e3b07ffe518ac419
@@@ -179,7 -179,7 +179,7 @@@ static int checkout_merged(int pos, str
        /*
         * NEEDSWORK:
         * There is absolutely no reason to write this as a blob object
 -       * and create a phoney cache entry just to leak.  This hack is
 +       * and create a phony cache entry just to leak.  This hack is
         * primarily to get to the write_entry() machinery that massages
         * the contents to work-tree format and writes out which only
         * allows it for a cache entry.  The code in write_entry() needs
@@@ -293,8 -293,6 +293,8 @@@ static void show_local_changes(struct o
        init_revisions(&rev, NULL);
        rev.abbrev = 0;
        rev.diffopt.output_format |= DIFF_FORMAT_NAME_STATUS;
 +      if (diff_setup_done(&rev.diffopt) < 0)
 +              die("diff_setup_done failed");
        add_pending_object(&rev, head, NULL);
        run_diff_index(&rev, 0);
  }
@@@ -351,11 -349,16 +351,11 @@@ struct branch_info 
  static void setup_branch_path(struct branch_info *branch)
  {
        struct strbuf buf = STRBUF_INIT;
 -      int ret;
  
 -      if ((ret = interpret_nth_last_branch(branch->name, &buf))
 -          && ret == strlen(branch->name)) {
 +      strbuf_branchname(&buf, branch->name);
 +      if (strcmp(buf.buf, branch->name))
                branch->name = xstrdup(buf.buf);
 -              strbuf_splice(&buf, 0, 0, "refs/heads/", 11);
 -      } else {
 -              strbuf_addstr(&buf, "refs/heads/");
 -              strbuf_addstr(&buf, branch->name);
 -      }
 +      strbuf_splice(&buf, 0, 0, "refs/heads/", 11);
        branch->path = strbuf_detach(&buf, NULL);
  }
  
@@@ -365,17 -368,14 +365,14 @@@ static int merge_working_tree(struct ch
        int ret;
        struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
        int newfd = hold_locked_index(lock_file, 1);
-       int reprime_cache_tree = 0;
  
        if (read_cache() < 0)
                return error("corrupt index file");
  
-       cache_tree_free(&active_cache_tree);
        if (opts->force) {
                ret = reset_tree(new->commit->tree, opts, 1);
                if (ret)
                        return ret;
-               reprime_cache_tree = 1;
        } else {
                struct tree_desc trees[2];
                struct tree *tree;
                topts.verbose_update = !opts->quiet;
                topts.fn = twoway_merge;
                topts.dir = xcalloc(1, sizeof(*topts.dir));
 -              topts.dir->show_ignored = 1;
 +              topts.dir->flags |= DIR_SHOW_IGNORED;
                topts.dir->exclude_per_dir = ".gitignore";
                tree = parse_tree_indirect(old->commit->object.sha1);
                init_tree_desc(&trees[0], tree->buffer, tree->size);
                init_tree_desc(&trees[1], tree->buffer, tree->size);
  
                ret = unpack_trees(2, trees, &topts);
-               if (ret != -1) {
-                       reprime_cache_tree = 1;
-               } else {
+               if (ret == -1) {
                        /*
                         * Unpack couldn't do a trivial merge; either
                         * give up or do a real merge, depending on
                }
        }
  
-       if (reprime_cache_tree)
-               prime_cache_tree(&active_cache_tree, new->commit->tree);
        if (write_cache(newfd, active_cache, active_nr) ||
            commit_locked_index(lock_file))
                die("unable to write new index file");
@@@ -558,8 -554,8 +551,8 @@@ static int switch_branches(struct check
  
        if (!old.commit && !opts->force) {
                if (!opts->quiet) {
 -                      fprintf(stderr, "warning: You appear to be on a branch yet to be born.\n");
 -                      fprintf(stderr, "warning: Forcing checkout of %s.\n", new->name);
 +                      warning("You appear to be on a branch yet to be born.");
 +                      warning("Forcing checkout of %s.", new->name);
                }
                opts->force = 1;
        }
@@@ -738,11 -734,12 +731,11 @@@ no_reference
  
        if (opts.new_branch) {
                struct strbuf buf = STRBUF_INIT;
 -              strbuf_addstr(&buf, "refs/heads/");
 -              strbuf_addstr(&buf, opts.new_branch);
 +              if (strbuf_check_branch_ref(&buf, opts.new_branch))
 +                      die("git checkout: we do not like '%s' as a branch name.",
 +                          opts.new_branch);
                if (!get_sha1(buf.buf, rev))
                        die("git checkout: branch %s already exists", opts.new_branch);
 -              if (check_ref_format(buf.buf))
 -                      die("git checkout: we do not like '%s' as a branch name.", opts.new_branch);
                strbuf_release(&buf);
        }