summaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-06-13 12:53:19 -0700
committerJunio C Hamano <gitster@pobox.com>2009-06-13 12:53:19 -0700
commite2486193c54e5404bad1748d220f58a414867797 (patch)
treedaa1c56dba69c11c01476fa31c99d4f2b172b752 /transport.c
parentcec3f989dab861761ad83e264c3cd8a754e4ace5 (diff)
parent5424bc557fc6414660830b470dd45774b8f5f281 (diff)
downloadgit-e2486193c54e5404bad1748d220f58a414867797.tar.gz
Merge branch 'rc/http-push'
* rc/http-push: (22 commits) http*: add helper methods for fetching objects (loose) http*: add helper methods for fetching packs http: use new http API in fetch_index() http*: add http_get_info_packs http-push.c::fetch_symref(): use the new http API http-push.c::remote_exists(): use the new http API http.c::http_fetch_ref(): use the new http API transport.c::get_refs_via_curl(): use the new http API http.c: new functions for the http API http: create function end_url_with_slash http*: move common variables and macros to http.[ch] transport.c::get_refs_via_curl(): do not leak refs_url Don't expect verify_pack() callers to set pack_size http-push: do not SEGV after fetching a bad pack idx file http*: copy string returned by sha1_to_hex http-walker: verify remote packs http-push, http-walker: style fixes t5550-http-fetch: test fetching of packed objects http-push: fix missing "#ifdef USE_CURL_MULTI" around "is_running_queue" http-push: send out fetch requests on queue ...
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/transport.c b/transport.c
index d8a2392a65..501a77b241 100644
--- a/transport.c
+++ b/transport.c
@@ -439,9 +439,7 @@ static struct ref *get_refs_via_curl(struct transport *transport, int for_push)
char *ref_name;
char *refs_url;
int i = 0;
-
- struct active_request_slot *slot;
- struct slot_results results;
+ int http_ret;
struct ref *refs = NULL;
struct ref *ref = NULL;
@@ -461,25 +459,16 @@ static struct ref *get_refs_via_curl(struct transport *transport, int for_push)
refs_url = xmalloc(strlen(transport->url) + 11);
sprintf(refs_url, "%s/info/refs", transport->url);
- 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_URL, refs_url);
- curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
-
- if (start_active_slot(slot)) {
- run_active_slot(slot);
- if (results.curl_result != CURLE_OK) {
- strbuf_release(&buffer);
- if (missing_target(&results))
- die("%s not found: did you run git update-server-info on the server?", refs_url);
- else
- die("%s download error - %s", refs_url, curl_errorstr);
- }
- } else {
- strbuf_release(&buffer);
- die("Unable to start HTTP request");
+ http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);
+ switch (http_ret) {
+ case HTTP_OK:
+ break;
+ case HTTP_MISSING_TARGET:
+ die("%s not found: did you run git update-server-info on the"
+ " server?", refs_url);
+ default:
+ http_error(refs_url, http_ret);
+ die("HTTP request failed");
}
data = buffer.buf;
@@ -519,6 +508,8 @@ static struct ref *get_refs_via_curl(struct transport *transport, int for_push)
free(ref);
}
+ strbuf_release(&buffer);
+ free(refs_url);
return refs;
}