{"thread":{"id":"27243","subject":"[PATCH v3 1/4] t5541-http-push: add test for chunked","startedAt":"2011-05-03T15:47:25Z","lastAt":"2011-05-04T20:28:37Z","messageCount":20,"participants":["Tay Ray Chuan","Shawn Pearce","Junio C Hamano","Jakub Narebski"],"isPatch":true,"patchVersion":3,"patchTotal":4},"messages":[{"id":"166943","messageId":"1304437649-7052-1-git-send-email-rctay89@gmail.com","threadId":"27243","inReplyTo":null,"subject":"[PATCH v3 0/4] http cleanups","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2011-05-03T15:47:25Z","receivedAt":"2011-05-03T15:47:25Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"This is a re-roll of dm/http-cleanup. I've also included a test for\nchunked http pushes that has been sitting on my side for some time.\n\nNote to Junio: these patches should apply safely on\nsp/maint-clear-postfields. Actually, the first patch depends on it.\n\n[1/4] t5541-http-push: add test for chunked\n[2/4] http: make curl callbacks match contracts from curl header\n[3/4] http-push: use const for strings in signatures\n[4/4] http-push: refactor curl_easy_setup madness\n\n http-push.c          |  152 +++++++++++++++++---------------------------------\n http-walker.c        |    4 +-\n http.c               |   12 ++--\n http.h               |    6 +-\n remote-curl.c        |    2 +-\n t/t5541-http-push.sh |   28 +++++++++-\n 6 files changed, 90 insertions(+), 114 deletions(-)\n\n-- \n1.7.3.3.585.g74f6e\n"},{"id":"166940","messageId":"1304437649-7052-2-git-send-email-rctay89@gmail.com","threadId":"27243","inReplyTo":"1304437649-7052-1-git-send-email-rctay89@gmail.com","subject":"[PATCH v3 1/4] t5541-http-push: add test for chunked","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2011-05-03T15:47:26Z","receivedAt":"2011-05-03T15:47:26Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Trigger the chunked type of pushing for smart HTTP. This can serve as a\nregression test for the issue fixed in 1e41827 (http: clear POSTFIELDS\nwhen initializing a slot).\n\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n\nNew.\n\n t/t5541-http-push.sh |   28 ++++++++++++++++++++++++++--\n 1 files changed, 26 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh\nindex 0492877..f589221 100755\n--- a/t/t5541-http-push.sh\n+++ b/t/t5541-http-push.sh\n@@ -65,14 +65,16 @@ test_expect_success 'clone remote repository' '\n \tgit clone $HTTPD_URL/smart/test_repo.git test_repo_clone\n '\n \n-test_expect_success 'push to remote repository' '\n+test_expect_success 'push to remote repository (standard)' '\n \tcd \"$ROOT_PATH\"/test_repo_clone &&\n \t: >path2 &&\n \tgit add path2 &&\n \ttest_tick &&\n \tgit commit -m path2 &&\n \tHEAD=$(git rev-parse --verify HEAD) &&\n-\tgit push &&\n+\tGIT_CURL_VERBOSE=1 git push -v -v 2>err &&\n+\t! grep \"Expect: 100-continue\" err &&\n+\tgrep \"POST git-receive-pack (376 bytes)\" err &&\n \t(cd \"$HTTPD_DOCUMENT_ROOT_PATH\"/test_repo.git &&\n \t test $HEAD = $(git rev-parse --verify HEAD))\n '\n@@ -140,5 +142,27 @@ test_expect_success C_LOCALE_OUTPUT 'push fails for non-fast-forward refs unmatc\n \t\toutput\n '\n \n+test_expect_success 'push (chunked)' '\n+\tBRANCH=master-chunked &&\n+\tREPO=test_repo_chunked &&\n+\n+\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH\" &&\n+\t cp -R test_repo.git $REPO) &&\n+\tgit remote set-url origin $HTTPD_URL/smart/$REPO &&\n+\n+\t# to trigger chunked pushing, we need a sufficiently large pack - use\n+\t# git v0.99\n+\tGIT_REPO=$TEST_DIRECTORY/../.git &&\n+\ttest -d $GIT_REPO &&\n+\techo $GIT_REPO/objects > .git/objects/info/alternates &&\n+\tgit fetch $GIT_REPO refs/tags/v0.99 &&\n+\tgit branch $BRANCH FETCH_HEAD &&\n+\tBRANCH_REF=$(git rev-parse --verify refs/heads/$BRANCH) &&\n+\tgit push -v -v origin $BRANCH 2>err &&\n+\tgrep \"POST git-receive-pack (chunked)\" err &&\n+\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH\"/$REPO &&\n+\t test $BRANCH_REF = $(git rev-parse --verify refs/heads/$BRANCH))\n+'\n+\n stop_httpd\n test_done\n-- \n1.7.3.3.585.g74f6e\n"},{"id":"166942","messageId":"1304437649-7052-3-git-send-email-rctay89@gmail.com","threadId":"27243","inReplyTo":"1304437649-7052-2-git-send-email-rctay89@gmail.com","subject":"[PATCH v3 2/4] http: make curl callbacks match contracts from curl header","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2011-05-03T15:47:27Z","receivedAt":"2011-05-03T15:47:27Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"From: Dan McGee <dpmcgee@gmail.com>\n\nYes, these don't match perfectly with the void* first parameter of the\nfread/fwrite in the standard library, but they do match the curl\nexpected method signature. This is needed when a refactor passes a\ncurl_write_callback around, which would otherwise give incorrect\nparameter warnings.\n\nSigned-off-by: Dan McGee <dpmcgee@gmail.com>\n---\nUnchanged.\n\n http-walker.c |    4 ++--\n http.c        |   12 ++++++------\n http.h        |    6 +++---\n remote-curl.c |    2 +-\n 4 files changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/http-walker.c b/http-walker.c\nindex 9bc8114..51a906e 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -185,7 +185,7 @@ static void process_alternates_response(void *callback_data)\n \tstruct active_request_slot *slot = alt_req->slot;\n \tstruct alt_base *tail = cdata->alt;\n \tconst char *base = alt_req->base;\n-\tstatic const char null_byte = '\\0';\n+\tconst char null_byte = '\\0';\n \tchar *data;\n \tint i = 0;\n \n@@ -218,7 +218,7 @@ static void process_alternates_response(void *callback_data)\n \t\t}\n \t}\n \n-\tfwrite_buffer(&null_byte, 1, 1, alt_req->buffer);\n+\tfwrite_buffer((char *)&null_byte, 1, 1, alt_req->buffer);\n \talt_req->buffer->len--;\n \tdata = alt_req->buffer->buf;\n \ndiff --git a/http.c b/http.c\nindex b27bb57..b2ae8de 100644\n--- a/http.c\n+++ b/http.c\n@@ -60,7 +60,7 @@ static struct curl_slist *no_pragma_header;\n \n static struct active_request_slot *active_queue_head;\n \n-size_t fread_buffer(void *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n+size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n {\n \tsize_t size = eltsize * nmemb;\n \tstruct buffer *buffer = buffer_;\n@@ -92,7 +92,7 @@ curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp)\n }\n #endif\n \n-size_t fwrite_buffer(const void *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n+size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n {\n \tsize_t size = eltsize * nmemb;\n \tstruct strbuf *buffer = buffer_;\n@@ -102,7 +102,7 @@ size_t fwrite_buffer(const void *ptr, size_t eltsize, size_t nmemb, void *buffer\n \treturn size;\n }\n \n-size_t fwrite_null(const void *ptr, size_t eltsize, size_t nmemb, void *strbuf)\n+size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf)\n {\n \tdata_received++;\n \treturn eltsize * nmemb;\n@@ -1167,7 +1167,7 @@ abort:\n }\n \n /* Helpers for fetching objects (loose) */\n-static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,\n+static size_t fwrite_sha1_file(char *ptr, size_t eltsize, size_t nmemb,\n \t\t\t       void *data)\n {\n \tunsigned char expn[4096];\n@@ -1184,7 +1184,7 @@ static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,\n \t} while (posn < size);\n \n \tfreq->stream.avail_in = size;\n-\tfreq->stream.next_in = ptr;\n+\tfreq->stream.next_in = (void *)ptr;\n \tdo {\n \t\tfreq->stream.next_out = expn;\n \t\tfreq->stream.avail_out = sizeof(expn);\n@@ -1203,7 +1203,7 @@ struct http_object_request *new_http_object_request(const char *base_url,\n \tchar *filename;\n \tchar prevfile[PATH_MAX];\n \tint prevlocal;\n-\tunsigned char prev_buf[PREV_BUF_SIZE];\n+\tchar prev_buf[PREV_BUF_SIZE];\n \tssize_t prev_read = 0;\n \tlong prev_posn = 0;\n \tchar range[RANGE_HEADER_SIZE];\ndiff --git a/http.h b/http.h\nindex e9ed3c2..19b7134 100644\n--- a/http.h\n+++ b/http.h\n@@ -66,9 +66,9 @@ struct buffer {\n };\n \n /* Curl request read/write callbacks */\n-extern size_t fread_buffer(void *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n-extern size_t fwrite_buffer(const void *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n-extern size_t fwrite_null(const void *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n+extern size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n+extern size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n+extern size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n #ifndef NO_CURL_IOCTL\n extern curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp);\n #endif\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 775d614..17d8a9b 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -347,7 +347,7 @@ static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)\n }\n #endif\n \n-static size_t rpc_in(const void *ptr, size_t eltsize,\n+static size_t rpc_in(char *ptr, size_t eltsize,\n \t\tsize_t nmemb, void *buffer_)\n {\n \tsize_t size = eltsize * nmemb;\n-- \n1.7.3.3.585.g74f6e\n"},{"id":"166941","messageId":"1304437649-7052-4-git-send-email-rctay89@gmail.com","threadId":"27243","inReplyTo":"1304437649-7052-3-git-send-email-rctay89@gmail.com","subject":"[PATCH v3 3/4] http-push: use const for strings in signatures","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2011-05-03T15:47:28Z","receivedAt":"2011-05-03T15:47:28Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"From: Dan McGee <dpmcgee@gmail.com>\n\nSigned-off-by: Dan McGee <dpmcgee@gmail.com>\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n\nSplit off from patch #4.\n\n http-push.c |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex d18346c..0fce38d 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -169,7 +169,7 @@ enum dav_header_flag {\n \tDAV_HEADER_TIMEOUT = (1u << 2)\n };\n \n-static char *xml_entities(char *s)\n+static char *xml_entities(const char *s)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \twhile (*s) {\n@@ -797,7 +797,7 @@ static void handle_new_lock_ctx(struct xml_ctx *ctx, int tag_closed)\n \t}\n }\n \n-static void one_remote_ref(char *refname);\n+static void one_remote_ref(const char *refname);\n \n static void\n xml_start_tag(void *userData, const char *name, const char **atts)\n@@ -1471,7 +1471,7 @@ static int update_remote(unsigned char *sha1, struct remote_lock *lock)\n \n static struct ref *remote_refs;\n \n-static void one_remote_ref(char *refname)\n+static void one_remote_ref(const char *refname)\n {\n \tstruct ref *ref;\n \tstruct object *obj;\n@@ -1660,7 +1660,7 @@ static int verify_merge_base(unsigned char *head_sha1, unsigned char *branch_sha\n \treturn (merge_bases && !merge_bases->next && merge_bases->item == branch);\n }\n \n-static int delete_remote_branch(char *pattern, int force)\n+static int delete_remote_branch(const char *pattern, int force)\n {\n \tstruct ref *refs = remote_refs;\n \tstruct ref *remote_ref = NULL;\n-- \n1.7.3.3.585.g74f6e\n"},{"id":"166944","messageId":"1304437649-7052-5-git-send-email-rctay89@gmail.com","threadId":"27243","inReplyTo":"1304437649-7052-4-git-send-email-rctay89@gmail.com","subject":"[PATCH v3 4/4] http-push: refactor curl_easy_setup madness","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2011-05-03T15:47:29Z","receivedAt":"2011-05-03T15:47:29Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"From: Dan McGee <dpmcgee@gmail.com>\n\nWe were doing (nearly) the same thing all over the place, in slightly\ndifferent orders, different variable names, etc. Refactor most calls\ninto two helper functions, one for GET and one for everything else, that\ndo the heavy lifting leaving most callsites a lot cleaner in the\nprocess.\n\nNote that the setting of CURLOPT_PUT at the callsites of\ncurl_setup_http() which previously didn't do it (eg.\nlocking_available(), remote_ls()) is safe, since that\noption is deprecated in libcurl in place of, and has the same effect as,\nCURLOPT_UPLOAD.\n\nSigned-off-by: Dan McGee <dpmcgee@gmail.com>\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n\nInserted the second paragraph on CURLOPT_PUT and CURLOPT_UPLOAD.\n\n http-push.c |  144 ++++++++++++++++++++---------------------------------------\n 1 files changed, 48 insertions(+), 96 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex 0fce38d..28bfe76 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -197,6 +197,34 @@ static char *xml_entities(const char *s)\n \treturn strbuf_detach(&buf, NULL);\n }\n \n+static void curl_setup_http_get(CURL *curl, const char *url,\n+\t\tconst char *custom_req)\n+{\n+\tcurl_easy_setopt(curl, CURLOPT_HTTPGET, 1);\n+\tcurl_easy_setopt(curl, CURLOPT_URL, url);\n+\tcurl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);\n+\tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n+}\n+\n+static void curl_setup_http(CURL *curl, const char *url,\n+\t\tconst char *custom_req, struct buffer *buffer,\n+\t\tcurl_write_callback write_fn)\n+{\n+\tcurl_easy_setopt(curl, CURLOPT_PUT, 1);\n+\tcurl_easy_setopt(curl, CURLOPT_URL, url);\n+\tcurl_easy_setopt(curl, CURLOPT_INFILE, buffer);\n+\tcurl_easy_setopt(curl, CURLOPT_INFILESIZE, buffer->buf.len);\n+\tcurl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);\n+#ifndef NO_CURL_IOCTL\n+\tcurl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n+\tcurl_easy_setopt(curl, CURLOPT_IOCTLDATA, &buffer);\n+#endif\n+\tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn);\n+\tcurl_easy_setopt(curl, CURLOPT_NOBODY, 0);\n+\tcurl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);\n+\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1);\n+}\n+\n static struct curl_slist *get_dav_token_headers(struct remote_lock *lock, enum dav_header_flag options)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n@@ -272,11 +300,8 @@ static void start_mkcol(struct transfer_request *request)\n \tslot = get_active_slot();\n \tslot->callback_func = process_response;\n \tslot->callback_data = request;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1); /* undo PUT setup */\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, request->url);\n+\tcurl_setup_http_get(slot->curl, request->url, DAV_MKCOL);\n \tcurl_easy_setopt(slot->curl, CURLOPT_ERRORBUFFER, request->errorstr);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_MKCOL);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n \n \tif (start_active_slot(slot)) {\n \t\trequest->slot = slot;\n@@ -395,19 +420,8 @@ static void start_put(struct transfer_request *request)\n \tslot = get_active_slot();\n \tslot->callback_func = process_response;\n \tslot->callback_data = request;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILE, &request->buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, request->buffer.buf.len);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);\n-#ifndef NO_CURL_IOCTL\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, &request->buffer);\n-#endif\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_PUT);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_PUT, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, request->url);\n+\tcurl_setup_http(slot->curl, request->url, DAV_PUT,\n+\t\t\t&request->buffer, fwrite_null);\n \n \tif (start_active_slot(slot)) {\n \t\trequest->slot = slot;\n@@ -427,13 +441,10 @@ static void start_move(struct transfer_request *request)\n \tslot = get_active_slot();\n \tslot->callback_func = process_response;\n \tslot->callback_data = request;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1); /* undo PUT setup */\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_MOVE);\n+\tcurl_setup_http_get(slot->curl, request->url, DAV_MOVE);\n \tdav_headers = curl_slist_append(dav_headers, request->dest);\n \tdav_headers = curl_slist_append(dav_headers, \"Overwrite: T\");\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, request->url);\n \n \tif (start_active_slot(slot)) {\n \t\trequest->slot = slot;\n@@ -458,10 +469,7 @@ static int refresh_lock(struct remote_lock *lock)\n \n \tslot = get_active_slot();\n \tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, lock->url);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_LOCK);\n+\tcurl_setup_http_get(slot->curl, lock->url, DAV_LOCK);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n \n \tif (start_active_slot(slot)) {\n@@ -876,10 +884,7 @@ static struct remote_lock *lock_remote(const char *path, long timeout)\n \t\tep[1] = '\\0';\n \t\tslot = get_active_slot();\n \t\tslot->results = &results;\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_MKCOL);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n+\t\tcurl_setup_http_get(slot->curl, url, DAV_MKCOL);\n \t\tif (start_active_slot(slot)) {\n \t\t\trun_active_slot(slot);\n \t\t\tif (results.curl_result != CURLE_OK &&\n@@ -909,19 +914,9 @@ static struct remote_lock *lock_remote(const char *path, long timeout)\n \n \tslot = get_active_slot();\n \tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILE, &out_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, out_buffer.buf.len);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);\n-#ifndef NO_CURL_IOCTL\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, &out_buffer);\n-#endif\n-\tcurl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_LOCK);\n+\tcurl_setup_http(slot->curl, url, DAV_LOCK, &out_buffer, fwrite_buffer);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);\n \n \tlock = xcalloc(1, sizeof(*lock));\n \tlock->timeout = -1;\n@@ -987,9 +982,7 @@ static int unlock_remote(struct remote_lock *lock)\n \n \tslot = get_active_slot();\n \tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, lock->url);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_UNLOCK);\n+\tcurl_setup_http_get(slot->curl, lock->url, DAV_UNLOCK);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n \n \tif (start_active_slot(slot)) {\n@@ -1167,19 +1160,10 @@ static void remote_ls(const char *path, int flags,\n \n \tslot = get_active_slot();\n \tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILE, &out_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, out_buffer.buf.len);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);\n-#ifndef NO_CURL_IOCTL\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, &out_buffer);\n-#endif\n-\tcurl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_PROPFIND);\n+\tcurl_setup_http(slot->curl, url, DAV_PROPFIND,\n+\t\t\t&out_buffer, fwrite_buffer);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);\n \n \tif (start_active_slot(slot)) {\n \t\trun_active_slot(slot);\n@@ -1250,19 +1234,10 @@ static int locking_available(void)\n \n \tslot = get_active_slot();\n \tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILE, &out_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, out_buffer.buf.len);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);\n-#ifndef NO_CURL_IOCTL\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, &out_buffer);\n-#endif\n-\tcurl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, repo->url);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_PROPFIND);\n+\tcurl_setup_http(slot->curl, repo->url, DAV_PROPFIND,\n+\t\t\t&out_buffer, fwrite_buffer);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);\n \n \tif (start_active_slot(slot)) {\n \t\trun_active_slot(slot);\n@@ -1436,19 +1411,9 @@ static int update_remote(unsigned char *sha1, struct remote_lock *lock)\n \n \tslot = get_active_slot();\n \tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILE, &out_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, out_buffer.buf.len);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);\n-#ifndef NO_CURL_IOCTL\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, &out_buffer);\n-#endif\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_PUT);\n+\tcurl_setup_http(slot->curl, lock->url, DAV_PUT,\n+\t\t\t&out_buffer, fwrite_null);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_PUT, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, lock->url);\n \n \tif (start_active_slot(slot)) {\n \t\trun_active_slot(slot);\n@@ -1572,19 +1537,9 @@ static void update_remote_info_refs(struct remote_lock *lock)\n \n \t\tslot = get_active_slot();\n \t\tslot->results = &results;\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_INFILE, &buffer);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, buffer.buf.len);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);\n-#ifndef NO_CURL_IOCTL\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, &buffer);\n-#endif\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_PUT);\n+\t\tcurl_setup_http(slot->curl, lock->url, DAV_PUT,\n+\t\t\t\t&buffer, fwrite_null);\n \t\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_PUT, 1);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_URL, lock->url);\n \n \t\tif (start_active_slot(slot)) {\n \t\t\trun_active_slot(slot);\n@@ -1742,10 +1697,7 @@ static int delete_remote_branch(const char *pattern, int force)\n \tsprintf(url, \"%s%s\", repo->url, remote_ref->name);\n \tslot = get_active_slot();\n \tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_DELETE);\n+\tcurl_setup_http_get(slot->curl, url, DAV_DELETE);\n \tif (start_active_slot(slot)) {\n \t\trun_active_slot(slot);\n \t\tfree(url);\n-- \n1.7.3.3.585.g74f6e\n"},{"id":"166946","messageId":"BANLkTimmQAUKXfe3SntpDpKjc8XhEpjeJA@mail.gmail.com","threadId":"27243","inReplyTo":"1304437649-7052-2-git-send-email-rctay89@gmail.com","subject":"Re: [PATCH v3 1/4] t5541-http-push: add test for chunked","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2011-05-03T16:32:41Z","receivedAt":"2011-05-03T16:32:41Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"On Tue, May 3, 2011 at 08:47, Tay Ray Chuan <rctay89@gmail.com> wrote:\n> Trigger the chunked type of pushing for smart HTTP. This can serve as a\n> regression test for the issue fixed in 1e41827 (http: clear POSTFIELDS\n> when initializing a slot).\n...\n> +       # to trigger chunked pushing, we need a sufficiently large pack - use\n> +       # git v0.99\n\nThe better way to trigger this is to set http.postBuffer to something\nvery small, e.g. \"4\".\n\n-- \nShawn.\n"},{"id":"166948","messageId":"BANLkTi=MQYSR5_wwswtpeM-gn61znVeoaw@mail.gmail.com","threadId":"27243","inReplyTo":"BANLkTimmQAUKXfe3SntpDpKjc8XhEpjeJA@mail.gmail.com","subject":"Re: [PATCH v3 1/4] t5541-http-push: add test for chunked","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2011-05-03T17:18:34Z","receivedAt":"2011-05-03T17:18:34Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"On Wed, May 4, 2011 at 12:32 AM, Shawn Pearce <spearce@spearce.org> wrote:\n> On Tue, May 3, 2011 at 08:47, Tay Ray Chuan <rctay89@gmail.com> wrote:\n>> Trigger the chunked type of pushing for smart HTTP. This can serve as a\n>> regression test for the issue fixed in 1e41827 (http: clear POSTFIELDS\n>> when initializing a slot).\n> ...\n>> +       # to trigger chunked pushing, we need a sufficiently large pack - use\n>> +       # git v0.99\n>\n> The better way to trigger this is to set http.postBuffer to something\n> very small, e.g. \"4\".\n\nAh, thanks for the tip.\n\n-- \nCheers,\nRay Chuan\n"},{"id":"166986","messageId":"7v8vunglbp.fsf@alter.siamese.dyndns.org","threadId":"27243","inReplyTo":"1304437649-7052-2-git-send-email-rctay89@gmail.com","subject":"Re: [PATCH v3 1/4] t5541-http-push: add test for chunked","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-04T04:07:38Z","receivedAt":"2011-05-04T04:07:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tay Ray Chuan <rctay89@gmail.com> writes:\n\n> +\tGIT_REPO=$TEST_DIRECTORY/../.git &&\n> +\ttest -d $GIT_REPO &&\n\nShouldn't a test be runnable without failing in a tarball extract?\n"},{"id":"166987","messageId":"7v4o5bgl8m.fsf@alter.siamese.dyndns.org","threadId":"27243","inReplyTo":"1304437649-7052-1-git-send-email-rctay89@gmail.com","subject":"Re: [PATCH v3 0/4] http cleanups","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-04T04:09:29Z","receivedAt":"2011-05-04T04:09:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tay Ray Chuan <rctay89@gmail.com> writes:\n\n> This is a re-roll of dm/http-cleanup. I've also included a test for\n> chunked http pushes that has been sitting on my side for some time.\n>\n> Note to Junio: these patches should apply safely on\n> sp/maint-clear-postfields. Actually, the first patch depends on it.\n\nIt doesn't apply for me.  It does apply to 'master' after that topic is\nmerged to it, which is good enough for our purpose, though.\n"},{"id":"167008","messageId":"BANLkTim9uii4gRHAp+UWk8+_bv=wXasj-g@mail.gmail.com","threadId":"27243","inReplyTo":"7v4o5bgl8m.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3 0/4] http cleanups","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2011-05-04T09:50:24Z","receivedAt":"2011-05-04T09:50:24Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"On Wed, May 4, 2011 at 12:09 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> It doesn't apply for me.  It does apply to 'master' after that topic is\n> merged to it, which is good enough for our purpose, though.\n\nSorry about the inaccurate note. I think this is due to\nsp/main-clear-postfields not containing t/t5541-http-push.sh.\n\n-- \nCheers,\nRay Chuan\n"},{"id":"167009","messageId":"1304503896-5988-1-git-send-email-rctay89@gmail.com","threadId":"27243","inReplyTo":"1304437649-7052-1-git-send-email-rctay89@gmail.com","subject":"[PATCH v4 0/4] http cleanups","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2011-05-04T10:11:32Z","receivedAt":"2011-05-04T10:11:32Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Only patch #1 has been changed.\n\n[1/4] t5541-http-push: add test for chunked\n[2/4] http: make curl callbacks match contracts from curl header\n[3/4] http-push: use const for strings in signatures\n[4/4] http-push: refactor curl_easy_setup madness\n\n-- \n1.7.3.3.585.g74f6e\n"},{"id":"167012","messageId":"1304503896-5988-2-git-send-email-rctay89@gmail.com","threadId":"27243","inReplyTo":"1304503896-5988-1-git-send-email-rctay89@gmail.com","subject":"[PATCH v4 1/4] t5541-http-push: add test for chunked","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2011-05-04T10:11:33Z","receivedAt":"2011-05-04T10:11:33Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Trigger the chunked type of pushing for smart HTTP. This can serve as a\nregression test for the issue fixed in 1e41827 (http: clear POSTFIELDS\nwhen initializing a slot).\n\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n\nChanged in v4: simplified the way chunked pushing is triggered. The test\nnow runs in a tarball extract.\n\n t/t5541-http-push.sh |   18 ++++++++++++++++--\n 1 files changed, 16 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh\nindex 0492877..0c0917a 100755\n--- a/t/t5541-http-push.sh\n+++ b/t/t5541-http-push.sh\n@@ -65,14 +65,16 @@ test_expect_success 'clone remote repository' '\n \tgit clone $HTTPD_URL/smart/test_repo.git test_repo_clone\n '\n \n-test_expect_success 'push to remote repository' '\n+test_expect_success 'push to remote repository (standard)' '\n \tcd \"$ROOT_PATH\"/test_repo_clone &&\n \t: >path2 &&\n \tgit add path2 &&\n \ttest_tick &&\n \tgit commit -m path2 &&\n \tHEAD=$(git rev-parse --verify HEAD) &&\n-\tgit push &&\n+\tGIT_CURL_VERBOSE=1 git push -v -v 2>err &&\n+\t! grep \"Expect: 100-continue\" err &&\n+\tgrep \"POST git-receive-pack (376 bytes)\" err &&\n \t(cd \"$HTTPD_DOCUMENT_ROOT_PATH\"/test_repo.git &&\n \t test $HEAD = $(git rev-parse --verify HEAD))\n '\n@@ -140,5 +142,17 @@ test_expect_success C_LOCALE_OUTPUT 'push fails for non-fast-forward refs unmatc\n \t\toutput\n '\n \n+test_expect_success 'push (chunked)' '\n+\tgit checkout master &&\n+\ttest_commit commit path3 &&\n+\tHEAD=$(git rev-parse --verify HEAD) &&\n+\tgit config http.postbuffer 4 &&\n+\tgit push -v -v origin $BRANCH 2>err &&\n+\tgrep \"POST git-receive-pack (chunked)\" err &&\n+\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH\"/test_repo.git &&\n+\t test $HEAD = $(git rev-parse --verify HEAD)) &&\n+\tgit config --unset http.postbuffer\n+'\n+\n stop_httpd\n test_done\n-- \n1.7.3.3.585.g74f6e\n"},{"id":"167010","messageId":"1304503896-5988-3-git-send-email-rctay89@gmail.com","threadId":"27243","inReplyTo":"1304503896-5988-2-git-send-email-rctay89@gmail.com","subject":"[PATCH v4 2/4] http: make curl callbacks match contracts from curl header","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2011-05-04T10:11:34Z","receivedAt":"2011-05-04T10:11:34Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"From: Dan McGee <dpmcgee@gmail.com>\n\nYes, these don't match perfectly with the void* first parameter of the\nfread/fwrite in the standard library, but they do match the curl\nexpected method signature. This is needed when a refactor passes a\ncurl_write_callback around, which would otherwise give incorrect\nparameter warnings.\n\nSigned-off-by: Dan McGee <dpmcgee@gmail.com>\n---\n http-walker.c |    4 ++--\n http.c        |   12 ++++++------\n http.h        |    6 +++---\n remote-curl.c |    2 +-\n 4 files changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/http-walker.c b/http-walker.c\nindex 9bc8114..51a906e 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -185,7 +185,7 @@ static void process_alternates_response(void *callback_data)\n \tstruct active_request_slot *slot = alt_req->slot;\n \tstruct alt_base *tail = cdata->alt;\n \tconst char *base = alt_req->base;\n-\tstatic const char null_byte = '\\0';\n+\tconst char null_byte = '\\0';\n \tchar *data;\n \tint i = 0;\n \n@@ -218,7 +218,7 @@ static void process_alternates_response(void *callback_data)\n \t\t}\n \t}\n \n-\tfwrite_buffer(&null_byte, 1, 1, alt_req->buffer);\n+\tfwrite_buffer((char *)&null_byte, 1, 1, alt_req->buffer);\n \talt_req->buffer->len--;\n \tdata = alt_req->buffer->buf;\n \ndiff --git a/http.c b/http.c\nindex b27bb57..b2ae8de 100644\n--- a/http.c\n+++ b/http.c\n@@ -60,7 +60,7 @@ static struct curl_slist *no_pragma_header;\n \n static struct active_request_slot *active_queue_head;\n \n-size_t fread_buffer(void *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n+size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n {\n \tsize_t size = eltsize * nmemb;\n \tstruct buffer *buffer = buffer_;\n@@ -92,7 +92,7 @@ curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp)\n }\n #endif\n \n-size_t fwrite_buffer(const void *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n+size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)\n {\n \tsize_t size = eltsize * nmemb;\n \tstruct strbuf *buffer = buffer_;\n@@ -102,7 +102,7 @@ size_t fwrite_buffer(const void *ptr, size_t eltsize, size_t nmemb, void *buffer\n \treturn size;\n }\n \n-size_t fwrite_null(const void *ptr, size_t eltsize, size_t nmemb, void *strbuf)\n+size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf)\n {\n \tdata_received++;\n \treturn eltsize * nmemb;\n@@ -1167,7 +1167,7 @@ abort:\n }\n \n /* Helpers for fetching objects (loose) */\n-static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,\n+static size_t fwrite_sha1_file(char *ptr, size_t eltsize, size_t nmemb,\n \t\t\t       void *data)\n {\n \tunsigned char expn[4096];\n@@ -1184,7 +1184,7 @@ static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,\n \t} while (posn < size);\n \n \tfreq->stream.avail_in = size;\n-\tfreq->stream.next_in = ptr;\n+\tfreq->stream.next_in = (void *)ptr;\n \tdo {\n \t\tfreq->stream.next_out = expn;\n \t\tfreq->stream.avail_out = sizeof(expn);\n@@ -1203,7 +1203,7 @@ struct http_object_request *new_http_object_request(const char *base_url,\n \tchar *filename;\n \tchar prevfile[PATH_MAX];\n \tint prevlocal;\n-\tunsigned char prev_buf[PREV_BUF_SIZE];\n+\tchar prev_buf[PREV_BUF_SIZE];\n \tssize_t prev_read = 0;\n \tlong prev_posn = 0;\n \tchar range[RANGE_HEADER_SIZE];\ndiff --git a/http.h b/http.h\nindex e9ed3c2..19b7134 100644\n--- a/http.h\n+++ b/http.h\n@@ -66,9 +66,9 @@ struct buffer {\n };\n \n /* Curl request read/write callbacks */\n-extern size_t fread_buffer(void *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n-extern size_t fwrite_buffer(const void *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n-extern size_t fwrite_null(const void *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n+extern size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n+extern size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n+extern size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);\n #ifndef NO_CURL_IOCTL\n extern curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp);\n #endif\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 775d614..17d8a9b 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -347,7 +347,7 @@ static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)\n }\n #endif\n \n-static size_t rpc_in(const void *ptr, size_t eltsize,\n+static size_t rpc_in(char *ptr, size_t eltsize,\n \t\tsize_t nmemb, void *buffer_)\n {\n \tsize_t size = eltsize * nmemb;\n-- \n1.7.3.3.585.g74f6e\n"},{"id":"167011","messageId":"1304503896-5988-4-git-send-email-rctay89@gmail.com","threadId":"27243","inReplyTo":"1304503896-5988-3-git-send-email-rctay89@gmail.com","subject":"[PATCH v4 3/4] http-push: use const for strings in signatures","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2011-05-04T10:11:35Z","receivedAt":"2011-05-04T10:11:35Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"From: Dan McGee <dpmcgee@gmail.com>\n\nSigned-off-by: Dan McGee <dpmcgee@gmail.com>\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n http-push.c |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex d18346c..0fce38d 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -169,7 +169,7 @@ enum dav_header_flag {\n \tDAV_HEADER_TIMEOUT = (1u << 2)\n };\n \n-static char *xml_entities(char *s)\n+static char *xml_entities(const char *s)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \twhile (*s) {\n@@ -797,7 +797,7 @@ static void handle_new_lock_ctx(struct xml_ctx *ctx, int tag_closed)\n \t}\n }\n \n-static void one_remote_ref(char *refname);\n+static void one_remote_ref(const char *refname);\n \n static void\n xml_start_tag(void *userData, const char *name, const char **atts)\n@@ -1471,7 +1471,7 @@ static int update_remote(unsigned char *sha1, struct remote_lock *lock)\n \n static struct ref *remote_refs;\n \n-static void one_remote_ref(char *refname)\n+static void one_remote_ref(const char *refname)\n {\n \tstruct ref *ref;\n \tstruct object *obj;\n@@ -1660,7 +1660,7 @@ static int verify_merge_base(unsigned char *head_sha1, unsigned char *branch_sha\n \treturn (merge_bases && !merge_bases->next && merge_bases->item == branch);\n }\n \n-static int delete_remote_branch(char *pattern, int force)\n+static int delete_remote_branch(const char *pattern, int force)\n {\n \tstruct ref *refs = remote_refs;\n \tstruct ref *remote_ref = NULL;\n-- \n1.7.3.3.585.g74f6e\n"},{"id":"167013","messageId":"1304503896-5988-5-git-send-email-rctay89@gmail.com","threadId":"27243","inReplyTo":"1304503896-5988-4-git-send-email-rctay89@gmail.com","subject":"[PATCH v4 4/4] http-push: refactor curl_easy_setup madness","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2011-05-04T10:11:36Z","receivedAt":"2011-05-04T10:11:36Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"From: Dan McGee <dpmcgee@gmail.com>\n\nWe were doing (nearly) the same thing all over the place, in slightly\ndifferent orders, different variable names, etc. Refactor most calls\ninto two helper functions, one for GET and one for everything else, that\ndo the heavy lifting leaving most callsites a lot cleaner in the\nprocess.\n\nNote that the setting of CURLOPT_PUT at the callsites of\ncurl_setup_http() which previously didn't do it (eg.\nlocking_available(), remote_ls()) is safe, since that\noption is deprecated in libcurl in place of, and has the same effect as,\nCURLOPT_UPLOAD.\n\nSigned-off-by: Dan McGee <dpmcgee@gmail.com>\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n http-push.c |  144 ++++++++++++++++++++---------------------------------------\n 1 files changed, 48 insertions(+), 96 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex 0fce38d..28bfe76 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -197,6 +197,34 @@ static char *xml_entities(const char *s)\n \treturn strbuf_detach(&buf, NULL);\n }\n \n+static void curl_setup_http_get(CURL *curl, const char *url,\n+\t\tconst char *custom_req)\n+{\n+\tcurl_easy_setopt(curl, CURLOPT_HTTPGET, 1);\n+\tcurl_easy_setopt(curl, CURLOPT_URL, url);\n+\tcurl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);\n+\tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n+}\n+\n+static void curl_setup_http(CURL *curl, const char *url,\n+\t\tconst char *custom_req, struct buffer *buffer,\n+\t\tcurl_write_callback write_fn)\n+{\n+\tcurl_easy_setopt(curl, CURLOPT_PUT, 1);\n+\tcurl_easy_setopt(curl, CURLOPT_URL, url);\n+\tcurl_easy_setopt(curl, CURLOPT_INFILE, buffer);\n+\tcurl_easy_setopt(curl, CURLOPT_INFILESIZE, buffer->buf.len);\n+\tcurl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);\n+#ifndef NO_CURL_IOCTL\n+\tcurl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n+\tcurl_easy_setopt(curl, CURLOPT_IOCTLDATA, &buffer);\n+#endif\n+\tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn);\n+\tcurl_easy_setopt(curl, CURLOPT_NOBODY, 0);\n+\tcurl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);\n+\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1);\n+}\n+\n static struct curl_slist *get_dav_token_headers(struct remote_lock *lock, enum dav_header_flag options)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n@@ -272,11 +300,8 @@ static void start_mkcol(struct transfer_request *request)\n \tslot = get_active_slot();\n \tslot->callback_func = process_response;\n \tslot->callback_data = request;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1); /* undo PUT setup */\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, request->url);\n+\tcurl_setup_http_get(slot->curl, request->url, DAV_MKCOL);\n \tcurl_easy_setopt(slot->curl, CURLOPT_ERRORBUFFER, request->errorstr);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_MKCOL);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n \n \tif (start_active_slot(slot)) {\n \t\trequest->slot = slot;\n@@ -395,19 +420,8 @@ static void start_put(struct transfer_request *request)\n \tslot = get_active_slot();\n \tslot->callback_func = process_response;\n \tslot->callback_data = request;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILE, &request->buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, request->buffer.buf.len);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);\n-#ifndef NO_CURL_IOCTL\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, &request->buffer);\n-#endif\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_PUT);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_PUT, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, request->url);\n+\tcurl_setup_http(slot->curl, request->url, DAV_PUT,\n+\t\t\t&request->buffer, fwrite_null);\n \n \tif (start_active_slot(slot)) {\n \t\trequest->slot = slot;\n@@ -427,13 +441,10 @@ static void start_move(struct transfer_request *request)\n \tslot = get_active_slot();\n \tslot->callback_func = process_response;\n \tslot->callback_data = request;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1); /* undo PUT setup */\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_MOVE);\n+\tcurl_setup_http_get(slot->curl, request->url, DAV_MOVE);\n \tdav_headers = curl_slist_append(dav_headers, request->dest);\n \tdav_headers = curl_slist_append(dav_headers, \"Overwrite: T\");\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, request->url);\n \n \tif (start_active_slot(slot)) {\n \t\trequest->slot = slot;\n@@ -458,10 +469,7 @@ static int refresh_lock(struct remote_lock *lock)\n \n \tslot = get_active_slot();\n \tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, lock->url);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_LOCK);\n+\tcurl_setup_http_get(slot->curl, lock->url, DAV_LOCK);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n \n \tif (start_active_slot(slot)) {\n@@ -876,10 +884,7 @@ static struct remote_lock *lock_remote(const char *path, long timeout)\n \t\tep[1] = '\\0';\n \t\tslot = get_active_slot();\n \t\tslot->results = &results;\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_MKCOL);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n+\t\tcurl_setup_http_get(slot->curl, url, DAV_MKCOL);\n \t\tif (start_active_slot(slot)) {\n \t\t\trun_active_slot(slot);\n \t\t\tif (results.curl_result != CURLE_OK &&\n@@ -909,19 +914,9 @@ static struct remote_lock *lock_remote(const char *path, long timeout)\n \n \tslot = get_active_slot();\n \tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILE, &out_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, out_buffer.buf.len);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);\n-#ifndef NO_CURL_IOCTL\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, &out_buffer);\n-#endif\n-\tcurl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_LOCK);\n+\tcurl_setup_http(slot->curl, url, DAV_LOCK, &out_buffer, fwrite_buffer);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);\n \n \tlock = xcalloc(1, sizeof(*lock));\n \tlock->timeout = -1;\n@@ -987,9 +982,7 @@ static int unlock_remote(struct remote_lock *lock)\n \n \tslot = get_active_slot();\n \tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, lock->url);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_UNLOCK);\n+\tcurl_setup_http_get(slot->curl, lock->url, DAV_UNLOCK);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n \n \tif (start_active_slot(slot)) {\n@@ -1167,19 +1160,10 @@ static void remote_ls(const char *path, int flags,\n \n \tslot = get_active_slot();\n \tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILE, &out_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, out_buffer.buf.len);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);\n-#ifndef NO_CURL_IOCTL\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, &out_buffer);\n-#endif\n-\tcurl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_PROPFIND);\n+\tcurl_setup_http(slot->curl, url, DAV_PROPFIND,\n+\t\t\t&out_buffer, fwrite_buffer);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);\n \n \tif (start_active_slot(slot)) {\n \t\trun_active_slot(slot);\n@@ -1250,19 +1234,10 @@ static int locking_available(void)\n \n \tslot = get_active_slot();\n \tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILE, &out_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, out_buffer.buf.len);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);\n-#ifndef NO_CURL_IOCTL\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, &out_buffer);\n-#endif\n-\tcurl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, repo->url);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_PROPFIND);\n+\tcurl_setup_http(slot->curl, repo->url, DAV_PROPFIND,\n+\t\t\t&out_buffer, fwrite_buffer);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);\n \n \tif (start_active_slot(slot)) {\n \t\trun_active_slot(slot);\n@@ -1436,19 +1411,9 @@ static int update_remote(unsigned char *sha1, struct remote_lock *lock)\n \n \tslot = get_active_slot();\n \tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILE, &out_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, out_buffer.buf.len);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);\n-#ifndef NO_CURL_IOCTL\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, &out_buffer);\n-#endif\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_PUT);\n+\tcurl_setup_http(slot->curl, lock->url, DAV_PUT,\n+\t\t\t&out_buffer, fwrite_null);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_PUT, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, lock->url);\n \n \tif (start_active_slot(slot)) {\n \t\trun_active_slot(slot);\n@@ -1572,19 +1537,9 @@ static void update_remote_info_refs(struct remote_lock *lock)\n \n \t\tslot = get_active_slot();\n \t\tslot->results = &results;\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_INFILE, &buffer);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, buffer.buf.len);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);\n-#ifndef NO_CURL_IOCTL\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, &buffer);\n-#endif\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_PUT);\n+\t\tcurl_setup_http(slot->curl, lock->url, DAV_PUT,\n+\t\t\t\t&buffer, fwrite_null);\n \t\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_PUT, 1);\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_URL, lock->url);\n \n \t\tif (start_active_slot(slot)) {\n \t\t\trun_active_slot(slot);\n@@ -1742,10 +1697,7 @@ static int delete_remote_branch(const char *pattern, int force)\n \tsprintf(url, \"%s%s\", repo->url, remote_ref->name);\n \tslot = get_active_slot();\n \tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_DELETE);\n+\tcurl_setup_http_get(slot->curl, url, DAV_DELETE);\n \tif (start_active_slot(slot)) {\n \t\trun_active_slot(slot);\n \t\tfree(url);\n-- \n1.7.3.3.585.g74f6e\n"},{"id":"167015","messageId":"m3wri6vg5h.fsf@localhost.localdomain","threadId":"27243","inReplyTo":"1304503896-5988-2-git-send-email-rctay89@gmail.com","subject":"Re: [PATCH v4 1/4] t5541-http-push: add test for chunked","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-05-04T11:51:22Z","receivedAt":"2011-05-04T11:51:22Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Tay Ray Chuan <rctay89@gmail.com> writes:\n\n> +test_expect_success 'push (chunked)' '\n> +\tgit checkout master &&\n> +\ttest_commit commit path3 &&\n> +\tHEAD=$(git rev-parse --verify HEAD) &&\n> +\tgit config http.postbuffer 4 &&\n> +\tgit push -v -v origin $BRANCH 2>err &&\n> +\tgrep \"POST git-receive-pack (chunked)\" err &&\n> +\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH\"/test_repo.git &&\n> +\t test $HEAD = $(git rev-parse --verify HEAD)) &&\n> +\tgit config --unset http.postbuffer\n> +'\n\nIt is a very minor issue, a nitpick really; but wouldn't it be better\nto use\n\n  +\tgit config http.postbuffer 4 &&\n  +\ttest_when_finished \"git config --unset http.postbuffer\" &&  \n\nThis way you would have `http.postBuffer` unset even if any of\nintermediate commands fail, preparing clean state for next test.\nThough in this case that doesn't matter, as it is the very last test.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"167033","messageId":"7vzkn2e34y.fsf@alter.siamese.dyndns.org","threadId":"27243","inReplyTo":"m3wri6vg5h.fsf@localhost.localdomain","subject":"Re: [PATCH v4 1/4] t5541-http-push: add test for chunked","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-04T18:23:25Z","receivedAt":"2011-05-04T18:23:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> It is a very minor issue, a nitpick really; but wouldn't it be better\n> to use\n>\n>   +\tgit config http.postbuffer 4 &&\n>   +\ttest_when_finished \"git config --unset http.postbuffer\" &&  \n\nNot a minor issue it is.  It needs to be fixed before queued.  Thanks for\npointing it out.\n\nIt is a different matter if it needs to be rerolled. Something trivial\nlike this I could remember to amend/tweak before queuing.\n\nThanks.\n"},{"id":"167034","messageId":"7vvcxqe341.fsf@alter.siamese.dyndns.org","threadId":"27243","inReplyTo":"1304529590-1032-1-git-send-email-rctay89@gmail.com","subject":"Re: [PATCH v5 1/4] t5541-http-push: add test for chunked","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-04T18:23:58Z","receivedAt":"2011-05-04T18:23:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tay Ray Chuan <rctay89@gmail.com> writes:\n\n> Trigger the chunked type of pushing for smart HTTP. This can serve as a\n> regression test for the issue fixed in 1e41827 (http: clear POSTFIELDS\n> when initializing a slot).\n>\n> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>\n> ---\n>\n> Junio: only the first patch (this one) was changed; all the other three\n> remain as they are.\n>\n> Changed in v5: use test_when_finished to unset config changes.\n\nThanks.\n"},{"id":"167035","messageId":"7vr58ee261.fsf@alter.siamese.dyndns.org","threadId":"27243","inReplyTo":"1304529590-1032-1-git-send-email-rctay89@gmail.com","subject":"Re: [PATCH v5 1/4] t5541-http-push: add test for chunked","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-04T18:44:22Z","receivedAt":"2011-05-04T18:44:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tay Ray Chuan <rctay89@gmail.com> writes:\n\n> +\tGIT_CURL_VERBOSE=1 git push -v -v 2>err &&\n> +\t! grep \"Expect: 100-continue\" err &&\n> +\tgrep \"POST git-receive-pack (376 bytes)\" err &&\n\nThis \"376 bytes\" bothers me. Can our packing algorithm never improve?\n\n>  \t(cd \"$HTTPD_DOCUMENT_ROOT_PATH\"/test_repo.git &&\n>  \t test $HEAD = $(git rev-parse --verify HEAD))\n>  '\n> @@ -140,5 +142,17 @@ test_expect_success C_LOCALE_OUTPUT 'push fails for non-fast-forward refs unmatc\n>  \t\toutput\n>  '\n>  \n> +test_expect_success 'push (chunked)' '\n> +\tgit checkout master &&\n> +\ttest_commit commit path3 &&\n> +\tHEAD=$(git rev-parse --verify HEAD) &&\n> +\tgit config http.postbuffer 4 &&\n> +\ttest_when_finished git config --unset http.postbuffer &&\n\nIt probably is a good style to send the command line as a single\nargument.  There are a few violations in the existing code but that is not\nan excuse to add more violations.\n\n> +\tgit push -v -v origin $BRANCH 2>err &&\n> +\tgrep \"POST git-receive-pack (chunked)\" err &&\n> +\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH\"/test_repo.git &&\n> +\t test $HEAD = $(git rev-parse --verify HEAD))\n> +'\n> +\n>  stop_httpd\n>  test_done\n\nI'll queue this with the following trivial fix-up.\n\nBy the way, the \"(chunked) test\" is failing for me, with\n\n  Pushing to http://127.0.0.1:5541/smart/test_repo.git\n  POST git-receive-pack (chunked)\n  POST git-receive-pack (chunked)\n  POST git-receive-pack (chunked)\n  fatal: The remote end hung up unexpectedly\n  fatal: The remote end hung up unexpectedly\n\nin trash/test_repo_clone/err; sometimes with two POSTs and sometimes with\nthree POSTs before we get the \"fatal:\".\n\n---\n\n t/t5541-http-push.sh |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh\nindex fec552c..4b93fa1 100755\n--- a/t/t5541-http-push.sh\n+++ b/t/t5541-http-push.sh\n@@ -74,7 +74,7 @@ test_expect_success 'push to remote repository (standard)' '\n \tHEAD=$(git rev-parse --verify HEAD) &&\n \tGIT_CURL_VERBOSE=1 git push -v -v 2>err &&\n \t! grep \"Expect: 100-continue\" err &&\n-\tgrep \"POST git-receive-pack (376 bytes)\" err &&\n+\tgrep \"POST git-receive-pack ([0-9]* bytes)\" err &&\n \t(cd \"$HTTPD_DOCUMENT_ROOT_PATH\"/test_repo.git &&\n \t test $HEAD = $(git rev-parse --verify HEAD))\n '\n@@ -147,7 +147,7 @@ test_expect_success 'push (chunked)' '\n \ttest_commit commit path3 &&\n \tHEAD=$(git rev-parse --verify HEAD) &&\n \tgit config http.postbuffer 4 &&\n-\ttest_when_finished git config --unset http.postbuffer &&\n+\ttest_when_finished \"git config --unset http.postbuffer\" &&\n \tgit push -v -v origin $BRANCH 2>err &&\n \tgrep \"POST git-receive-pack (chunked)\" err &&\n \t(cd \"$HTTPD_DOCUMENT_ROOT_PATH\"/test_repo.git &&\n"},{"id":"167042","messageId":"7vmxj2dxca.fsf@alter.siamese.dyndns.org","threadId":"27243","inReplyTo":"7vr58ee261.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v5 1/4] t5541-http-push: add test for chunked","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-04T20:28:37Z","receivedAt":"2011-05-04T20:28:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> By the way, the \"(chunked) test\" is failing for me, with\n>\n>   Pushing to http://127.0.0.1:5541/smart/test_repo.git\n>   POST git-receive-pack (chunked)\n>   POST git-receive-pack (chunked)\n>   POST git-receive-pack (chunked)\n>   fatal: The remote end hung up unexpectedly\n>   fatal: The remote end hung up unexpectedly\n>\n> in trash/test_repo_clone/err; sometimes with two POSTs and sometimes with\n> three POSTs before we get the \"fatal:\".\n\nSorry.  False alarm.\n"}]}