Merge branch 'nd/resolve-ref'
authorJunio C Hamano <gitster@pobox.com>
Fri, 9 Dec 2011 21:37:14 +0000 (13:37 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Dec 2011 21:37:14 +0000 (13:37 -0800)
* nd/resolve-ref:
  Copy resolve_ref() return value for longer use
  Convert many resolve_ref() calls to read_ref*() and ref_exists()

Conflicts:
builtin/fmt-merge-msg.c
builtin/merge.c
refs.c

1  2 
builtin/branch.c
builtin/checkout.c
builtin/commit.c
builtin/fmt-merge-msg.c
builtin/merge.c
builtin/tag.c
cache.h
notes-merge.c
refs.c

Simple merge
Simple merge
Simple merge
index ed95349b424f2f3d2aa671a277b346ae6198d34c,a3ba21520916ce2e244839304def0a748e8a53c7..bdfa0ea05d99089937b9e753cf85a8489a5e27cb
@@@ -414,12 -306,10 +415,13 @@@ int fmt_merge_msg(struct strbuf *in, st
                        strbuf_addch(out, '\n');
  
                for (i = 0; i < origins.nr; i++)
 -                      shortlog(origins.items[i].string, origins.items[i].util,
 -                                      head, &rev, shortlog_len, out);
 +                      shortlog(origins.items[i].string,
 +                               origins.items[i].util,
 +                               head, &rev, opts->shortlog_len, out);
        }
 +
 +      strbuf_complete_line(out);
+       free((char *)current_branch);
        return 0;
  }
  
diff --cc builtin/merge.c
index 7349396d5b44f6ee894e0f0f50e2b66bb31203be,9cda40003e7af5ff55acd2793248f78916ff433d..a1c85344b2b54f957ea69ace864ea99b7d295405
@@@ -412,8 -409,18 +412,8 @@@ static void finish(struct commit *head_
  /* Get the name for the merge commit's message. */
  static void merge_name(const char *remote, struct strbuf *msg)
  {
 -      struct object *remote_head;
 +      struct commit *remote_head;
-       unsigned char branch_head[20], buf_sha[20];
+       unsigned char branch_head[20];
        struct strbuf buf = STRBUF_INIT;
        struct strbuf bname = STRBUF_INIT;
        const char *ptr;
                strbuf_addstr(&truname, "refs/heads/");
                strbuf_addstr(&truname, remote);
                strbuf_setlen(&truname, truname.len - len);
-               if (resolve_ref(truname.buf, buf_sha, 1, NULL)) {
+               if (ref_exists(truname.buf)) {
                        strbuf_addf(msg,
                                    "%s\t\tbranch '%s'%s of .\n",
 -                                  sha1_to_hex(remote_head->sha1),
 +                                  sha1_to_hex(remote_head->object.sha1),
                                    truname.buf + 11,
                                    (early ? " (early part)" : ""));
                        strbuf_release(&truname);
@@@ -1213,13 -1203,13 +1217,13 @@@ int cmd_merge(int argc, const char **ar
                if (!allow_fast_forward)
                        die(_("Non-fast-forward commit does not make sense into "
                            "an empty head"));
 -              remote_head = want_commit(argv[0]);
 +              remote_head = get_merge_parent(argv[0]);
                if (!remote_head)
                        die(_("%s - not something we can merge"), argv[0]);
 -              read_empty(remote_head->sha1, 0);
 -              update_ref("initial pull", "HEAD", remote_head->sha1, NULL, 0,
 -                              DIE_ON_ERR);
 +              read_empty(remote_head->object.sha1, 0);
 +              update_ref("initial pull", "HEAD", remote_head->object.sha1,
 +                         NULL, 0, DIE_ON_ERR);
-               return 0;
+               goto done;
        } else {
                struct strbuf merge_names = STRBUF_INIT;
  
                if (have_message)
                        strbuf_addstr(&msg,
                                " (no commit created; -m option ignored)");
 -              o = want_commit(sha1_to_hex(remoteheads->item->object.sha1));
 -              if (!o) {
 +              commit = remoteheads->item;
-               if (!commit)
-                       return 1;
++              if (!commit) {
+                       ret = 1;
+                       goto done;
+               }
  
                if (checkout_fast_forward(head_commit->object.sha1,
-                                         commit->object.sha1))
-                       return 1;
 -                                        remoteheads->item->object.sha1)) {
++                                        commit->object.sha1)) {
+                       ret = 1;
+                       goto done;
+               }
  
 -              finish(head_commit, o->sha1, msg.buf);
 +              finish(head_commit, commit->object.sha1, msg.buf);
                drop_save();
-               return 0;
+               goto done;
        } else if (!remoteheads->next && common->next)
                ;
                /*
diff --cc builtin/tag.c
Simple merge
diff --cc cache.h
Simple merge
diff --cc notes-merge.c
Simple merge
diff --cc refs.c
index c74b6e2a70222386383edb89789dbb7880768157,44c1c86e187568f8cf1224f2f540cb6b73db3469..f5cb297292f5ae577e3d2719f5f78512aae8cf28
--- 1/refs.c
--- 2/refs.c
+++ b/refs.c
@@@ -334,11 -333,12 +334,11 @@@ static void get_ref_dir(const char *sub
                                        hashclr(sha1);
                                        flag |= REF_ISBROKEN;
                                }
-                       } else if (!resolve_ref(ref, sha1, 1, &flag)) {
 -                      } else
 -                              if (read_ref_full(ref, sha1, 1, &flag)) {
 -                                      hashclr(sha1);
 -                                      flag |= REF_ISBROKEN;
 -                              }
 -                      add_ref(ref, sha1, flag, array, NULL);
++                      } else if (read_ref_full(ref, sha1, 1, &flag)) {
 +                              hashclr(sha1);
 +                              flag |= REF_ISBROKEN;
 +                      }
 +                      add_ref(ref, sha1, flag, 1, array, NULL);
                }
                free(ref);
                closedir(dir);