]> asedeno.scripts.mit.edu Git - git.git/blobdiff - remote.c
Merge branch 'tr/workflow-doc'
[git.git] / remote.c
index 3f3c789653a23e829369429da093c1193b53b015..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);
@@ -455,7 +455,7 @@ static int verify_refname(char *name, int is_glob)
  *          and dst pointers are always freeable pointers as well
  *          as the refspec pointer itself.
  */
-void free_refspecs(struct refspec *refspec, int nr_refspec)
+static void free_refspecs(struct refspec *refspec, int nr_refspec)
 {
        int i;
 
@@ -613,7 +613,7 @@ struct refspec *parse_fetch_refspec(int nr_refspec, const char **refspec)
        return parse_refspec_internal(nr_refspec, refspec, 1, 0);
 }
 
-struct refspec *parse_push_refspec(int nr_refspec, const char **refspec)
+static struct refspec *parse_push_refspec(int nr_refspec, const char **refspec)
 {
        return parse_refspec_internal(nr_refspec, refspec, 0, 0);
 }
@@ -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;
 }
 
@@ -783,7 +782,7 @@ struct ref *copy_ref_list(const struct ref *ref)
        return ret;
 }
 
-void free_ref(struct ref *ref)
+static void free_ref(struct ref *ref)
 {
        if (!ref)
                return;