git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[WIP Patch 04/12] Use the new http API in http_fetch_ref()

From
Mike Hommey <mh@glandium.org>
Date
Jan 18, 2009, 08:04 UTC
Message-ID
<1232265877-3649-5-git-send-email-mh@glandium.org>
In-Reply-To
<1232265877-3649-4-git-send-email-mh@glandium.org>
Signed-off-by: Mike Hommey <mh@glandium.org>
---
 http.c |   33 ++++++++-------------------------
 1 files changed, 8 insertions(+), 25 deletions(-)
diff --git a/http.c b/http.c
index 82534cf..0c9504b 100644
--- a/http.c
+++ b/http.c
@@ -604,34 +604,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.1.141.gb32a
Previous: Mike HommeyNext: Mike Hommey
Message 9 of 33 in “http-push: fix off-by-path_len”
  1. http-push: fix off-by-path_lenJohannes Schindelin, Jan 17, 2009
  2. Where's Nick?, was Re: [PATCH] http-push: fix off-by-path_lenJohannes Schindelin, Jan 17, 2009
  3. t5540: clarify that http-push does not handle packed-refs on the remoteJohannes Schindelin, Jan 17, 2009
  4. Mike HommeyJan 18, 2009
  5. 00/12 Refactoring the http APIMike Hommey, Jan 18, 2009
  6. 01/12 Don't expect verify_pack() callers to set pack_sizeMike Hommey, Jan 18, 2009
  7. 02/12 Some cleanup in get_refs_via_curl()Mike Hommey, Jan 18, 2009
  8. 03/12 Two new functions for the http APIMike Hommey, Jan 18, 2009
  9. 04/12 Use the new http API in http_fetch_ref()Mike Hommey, Jan 18, 2009
  10. 05/12 Use the new http API in get_refs_via_curl()Mike Hommey, Jan 18, 2009
  11. 06/12 Use the new http API in http-walker.c:fetch_indices()Mike Hommey, Jan 18, 2009
  12. 07/12 Use the new http API in http-push.c:fetch_indices()Mike Hommey, Jan 18, 2009
  13. 08/12 Use the new http API in update_remote_info_refs()Mike Hommey, Jan 18, 2009
  14. 09/12 Use the new http API in fetch_symref()Mike Hommey, Jan 18, 2009
  15. 10/12 Use the new http API in http-walker.c:fetch_index()Mike Hommey, Jan 18, 2009
  16. 11/12 Use the new http API in http-push.c:fetch_index()Mike Hommey, Jan 18, 2009
  17. 12/12 Use the new http API in http-walker.c:fetch_pack()Mike Hommey, Jan 18, 2009
  18. Johannes SchindelinJan 18, 2009
  19. Mike HommeyJan 18, 2009
  20. Johannes SchindelinJan 18, 2009
  21. Johannes SchindelinJan 18, 2009
  22. Johannes SchindelinJan 18, 2009
  23. Mike HommeyJan 18, 2009
  24. Johannes SchindelinJan 18, 2009
  25. Johannes SchindelinJan 18, 2009
  26. Johannes SchindelinJan 18, 2009
  27. Mike HommeyJan 18, 2009
  28. Johannes SchindelinJan 18, 2009
  29. Mike HommeyJan 18, 2009
  30. Johannes SchindelinJan 18, 2009
  31. Junio C HamanoJan 18, 2009
  32. Mike HommeyJan 18, 2009
  33. Boyd Stephen Smith Jr.Jan 18, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.