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

5 messages from 2009-06-05 to 2009-06-06. Participants: Tay Ray Chuan, Jakub Narebski, Junio C Hamano.
Thread: https://gitlist.dev/t/19695

## Tay Ray Chuan, 2009-06-05 16:05

Subject: [PATCH 19/23] http-push.c::fetch_symref(): use the new http API
Message-ID: <20090606000559.483f22da.rctay89@gmail.com>
URL: https://gitlist.dev/e/20090606000559.483f22da.rctay89%40gmail.com

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

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

diff --git a/http-push.c b/http-push.c
index 455e0aa..1714e4e 100644
--- a/http-push.c
+++ b/http-push.c
@@ -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

```

## Jakub Narebski, 2009-06-05 20:54

Subject: Re: [PATCH 19/23] http-push.c::fetch_symref(): use the new http API
Message-ID: <m37hzq5rod.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m37hzq5rod.fsf%40localhost.localdomain
In-Reply-To: <20090606000559.483f22da.rctay89@gmail.com>

```
Tay Ray Chuan <rctay89@gmail.com> writes:

> From:	Mike Hommey <mh@glandium.org>
> 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()"

> Date:	Sun, 18 Jan 2009 09:04:34 +0100
> 
> Signed-off-by: Mike Hommey <mh@glandium.org>
> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
> ---

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

>  http-push.c |   20 +++-----------------
>  1 files changed, 3 insertions(+), 17 deletions(-)
> 
> diff --git a/http-push.c b/http-push.c
> index 455e0aa..1714e4e 100644
> --- a/http-push.c
> +++ b/http-push.c
> @@ -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
> 

-- 
Jakub Narebski
Poland
ShadeHawk on #git

```

## Tay Ray Chuan, 2009-06-06 01:02

Subject: Re: [PATCH 19/23] http-push.c::fetch_symref(): use the new http API
Message-ID: <be6fef0d0906051802n4f6d5df3g453b292787ed62d0@mail.gmail.com>
URL: https://gitlist.dev/e/be6fef0d0906051802n4f6d5df3g453b292787ed62d0%40mail.gmail.com
In-Reply-To: <m37hzq5rod.fsf@localhost.localdomain>

```
Hi,

On Sat, Jun 6, 2009 at 4:54 AM, Jakub Narebski<jnareb@gmail.com> wrote:
>> From: Mike Hommey <mh@glandium.org>
>> 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.

-- 
Cheers,
Ray Chuan

```

## Junio C Hamano, 2009-06-06 05:32

Subject: Re: [PATCH 19/23] http-push.c::fetch_symref(): use the new http API
Message-ID: <7vvdnadj0z.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vvdnadj0z.fsf%40alter.siamese.dyndns.org
In-Reply-To: <be6fef0d0906051802n4f6d5df3g453b292787ed62d0@mail.gmail.com>

```
Tay Ray Chuan <rctay89@gmail.com> writes:

> On Sat, Jun 6, 2009 at 4:54 AM, Jakub Narebski<jnareb@gmail.com> wrote:
>>> From: Mike Hommey <mh@glandium.org>
>>> 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.

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 <rctay89@gmail.com>
        Subject: [PATCH 19/23] http-push.c:fetch_symref(): use the new HTTP API

(2)     From: Mike Hommey <mh@glandium.org>

(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 <mh@glandium.org>
        Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
(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.

```

## Tay Ray Chuan, 2009-06-06 07:20

Subject: Re: [PATCH 19/23] http-push.c::fetch_symref(): use the new http API
Message-ID: <be6fef0d0906060020x1a3a03a6ya4e58de6c83854d0@mail.gmail.com>
URL: https://gitlist.dev/e/be6fef0d0906060020x1a3a03a6ya4e58de6c83854d0%40mail.gmail.com
In-Reply-To: <7vvdnadj0z.fsf@alter.siamese.dyndns.org>

```
Hi,

On Sat, Jun 6, 2009 at 1:32 PM, Junio C Hamano<gitster@pobox.com> wrote:
> Please don't.

Ok.

>    (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.

-- 
Cheers,
Ray Chuan

```
