# [PATCH 0/3] http*: refactor fetching code (v2)

7 messages from 2009-05-18 to 2009-05-22. Participants: Tay Ray Chuan, Mike Hommey, Johannes Schindelin, Tony Finch, Clemens Buchacher.
Thread: https://gitlist.dev/t/19396

## Tay Ray Chuan, 2009-05-18 08:30

Subject: [PATCH 0/3] http*: refactor fetching code (v2)
Message-ID: <20090518163025.58842505.rctay89@gmail.com>
URL: https://gitlist.dev/e/20090518163025.58842505.rctay89%40gmail.com

```
This patch series applies on pu.

The major differences between this series and the 11-patch long one
(dated May 15, 2009) are:

 *check 'preq' pointer before using it (for fetching packs) [1]
 *moved free(url) before 'abort' label to stop -Wuninitialized warning
  (for fetching loose objects) [2]
 *use unlink_or_warn, after 691f1a2 ("replace direct calls to unlink
  (2) with unlink_or_warn")

Junio: I've rebased the patch series on pu, hopefully this stops the
attribute warnings for patch 3.

Tay Ray Chuan (3):
  http*: add helper methods for fetching packs
  http*: add helper methods for fetching objects/info/packs
  http*: add helper methods for fetching objects (loose)

 http-push.c   |  378 ++++++++--------------------------------------------
 http-walker.c |  407 +++++++++++---------------------------------------------
 http.c        |  415 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 http.h        |   72 ++++++++++-
 4 files changed, 616 insertions(+), 656 deletions(-)

Footnotes:
[1] @@ -595,17 +595,21 @@ static void finish_request(struct transfer_request *request)
     			start_fetch_packed(request);
     
     	} else if (request->state == RUN_FETCH_PACKED) {
    +		int fail = 1;
     		if (request->curl_result != CURLE_OK) {
     			fprintf(stderr, "Unable to get pack file %s\n%s",
     				request->url, curl_errorstr);
    -			repo->can_update_info_refs = 0;
     		} else {
     			preq = (struct http_pack_request *)request->userData;
     
    -			if (finish_http_pack_request(preq))
    -				repo->can_update_info_refs = 0;
    +			if (preq) {
    +				if (finish_http_pack_request(preq) > 0)
    +					fail = 0;
    +				release_http_pack_request(preq);
    +			}
     		}
    -		release_http_pack_request(preq);
    +		if (fail)
    +			repo->can_update_info_refs = 0;
     		release_request(request);
     	}
     }
    
[2] @@ -1167,9 +1167,9 @@ struct http_object_request
    *new_http_object_request(const char *base_url, 
     	return freq;
     
    +	free(url);
     abort:
     	free(filename);
    -	free(url);
     	free(freq);
     	return NULL;
     }

```

## Mike Hommey, 2009-05-20 07:43

Subject: Re: [PATCH 0/3] http*: refactor fetching code (v2)
Message-ID: <20090520074352.GC21455@glandium.org>
URL: https://gitlist.dev/e/20090520074352.GC21455%40glandium.org
In-Reply-To: <20090518163025.58842505.rctay89@gmail.com>

```
On Mon, May 18, 2009 at 04:30:25PM +0800, Tay Ray Chuan wrote:
> This patch series applies on pu.
> 
> The major differences between this series and the 11-patch long one
> (dated May 15, 2009) are:
> 
>  *check 'preq' pointer before using it (for fetching packs) [1]
>  *moved free(url) before 'abort' label to stop -Wuninitialized warning
>   (for fetching loose objects) [2]
>  *use unlink_or_warn, after 691f1a2 ("replace direct calls to unlink
>   (2) with unlink_or_warn")
> 
> Junio: I've rebased the patch series on pu, hopefully this stops the
> attribute warnings for patch 3.
> 
> Tay Ray Chuan (3):
>   http*: add helper methods for fetching packs
>   http*: add helper methods for fetching objects/info/packs
>   http*: add helper methods for fetching objects (loose)

I do think these would be even better if they were integrated with
http://kerneltrap.org/mailarchive/git/2009/1/18/4757804.

Speaking of which, do we have a better http test suite now ? If we do, I
can try to (finally) finalize my work.

Mike

```

## Johannes Schindelin, 2009-05-20 10:21

Subject: Re: [PATCH 0/3] http*: refactor fetching code (v2)
Message-ID: <alpine.DEB.1.00.0905201220270.16461@intel-tinevez-2-302>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0905201220270.16461%40intel-tinevez-2-302
In-Reply-To: <20090520074352.GC21455@glandium.org>

```
Hi,

On Wed, 20 May 2009, Mike Hommey wrote:

> do we have a better http test suite now ? If we do, I can try to 
> (finally) finalize my work.

Oops, sorry, I know I promised to work on that, but I simply lack the 
time.

Sorry,
Dscho

```

## Tay Ray Chuan, 2009-05-20 12:10

Subject: Re: [PATCH 0/3] http*: refactor fetching code (v2)
Message-ID: <be6fef0d0905200510w612d6dd0k7948a3194e6f7c15@mail.gmail.com>
URL: https://gitlist.dev/e/be6fef0d0905200510w612d6dd0k7948a3194e6f7c15%40mail.gmail.com
In-Reply-To: <20090520074352.GC21455@glandium.org>

```
Hi,

On Wed, May 20, 2009 at 3:43 PM, Mike Hommey <mh@glandium.org> wrote:
> I do think these would be even better if they were integrated with
> http://kerneltrap.org/mailarchive/git/2009/1/18/4757804.

yes, I agree very much with your proposed http API, with methods for
fetching to files and strbufs. Please think of my patch series as an
intermediate step for your patches, by reducing the amount of code
involved in this API-ish refactoring.

I'm presently working on this.

-- 
Cheers,
Ray Chuan

```

## Tay Ray Chuan, 2009-05-20 12:14

Subject: Re: [PATCH 0/3] http*: refactor fetching code (v2)
Message-ID: <be6fef0d0905200514p55317a80ra765f6027f47c339@mail.gmail.com>
URL: https://gitlist.dev/e/be6fef0d0905200514p55317a80ra765f6027f47c339%40mail.gmail.com
In-Reply-To: <alpine.DEB.1.00.0905201220270.16461@intel-tinevez-2-302>

```
Hi,

On Wed, May 20, 2009 at 6:21 PM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
> Oops, sorry, I know I promised to work on that, but I simply lack the
> time.

a quick list of tests available for http* (I left out some minor ones):

t5540-http-push:
 *push to remote repository with packed refs
 *push to remote repository with unpacked refs
 *http-push fetches unpacked objects
 *http-push fetches packed objects
 *create and delete remote branch

t5550-http-fetch:
 *fetch changes via http
 *http remote detects correct HEAD
 *fetch packed objects

Mike and Johannes, what else do you have in mind?

-- 
Cheers,
Ray Chuan

```

## Tony Finch, 2009-05-20 14:03

Subject: Re: [PATCH 0/3] http*: refactor fetching code (v2)
Message-ID: <alpine.LSU.2.00.0905201500220.23478@hermes-2.csi.cam.ac.uk>
URL: https://gitlist.dev/e/alpine.LSU.2.00.0905201500220.23478%40hermes-2.csi.cam.ac.uk
In-Reply-To: <20090520074352.GC21455@glandium.org>

```
On this topic, some of my friends have complained that git doesn't
automatically try appending .git to a URL when it fails to find a
bare git repository on the server.

Tony.
-- 
f.anthony.n.finch  <dot@dotat.at>  http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.

```

## Clemens Buchacher, 2009-05-22 08:34

Subject: Re: [PATCH 0/3] http*: refactor fetching code (v2)
Message-ID: <20090522083442.GA30571@localhost>
URL: https://gitlist.dev/e/20090522083442.GA30571%40localhost
In-Reply-To: <be6fef0d0905200514p55317a80ra765f6027f47c339@mail.gmail.com>

```
On Wed, May 20, 2009 at 08:14:59PM +0800, Tay Ray Chuan wrote:
> a quick list of tests available for http* (I left out some minor ones):
[...]
> 
> Mike and Johannes, what else do you have in mind?

As I understand it, there is a bunch of error regressions in Mike's patches.
Having tests for those would help.

```
