Merge branch 'jk/startup-info' into maint
[gitweb.git] / transport.c
index e20bb771faaa56aa876f14f73123e14a71731a1b..095e61f0adde0741a3c95817f10df4b957d473ee 100644 (file)
@@ -678,8 +678,9 @@ struct transport *transport_get(struct remote *remote, const char *url)
                || starts_with(url, "file://")
                || starts_with(url, "git://")
                || starts_with(url, "ssh://")
-               || starts_with(url, "git+ssh://")
-               || starts_with(url, "ssh+git://")) {
+               || starts_with(url, "git+ssh://") /* deprecated - do not use */
+               || starts_with(url, "ssh+git://") /* deprecated - do not use */
+               ) {
                /*
                 * These are builtin smart transports; "allowed" transports
                 * will be checked individually in git_connect.
@@ -983,7 +984,7 @@ int transport_fetch_refs(struct transport *transport, struct ref *refs)
                 * This condition shouldn't be met in a non-deepening fetch
                 * (see builtin/fetch.c:quickfetch()).
                 */
-               heads = xmalloc(nr_refs * sizeof(*heads));
+               ALLOC_ARRAY(heads, nr_refs);
                for (rm = refs; rm; rm = rm->next)
                        heads[nr_heads++] = rm;
        }
@@ -1027,7 +1028,7 @@ int transport_disconnect(struct transport *transport)
  */
 char *transport_anonymize_url(const char *url)
 {
-       char *anon_url, *scheme_prefix, *anon_part;
+       char *scheme_prefix, *anon_part;
        size_t anon_len, prefix_len = 0;
 
        anon_part = strchr(url, '@');
@@ -1061,10 +1062,8 @@ char *transport_anonymize_url(const char *url)
                        goto literal_copy;
                prefix_len = scheme_prefix - url + 3;
        }
-       anon_url = xcalloc(1, 1 + prefix_len + anon_len);
-       memcpy(anon_url, url, prefix_len);
-       memcpy(anon_url + prefix_len, anon_part, anon_len);
-       return anon_url;
+       return xstrfmt("%.*s%.*s", (int)prefix_len, url,
+                      (int)anon_len, anon_part);
 literal_copy:
        return xstrdup(url);
 }