{"thread":{"id":"19692","subject":"[PATCH 17/23] http.c::http_fetch_ref(): use the new http API","startedAt":"2009-06-05T16:05:56Z","lastAt":"2009-06-06T07:17:24Z","messageCount":4,"participants":["Tay Ray Chuan","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":23},"messages":[{"id":"115528","messageId":"20090606000556.9cbf4ac0.rctay89@gmail.com","threadId":"19692","inReplyTo":null,"subject":"[PATCH 17/23] http.c::http_fetch_ref(): use the new http API","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-06-05T16:05:56Z","receivedAt":"2009-06-05T16:05:56Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"From:\tMike Hommey <mh@glandium.org>\nSubject: [WIP Patch 04/12] Use the new http API in http_fetch_ref()\nDate:\tSun, 18 Jan 2009 09:04:29 +0100\n\nThe error message (\"Unable to start request\") has been removed, since\nthe http API already prints it.\n\nSigned-off-by: Mike Hommey <mh@glandium.org>\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n http.c |   33 ++++++++-------------------------\n 1 files changed, 8 insertions(+), 25 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex df22180..2a49372 100644\n--- a/http.c\n+++ b/http.c\n@@ -773,34 +773,17 @@ int http_fetch_ref(const char *base, struct ref *ref)\n {\n \tchar *url;\n \tstruct strbuf buffer = STRBUF_INIT;\n-\tstruct active_request_slot *slot;\n-\tstruct slot_results results;\n-\tint ret;\n+\tint ret = -1;\n\n \turl = quote_ref_url(base, ref->name);\n-\tslot = get_active_slot();\n-\tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n-\tif (start_active_slot(slot)) {\n-\t\trun_active_slot(slot);\n-\t\tif (results.curl_result == CURLE_OK) {\n-\t\t\tstrbuf_rtrim(&buffer);\n-\t\t\tif (buffer.len == 40)\n-\t\t\t\tret = get_sha1_hex(buffer.buf, ref->old_sha1);\n-\t\t\telse if (!prefixcmp(buffer.buf, \"ref: \")) {\n-\t\t\t\tref->symref = xstrdup(buffer.buf + 5);\n-\t\t\t\tret = 0;\n-\t\t\t} else\n-\t\t\t\tret = 1;\n-\t\t} else {\n-\t\t\tret = error(\"Couldn't get %s for %s\\n%s\",\n-\t\t\t\t    url, ref->name, curl_errorstr);\n+\tif (http_get_strbuf(url, &buffer, HTTP_NO_CACHE) == HTTP_OK) {\n+\t\tstrbuf_rtrim(&buffer);\n+\t\tif (buffer.len == 40)\n+\t\t\tret = get_sha1_hex(buffer.buf, ref->old_sha1);\n+\t\telse if (!prefixcmp(buffer.buf, \"ref: \")) {\n+\t\t\tref->symref = xstrdup(buffer.buf + 5);\n+\t\t\tret = 0;\n \t\t}\n-\t} else {\n-\t\tret = error(\"Unable to start request\");\n \t}\n\n \tstrbuf_release(&buffer);\n--\n1.6.3.1\n"},{"id":"115566","messageId":"m3eity5rtq.fsf@localhost.localdomain","threadId":"19692","inReplyTo":"20090606000556.9cbf4ac0.rctay89@gmail.com","subject":"Re: [PATCH 17/23] http.c::http_fetch_ref(): use the new http API","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-06-05T20:50:58Z","receivedAt":"2009-06-05T20:50:58Z","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> From:\tMike Hommey <mh@glandium.org>\n> Subject: [WIP Patch 04/12] Use the new http API in http_fetch_ref()\n\nWhat is the subject of this patch:\n  \"http.c::http_fetch_ref(): use the new http API\"\nor\n  \"Use the new http API in http_fetch_ref()\"\n\nPerhaps this and previous patch should be squashed?\n\n> Date:\tSun, 18 Jan 2009 09:04:29 +0100\n> \n> The error message (\"Unable to start request\") has been removed, since\n> the http API already prints it.\n> \n> Signed-off-by: Mike Hommey <mh@glandium.org>\n> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>\n> ---\n>  http.c |   33 ++++++++-------------------------\n>  1 files changed, 8 insertions(+), 25 deletions(-)\n> \n> diff --git a/http.c b/http.c\n> index df22180..2a49372 100644\n> --- a/http.c\n> +++ b/http.c\n> @@ -773,34 +773,17 @@ int http_fetch_ref(const char *base, struct ref *ref)\n>  {\n>  \tchar *url;\n>  \tstruct strbuf buffer = STRBUF_INIT;\n> -\tstruct active_request_slot *slot;\n> -\tstruct slot_results results;\n> -\tint ret;\n> +\tint ret = -1;\n> \n>  \turl = quote_ref_url(base, ref->name);\n> -\tslot = get_active_slot();\n> -\tslot->results = &results;\n> -\tcurl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);\n> -\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);\n> -\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);\n> -\tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n> -\tif (start_active_slot(slot)) {\n> -\t\trun_active_slot(slot);\n> -\t\tif (results.curl_result == CURLE_OK) {\n> -\t\t\tstrbuf_rtrim(&buffer);\n> -\t\t\tif (buffer.len == 40)\n> -\t\t\t\tret = get_sha1_hex(buffer.buf, ref->old_sha1);\n> -\t\t\telse if (!prefixcmp(buffer.buf, \"ref: \")) {\n> -\t\t\t\tref->symref = xstrdup(buffer.buf + 5);\n> -\t\t\t\tret = 0;\n> -\t\t\t} else\n> -\t\t\t\tret = 1;\n> -\t\t} else {\n> -\t\t\tret = error(\"Couldn't get %s for %s\\n%s\",\n> -\t\t\t\t    url, ref->name, curl_errorstr);\n> +\tif (http_get_strbuf(url, &buffer, HTTP_NO_CACHE) == HTTP_OK) {\n> +\t\tstrbuf_rtrim(&buffer);\n> +\t\tif (buffer.len == 40)\n> +\t\t\tret = get_sha1_hex(buffer.buf, ref->old_sha1);\n> +\t\telse if (!prefixcmp(buffer.buf, \"ref: \")) {\n> +\t\t\tref->symref = xstrdup(buffer.buf + 5);\n> +\t\t\tret = 0;\n>  \t\t}\n> -\t} else {\n> -\t\tret = error(\"Unable to start request\");\n>  \t}\n> \n>  \tstrbuf_release(&buffer);\n> --\n> 1.6.3.1\n> \n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"115588","messageId":"be6fef0d0906051804t704a802ane4921c56d4577401@mail.gmail.com","threadId":"19692","inReplyTo":"m3eity5rtq.fsf@localhost.localdomain","subject":"Re: [PATCH 17/23] http.c::http_fetch_ref(): use the new http API","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-06-06T01:04:44Z","receivedAt":"2009-06-06T01:04:44Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Sat, Jun 6, 2009 at 4:50 AM, Jakub Narebski<jnareb@gmail.com> wrote:\n>> From: Mike Hommey <mh@glandium.org>\n>> Subject: [WIP Patch 04/12] Use the new http API in http_fetch_ref()\n>\n> What is the subject of this patch:\n>  \"http.c::http_fetch_ref(): use the new http API\"\n> or\n>  \"Use the new http API in http_fetch_ref()\"\n\nSee my reply for patch #12.\n\n> Perhaps this and previous patch should be squashed?\n\nWhy should this and patch #16 (for get_refs_via_curl()) be squashed?\nAre you perhaps suggesting that all the use-the-new-http-API patches\nshould be squashed?\n\n-- \nCheers,\nRay Chuan\n"},{"id":"115607","messageId":"200906060917.25362.jnareb@gmail.com","threadId":"19692","inReplyTo":"be6fef0d0906051804t704a802ane4921c56d4577401@mail.gmail.com","subject":"Re: [PATCH 17/23] http.c::http_fetch_ref(): use the new http API","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-06-06T07:17:24Z","receivedAt":"2009-06-06T07:17:24Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Sat, 6 Jun 2009, Tay Ray Chuan wrote:\n> On Sat, Jun 6, 2009 at 4:50 AM, Jakub Narebski<jnareb@gmail.com> wrote:\n\n[...]\n\n> > Perhaps this and previous patch should be squashed?\n> \n> Why should this and patch #16 (for get_refs_via_curl()) be squashed?\n> Are you perhaps suggesting that all the use-the-new-http-API patches\n> should be squashed?\n\nI'm sorry this was before I noticed that there are a few more patches\nwhich are about using newly introduced API. Please disregard this part\nof message.\n\n-- \nJakub Narebski\nPoland\n"}]}