From: Junio C Hamano Date: Fri, 9 Dec 2011 21:37:14 +0000 (-0800) Subject: Merge branch 'nd/resolve-ref' X-Git-Tag: v1.7.9-rc0~82 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b7f7c07977ab6e41899b835b873a1ac499eaa2b3;p=git.git Merge branch 'nd/resolve-ref' * 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 --- b7f7c07977ab6e41899b835b873a1ac499eaa2b3 diff --cc builtin/fmt-merge-msg.c index ed95349b4,a3ba21520..bdfa0ea05 --- a/builtin/fmt-merge-msg.c +++ b/builtin/fmt-merge-msg.c @@@ -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 7349396d5,9cda40003..a1c85344b --- a/builtin/merge.c +++ b/builtin/merge.c @@@ -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; @@@ -477,10 -479,10 +477,10 @@@ 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; @@@ -1328,17 -1316,21 +1332,21 @@@ 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 refs.c index c74b6e2a7,44c1c86e1..f5cb29729 --- a/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);