t: wrap complicated expect_code users in a block
[gitweb.git] / http-push.c
index 6c3cc1725a9461876c7db11b9818eb553afb2fc2..bfb1c9605b46e8308e91a80c38643ea920cd4d1b 100644 (file)
@@ -199,7 +199,7 @@ static void curl_setup_http(CURL *curl, const char *url,
        curl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);
 #ifndef NO_CURL_IOCTL
        curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);
-       curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &buffer);
+       curl_easy_setopt(curl, CURLOPT_IOCTLDATA, buffer);
 #endif
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn);
        curl_easy_setopt(curl, CURLOPT_NOBODY, 0);
@@ -365,7 +365,6 @@ static void start_put(struct transfer_request *request)
        hdrlen = sprintf(hdr, "%s %lu", typename(type), len) + 1;
 
        /* Set it up */
-       memset(&stream, 0, sizeof(stream));
        git_deflate_init(&stream, zlib_compression_level);
        size = git_deflate_bound(&stream, len + hdrlen);
        strbuf_init(&request->buffer.buf, size);
@@ -1577,6 +1576,9 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
        if (buffer.len == 0)
                return;
 
+       /* Cut off trailing newline. */
+       strbuf_rtrim(&buffer);
+
        /* If it's a symref, set the refname; otherwise try for a sha1 */
        if (skip_prefix(buffer.buf, "ref: ", &name)) {
                *symref = xmemdupz(name, buffer.len - (name - buffer.buf));