Browse Source

[PATCH] Don't fetch objects that exist in the local repository

Be sure not to fetch objects that already exist in the local repository.
The main process loop no longer performs this check, http-fetch now checks
prior to starting a new request queue entry and when fetch_object() is called,
and local-fetch now checks when fetch_object() is called.

As discussed in this thread: http://marc.theaimsgroup.com/?t=112854890500001

Signed-off-by: Nick Hengeveld <nickh@reactrix.com>
maint
Nick Hengeveld 19 years ago committed by Junio C Hamano
parent
commit
11f0dafe2b
  1. 2
      fetch.c
  2. 10
      http-fetch.c
  3. 5
      local-fetch.c

2
fetch.c

@ -165,7 +165,7 @@ static int loop(void) @@ -165,7 +165,7 @@ static int loop(void)
* the queue because we needed to fetch it first.
*/
if (! (obj->flags & TO_SCAN)) {
if (!has_sha1_file(obj->sha1) && fetch(obj->sha1)) {
if (fetch(obj->sha1)) {
report_missing(obj->type
? obj->type
: "object", obj->sha1);

10
http-fetch.c

@ -489,7 +489,10 @@ void process_request_queue() @@ -489,7 +489,10 @@ void process_request_queue()

while (active_requests < max_requests && request != NULL) {
if (request->state == WAITING) {
start_request(request);
if (has_sha1_file(request->sha1))
release_request(request);
else
start_request(request);
curl_multi_perform(curlm, &num_transfers);
}
request = request->next;
@ -890,6 +893,11 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1) @@ -890,6 +893,11 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1)
if (request == NULL)
return error("Couldn't find request for %s in the queue", hex);

if (has_sha1_file(request->sha1)) {
release_request(request);
return 0;
}

#ifdef USE_CURL_MULTI
int num_transfers;
while (request->state == WAITING) {

5
local-fetch.c

@ -166,7 +166,10 @@ static int fetch_file(const unsigned char *sha1) @@ -166,7 +166,10 @@ static int fetch_file(const unsigned char *sha1)

int fetch(unsigned char *sha1)
{
return fetch_file(sha1) && fetch_pack(sha1);
if (has_sha1_file(sha1))
return 0;
else
return fetch_file(sha1) && fetch_pack(sha1);
}

int fetch_ref(char *ref, unsigned char *sha1)

Loading…
Cancel
Save