Merge branch 'jc/index-v4'
[gitweb.git] / builtin / fetch.c
index 996a4d62529dea72e6151662f4733d73e24cdb2b..1c8cb62445a3dc7a0ff1ff6d2663faec1bced167 100644 (file)
@@ -240,6 +240,7 @@ static int s_update_ref(const char *action,
 
 static int update_local_ref(struct ref *ref,
                            const char *remote,
+                           const struct ref *remote_ref,
                            struct strbuf *display)
 {
        struct commit *current = NULL, *updated;
@@ -293,13 +294,21 @@ static int update_local_ref(struct ref *ref,
                const char *msg;
                const char *what;
                int r;
-               if (!strncmp(ref->name, "refs/tags/", 10)) {
+               /*
+                * Nicely describe the new ref we're fetching.
+                * Base this on the remote's ref name, as it's
+                * more likely to follow a standard layout.
+                */
+               const char *name = remote_ref ? remote_ref->name : "";
+               if (!prefixcmp(name, "refs/tags/")) {
                        msg = "storing tag";
                        what = _("[new tag]");
-               }
-               else {
+               } else if (!prefixcmp(name, "refs/heads/")) {
                        msg = "storing head";
                        what = _("[new branch]");
+               } else {
+                       msg = "storing ref";
+                       what = _("[new ref]");
                }
 
                if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
@@ -466,7 +475,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 
                        strbuf_reset(&note);
                        if (ref) {
-                               rc |= update_local_ref(ref, what, &note);
+                               rc |= update_local_ref(ref, what, rm, &note);
                                free(ref);
                        } else
                                strbuf_addf(&note, "* %-*s %-*s -> FETCH_HEAD",
@@ -585,7 +594,7 @@ static void find_non_local_tags(struct transport *transport,
 
        for_each_ref(add_existing, &existing_refs);
        for (ref = transport_get_remote_refs(transport); ref; ref = ref->next) {
-               if (prefixcmp(ref->name, "refs/tags"))
+               if (prefixcmp(ref->name, "refs/tags/"))
                        continue;
 
                /*