Skip to contentSkip to conversation

http-push.c::fetch_symref(): use the new http API

PATCH In review Tay Ray Chuan 3 participants 5 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 19/23 http-push.c::fetch_symref(): use the new http API

From: Mike Hommey <[email protected]>
Subject: [WIP Patch 09/12] Use the new http API in fetch_symref()
Date: Sun, 18 Jan 2009 09:04:34 +0100

---
 http-push.c |   20 +++-----------------
 1 files changed, 3 insertions(+), 17 deletions(-)
http-push.c +3 -17
index 455e0aa..1714e4e 100644
@@ -2029,27 +2029,13 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
 {
 	char *url;
 	struct strbuf buffer = STRBUF_INIT;
-	struct active_request_slot *slot;
-	struct slot_results results;
 
 	url = xmalloc(strlen(repo->url) + strlen(path) + 1);
 	sprintf(url, "%s%s", repo->url, path);
 
-	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) {
-			die("Couldn't get %s for remote symref\n%s",
-			    url, curl_errorstr);
-		}
-	} else {
-		die("Unable to start remote symref request");
-	}
+	if (http_get_strbuf(url, &buffer, 0) != HTTP_OK)
+		die("Couldn't get %s for remote symref\n%s", url,
+		    curl_errorstr);
 	free(url);
 
 	free(*symref);

--
1.6.3.1

#1 lore raw
Quoted 2 lines · Tay Ray Chuan

From: Mike Hommey <[email protected]>
Subject: [WIP Patch 09/12] Use the new http API in fetch_symref()

What is the subject of this patch:
"http-push.c::fetch_symref(): use the new http API"
or
"Use the new http API in fetch_symref()"

Quoted 5 lines

Date: Sun, 18 Jan 2009 09:04:34 +0100

---

If you wanted to note old subject, it would be better to put it in comments (here).

Quoted 41 lines
 http-push.c |   20 +++-----------------
 1 files changed, 3 insertions(+), 17 deletions(-)
http-push.c +3 -18
index 455e0aa..1714e4e 100644
@@ -2029,27 +2029,13 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
 {
 	char *url;
 	struct strbuf buffer = STRBUF_INIT;
-	struct active_request_slot *slot;
-	struct slot_results results;
 
 	url = xmalloc(strlen(repo->url) + strlen(path) + 1);
 	sprintf(url, "%s%s", repo->url, path);
 
-	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) {
-			die("Couldn't get %s for remote symref\n%s",
-			    url, curl_errorstr);
-		}
-	} else {
-		die("Unable to start remote symref request");
-	}
+	if (http_get_strbuf(url, &buffer, 0) != HTTP_OK)
+		die("Couldn't get %s for remote symref\n%s", url,
+		    curl_errorstr);
 	free(url);
 
 	free(*symref);
--

1.6.3.1

Signature · 3 lines
Jakub Narebski
Poland
ShadeHawk on #git
#2 lore raw

Hi,

Quoted 10 lines · Jakub Narebski
Quoted 2 lines

From: Mike Hommey <[email protected]>
Subject: [WIP Patch 09/12] Use the new http API in fetch_symref()

What is the subject of this patch:
 "http-push.c::fetch_symref(): use the new http API"
or
 "Use the new http API in fetch_symref()"
[...]
If you wanted to note old subject, it would be better to put it in comments (here).

Since the title of the patch differed from Mike's original, I was afraid the attribution to the author's original patch was lost on the reader of the commit message, thus I added the original subject, in addition to the author and date, into the commit message.

I didn't add the subject line in Mike's other patches, like patch #11, because the title of the original patch and the current one are the same, so it's easy for readers to know what patch is being attributed to.

Signature · 2 lines
Cheers,
Ray Chuan
#3 lore raw
Quoted 12 lines · Tay Ray Chuan
Quoted 10 lines · Jakub Narebski
Quoted 2 lines

From: Mike Hommey <[email protected]>
Subject: [WIP Patch 09/12] Use the new http API in fetch_symref()

What is the subject of this patch:
 "http-push.c::fetch_symref(): use the new http API"
or
 "Use the new http API in fetch_symref()"
[...]
If you wanted to note old subject, it would be better to put it in comments (here).

Quoted 4 lines

Since the title of the patch differed from Mike's original, I was afraid the attribution to the author's original patch was lost on the reader of the commit message, thus I added the original subject, in addition to the author and date, into the commit message.

Please don't.

If you chose to use a better (in your opinion) subject from the original one, we'd want to have that improved one in our commit. The same thing if you chose to rewrite the proposed commit log message, or the contents of the patch, to add your own improvement. That is what we review here, and if people think your submitted version is good, that is what we want to record as a commit.

So, in general we would want to see something like this:

(1) From: Tay Ray Chuan <[email protected]>
Subject: [PATCH 19/23] http-push.c:fetch_symref(): use the new HTTP API

(2) From: Mike Hommey <[email protected]>

(3) Now the contents of a file can be slurped into a strbuf with a single
call to http_get_strbuf(), use it to simplify fetch_symref().

(4) Signed-off-by: Mike Hommey <[email protected]>

(5) ---
(6) This is based on Mike's earlier patch:

Subject: [WIP Patch 09/12] Use the new http API in fetch_symref()
Date: Sun, 18 Jan 2009 09:04:34 +0100

I retitlted Mike's patch in order to ...
Also changed frotz and nitfol so that they distim doshes better...

(7) http-push.c | 20 +++-----------------

         1 files changed, 3 insertions(+), 17 deletions(-)

(8) diff --git a/http-push.c b/http-push.c

        ...

That is,

(1) RFC2822 headers your MUA gives us;

(2) In-body (fake)headers for From: if the author is different from what (1) records. If you are forwarding somebody else's patch verbatim without modification, you may want to add Date: to keep the original datestamp, but if you are sending a version with your own improvements, we would rather use the Date: recorded in (1) in the final commit.

(3) Proposed commit log message;

(4) Chain of Signed-off-by lines;

(5) Three-dash separator;

(6) Commentary to explain the history of the patch, and/or background information if necessary,

(7) diffstat;

(8) the patch itself.

Thanks.

#4 lore raw

Hi,

Quoted 1 line · Junio C Hamano

Please don't.

Ok.

Quoted 4 lines

   (5) Three-dash separator;

   (6) Commentary to explain the history of the patch, and/or background information if necessary,

Is there anyway git can store and display these "commentaries"? I find myself having to repeatedly write this.

Signature · 2 lines
Cheers,
Ray Chuan