fast-export: Do parent rewriting to avoid dropping relevant commits
[gitweb.git] / branch.c
index d20fb0490bc4ea8dc21978596a46f61a625da951..62030af4b51abbfb9c488dbf018770f3b3606789 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -65,12 +65,23 @@ void install_branch_config(int flag, const char *local, const char *origin, cons
                git_config_set(key.buf, "true");
        }
 
-       if (flag & BRANCH_CONFIG_VERBOSE)
-               printf("Branch %s set up to track %s branch %s %s.\n",
-                      local,
-                      origin ? "remote" : "local",
-                      remote,
-                      rebasing ? "by rebasing" : "by merging");
+       if (flag & BRANCH_CONFIG_VERBOSE) {
+               strbuf_reset(&key);
+
+               strbuf_addstr(&key, origin ? "remote" : "local");
+
+               /* Are we tracking a proper "branch"? */
+               if (!prefixcmp(remote, "refs/heads/")) {
+                       strbuf_addf(&key, " branch %s", remote + 11);
+                       if (origin)
+                               strbuf_addf(&key, " from %s", origin);
+               }
+               else
+                       strbuf_addf(&key, " ref %s", remote);
+               printf("Branch %s set up to track %s%s.\n",
+                      local, key.buf,
+                      rebasing ? " by rebasing" : "");
+       }
        strbuf_release(&key);
 }
 
@@ -123,16 +134,8 @@ void create_branch(const char *head,
        char *real_ref, msg[PATH_MAX + 20];
        struct strbuf ref = STRBUF_INIT;
        int forcing = 0;
-       int len;
-
-       len = strlen(name);
-       if (interpret_nth_last_branch(name, &ref) != len) {
-               strbuf_reset(&ref);
-               strbuf_add(&ref, name, len);
-       }
-       strbuf_splice(&ref, 0, 0, "refs/heads/", 11);
 
-       if (check_ref_format(ref.buf))
+       if (strbuf_check_branch_ref(&ref, name))
                die("'%s' is not a valid branch name.", name);
 
        if (resolve_ref(ref.buf, sha1, 1, NULL)) {