]> asedeno.scripts.mit.edu Git - git.git/blobdiff - remote.c
Merge branch 'tr/workflow-doc'
[git.git] / remote.c
index c45d96e98fffe3411284144b6d836cf499d42ba4..8a04066d6142823183033aaff8754febe31ad1b0 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -245,7 +245,7 @@ static void read_branches_file(struct remote *remote)
 {
        const char *slash = strchr(remote->name, '/');
        char *frag;
-       struct strbuf branch;
+       struct strbuf branch = STRBUF_INIT;
        int n = slash ? slash - remote->name : 1000;
        FILE *f = fopen(git_path("branches/%.*s", n, remote->name), "r");
        char *s, *p;
@@ -283,7 +283,6 @@ static void read_branches_file(struct remote *remote)
         * #branch specified.  The "master" (or specified) branch is
         * fetched and stored in the local branch of the same name.
         */
-       strbuf_init(&branch, 0);
        frag = strchr(p, '#');
        if (frag) {
                *(frag++) = '\0';
@@ -342,13 +341,14 @@ static int handle_config(const char *key, const char *value, void *cb)
        if (prefixcmp(key,  "remote."))
                return 0;
        name = key + 7;
+       if (*name == '/') {
+               warning("Config remote shorthand cannot begin with '/': %s",
+                       name);
+               return 0;
+       }
        subkey = strrchr(name, '.');
        if (!subkey)
                return error("Config with no key for remote %s", name);
-       if (*subkey == '/') {
-               warning("Config remote shorthand cannot begin with '/': %s", name);
-               return 0;
-       }
        remote = make_remote(name, subkey - name);
        if (!strcmp(subkey, ".mirror"))
                remote->mirror = git_config_bool(key, value);
@@ -751,8 +751,7 @@ int remote_find_tracking(struct remote *remote, struct refspec *refspec)
 
 struct ref *alloc_ref(unsigned namelen)
 {
-       struct ref *ret = xmalloc(sizeof(struct ref) + namelen);
-       memset(ret, 0, sizeof(struct ref) + namelen);
+       struct ref *ret = xcalloc(1, sizeof(struct ref) + namelen);
        return ret;
 }