Merge branch 'js/maint-submodule-checkout'
authorJunio C Hamano <gitster@pobox.com>
Wed, 8 Apr 2009 05:33:02 +0000 (22:33 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Apr 2009 05:33:02 +0000 (22:33 -0700)
* js/maint-submodule-checkout:
Fix 'git checkout <submodule>' to update the index

1  2 
builtin-checkout.c
diff --combined builtin-checkout.c
index 33d1fecb6251b4922666255817addeb9f672fa29,c0abe1ca77b5a7a3120ec1b0e422950f8d151817..2e4fe1a4533b852fa6bfda81dd594c6cf6fb5b8f
@@@ -53,9 -53,6 +53,6 @@@ static int update_some(const unsigned c
        int len;
        struct cache_entry *ce;
  
-       if (S_ISGITLINK(mode))
-               return 0;
        if (S_ISDIR(mode))
                return READ_TREE_RECURSIVE;
  
@@@ -295,8 -292,6 +292,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);
  }
@@@ -353,11 -348,16 +350,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);
  }
  
@@@ -402,7 -402,7 +399,7 @@@ static int merge_working_tree(struct ch
                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);
@@@ -553,8 -553,8 +550,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;
        }
@@@ -733,11 -733,12 +730,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);
        }