Merge branch 'jk/maint-merge-msg-fix'
authorJunio C Hamano <gitster@pobox.com>
Sun, 16 Aug 2009 11:13:04 +0000 (04:13 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 16 Aug 2009 11:13:04 +0000 (04:13 -0700)
* jk/maint-merge-msg-fix:
merge: indicate remote tracking branches in merge message
merge: fix incorrect merge message for ambiguous tag/branch
add tests for merge message headings

1  2 
builtin-merge.c
diff --combined builtin-merge.c
index 0b12fb31558d1cb59f9e2a8ab049ea944fe3060e,f4de73fa9d8d4ca4d311cb86d6901346ceb0d19f..b6b84286b26a4317dfd5185ae83fd861c6f9fa7d
@@@ -358,6 -358,7 +358,7 @@@ static void merge_name(const char *remo
        struct strbuf buf = STRBUF_INIT;
        struct strbuf bname = STRBUF_INIT;
        const char *ptr;
+       char *found_ref;
        int len, early;
  
        strbuf_branchname(&bname, remote);
        if (!remote_head)
                die("'%s' does not point to a commit", remote);
  
-       strbuf_addstr(&buf, "refs/heads/");
-       strbuf_addstr(&buf, remote);
-       resolve_ref(buf.buf, branch_head, 0, NULL);
-       if (!hashcmp(remote_head->sha1, branch_head)) {
-               strbuf_addf(msg, "%s\t\tbranch '%s' of .\n",
-                       sha1_to_hex(branch_head), remote);
-               goto cleanup;
+       if (dwim_ref(remote, strlen(remote), branch_head, &found_ref) > 0) {
+               if (!prefixcmp(found_ref, "refs/heads/")) {
+                       strbuf_addf(msg, "%s\t\tbranch '%s' of .\n",
+                                   sha1_to_hex(branch_head), remote);
+                       goto cleanup;
+               }
+               if (!prefixcmp(found_ref, "refs/remotes/")) {
+                       strbuf_addf(msg, "%s\t\tremote branch '%s' of .\n",
+                                   sha1_to_hex(branch_head), remote);
+                       goto cleanup;
+               }
        }
  
        /* See if remote matches <name>^^^.. or <name>~<number> */
@@@ -594,7 -598,7 +598,7 @@@ static int try_merge_strategy(const cha
                discard_cache();
                if (read_cache() < 0)
                        die("failed to read the cache");
 -              return -ret;
 +              return ret;
        }
  }