Code

t5541: check error message against the real port number used
[git.git] / remote-curl.c
index 13d8ceede345893b76fa2f15597d90304a50cf8e..f48485931fc5e5ec9c17700801dd88d00ff40e01 100644 (file)
@@ -227,6 +227,8 @@ static struct ref *parse_info_refs(struct discovery *heads)
                if (data[i] == '\t')
                        mid = &data[i];
                if (data[i] == '\n') {
+                       if (mid - start != 40)
+                               die("%sinfo/refs not valid: is this a git repository?", url);
                        data[i] = 0;
                        ref_name = mid + 1;
                        ref = xmalloc(sizeof(struct ref) +
@@ -347,7 +349,7 @@ static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)
 }
 #endif
 
-static size_t rpc_in(const void *ptr, size_t eltsize,
+static size_t rpc_in(char *ptr, size_t eltsize,
                size_t nmemb, void *buffer_)
 {
        size_t size = eltsize * nmemb;
@@ -471,7 +473,7 @@ static int post_rpc(struct rpc_state *rpc)
                 * the transfer time.
                 */
                size_t size;
-               z_stream stream;
+               git_zstream stream;
                int ret;
 
                memset(&stream, 0, sizeof(stream));
@@ -795,7 +797,7 @@ static int push(int nr_spec, char **specs)
 static void parse_push(struct strbuf *buf)
 {
        char **specs = NULL;
-       int alloc_spec = 0, nr_spec = 0, i;
+       int alloc_spec = 0, nr_spec = 0, i, ret;
 
        do {
                if (!prefixcmp(buf->buf, "push ")) {
@@ -807,19 +809,22 @@ static void parse_push(struct strbuf *buf)
 
                strbuf_reset(buf);
                if (strbuf_getline(buf, stdin, '\n') == EOF)
-                       return;
+                       goto free_specs;
                if (!*buf->buf)
                        break;
        } while (1);
 
-       if (push(nr_spec, specs))
+       ret = push(nr_spec, specs);
+       printf("\n");
+       fflush(stdout);
+
+       if (ret)
                exit(128); /* error already reported */
+
+ free_specs:
        for (i = 0; i < nr_spec; i++)
                free(specs[i]);
        free(specs);
-
-       printf("\n");
-       fflush(stdout);
 }
 
 int main(int argc, const char **argv)