git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 17/23] http.c::http_fetch_ref(): use the new http API
@ 2009-06-05 16:05 Tay Ray Chuan
  2009-06-05 20:50 ` Jakub Narebski
  0 siblings, 1 reply; 27+ messages in thread
From: Tay Ray Chuan @ 2009-06-05 16:05 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano, Johannes Schindelin, Mike Hommey

From:	Mike Hommey <mh@glandium.org>
Subject: [WIP Patch 04/12] Use the new http API in http_fetch_ref()
Date:	Sun, 18 Jan 2009 09:04:29 +0100

The error message ("Unable to start request") has been removed, since
the http API already prints it.

Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
 http.c |   33 ++++++++-------------------------
 1 files changed, 8 insertions(+), 25 deletions(-)

diff --git a/http.c b/http.c
index df22180..2a49372 100644
--- a/http.c
+++ b/http.c
@@ -773,34 +773,17 @@ int http_fetch_ref(const char *base, struct ref *ref)
 {
 	char *url;
 	struct strbuf buffer = STRBUF_INIT;
-	struct active_request_slot *slot;
-	struct slot_results results;
-	int ret;
+	int ret = -1;

 	url = quote_ref_url(base, ref->name);
-	slot = get_active_slot();
-	slot->results = &results;
-	curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);
-	curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
-	curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
-	curl_easy_setopt(slot->curl, CURLOPT_URL, url);
-	if (start_active_slot(slot)) {
-		run_active_slot(slot);
-		if (results.curl_result == CURLE_OK) {
-			strbuf_rtrim(&buffer);
-			if (buffer.len == 40)
-				ret = get_sha1_hex(buffer.buf, ref->old_sha1);
-			else if (!prefixcmp(buffer.buf, "ref: ")) {
-				ref->symref = xstrdup(buffer.buf + 5);
-				ret = 0;
-			} else
-				ret = 1;
-		} else {
-			ret = error("Couldn't get %s for %s\n%s",
-				    url, ref->name, curl_errorstr);
+	if (http_get_strbuf(url, &buffer, HTTP_NO_CACHE) == HTTP_OK) {
+		strbuf_rtrim(&buffer);
+		if (buffer.len == 40)
+			ret = get_sha1_hex(buffer.buf, ref->old_sha1);
+		else if (!prefixcmp(buffer.buf, "ref: ")) {
+			ref->symref = xstrdup(buffer.buf + 5);
+			ret = 0;
 		}
-	} else {
-		ret = error("Unable to start request");
 	}

 	strbuf_release(&buffer);
--
1.6.3.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2009-06-06  8:51 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1244277116.git.rctay89@gmail.com>
2009-06-06  8:43 ` [PATCH 01/23] t5540-http-push: test fetching of loose objects Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 02/23] t5540-http-push: test fetching of packed objects Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 03/23] http*: cleanup slot->local after fclose Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 04/23] http-push: send out fetch requests on queue Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 05/23] http-push: fix missing "#ifdef USE_CURL_MULTI" around "is_running_queue" Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 06/23] t5550-http-fetch: test fetching of packed objects Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 07/23] http-push, http-walker: style fixes Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 08/23] http-walker: verify remote packs Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 09/23] http*: copy string returned by sha1_to_hex Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 10/23] http-push: do not SEGV after fetching a bad pack idx file Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 11/23] Don't expect verify_pack() callers to set pack_size Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 12/23] transport.c::get_refs_via_curl(): do not leak refs_url Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 13/23] http*: move common variables and macros to http.[ch] Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 14/23] http: create function end_url_with_slash Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 15/23] http.c: new functions for the http API Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 16/23] transport.c::get_refs_via_curl(): use the new " Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 17/23] http.c::http_fetch_ref(): " Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 18/23] http-push.c::remote_exists(): " Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 19/23] http-push.c::fetch_symref(): " Tay Ray Chuan
2009-06-06  8:43 ` [PATCH 20/23] http*: add http_get_info_packs Tay Ray Chuan
2009-06-06  8:44 ` [PATCH 21/23] http: use new http API in fetch_index() Tay Ray Chuan
2009-06-06  8:44 ` [PATCH 22/23] http*: add helper methods for fetching packs Tay Ray Chuan
2009-06-06  8:44 ` [PATCH 23/23] http*: add helper methods for fetching objects (loose) Tay Ray Chuan
2009-06-05 16:05 [PATCH 17/23] http.c::http_fetch_ref(): use the new http API Tay Ray Chuan
2009-06-05 20:50 ` Jakub Narebski
2009-06-06  1:04   ` Tay Ray Chuan
2009-06-06  7:17     ` Jakub Narebski

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).