projects
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix for http-fetch from file:// URLs
[git.git]
/
http-fetch.c
diff --git
a/http-fetch.c
b/http-fetch.c
index
4353173
..
61b2188
100644
(file)
--- a/
http-fetch.c
+++ b/
http-fetch.c
@@
-267,7
+267,8
@@
static void process_object_response(void *callback_data)
obj_req->state = COMPLETE;
/* Use alternates if necessary */
obj_req->state = COMPLETE;
/* Use alternates if necessary */
- if (obj_req->http_code == 404) {
+ if (obj_req->http_code == 404 ||
+ obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE) {
fetch_alternates(alt->base);
if (obj_req->repo->next != NULL) {
obj_req->repo =
fetch_alternates(alt->base);
if (obj_req->repo->next != NULL) {
obj_req->repo =
@@
-475,7
+476,8
@@
static void process_alternates_response(void *callback_data)
}
}
} else if (slot->curl_result != CURLE_OK) {
}
}
} else if (slot->curl_result != CURLE_OK) {
- if (slot->http_code != 404) {
+ if (slot->http_code != 404 &&
+ slot->curl_result != CURLE_FILE_COULDNT_READ_FILE) {
got_alternates = -1;
return;
}
got_alternates = -1;
return;
}
@@
-637,7
+639,8
@@
static int fetch_indices(struct alt_base *repo)
if (start_active_slot(slot)) {
run_active_slot(slot);
if (slot->curl_result != CURLE_OK) {
if (start_active_slot(slot)) {
run_active_slot(slot);
if (slot->curl_result != CURLE_OK) {
- if (slot->http_code == 404) {
+ if (slot->http_code == 404 ||
+ slot->curl_result == CURLE_FILE_COULDNT_READ_FILE) {
repo->got_indices = 1;
free(buffer.buffer);
return 0;
repo->got_indices = 1;
free(buffer.buffer);
return 0;
@@
-658,7
+661,7
@@
static int fetch_indices(struct alt_base *repo)
switch (data[i]) {
case 'P':
i++;
switch (data[i]) {
case 'P':
i++;
- if (i + 52 < buffer.posn &&
+ if (i + 52 <
=
buffer.posn &&
!strncmp(data + i, " pack-", 6) &&
!strncmp(data + i + 46, ".pack\n", 6)) {
get_sha1_hex(data + i + 6, sha1);
!strncmp(data + i, " pack-", 6) &&
!strncmp(data + i + 46, ".pack\n", 6)) {
get_sha1_hex(data + i + 6, sha1);
@@
-667,7
+670,7
@@
static int fetch_indices(struct alt_base *repo)
break;
}
default:
break;
}
default:
- while (data[i] != '\n')
+ while (
i < buffer.posn &&
data[i] != '\n')
i++;
}
i++;
i++;
}
i++;
@@
-802,7
+805,8
@@
static int fetch_object(struct alt_base *repo, unsigned char *sha1)
ret = error("Request for %s aborted", hex);
} else if (obj_req->curl_result != CURLE_OK &&
obj_req->http_code != 416) {
ret = error("Request for %s aborted", hex);
} else if (obj_req->curl_result != CURLE_OK &&
obj_req->http_code != 416) {
- if (obj_req->http_code == 404)
+ if (obj_req->http_code == 404 ||
+ obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE)
ret = -1; /* Be silent, it is probably in a pack. */
else
ret = error("%s (curl_result = %d, http_code = %ld, sha1 = %s)",
ret = -1; /* Be silent, it is probably in a pack. */
else
ret = error("%s (curl_result = %d, http_code = %ld, sha1 = %s)",
@@
-922,6
+926,8
@@
int main(int argc, char **argv)
int arg = 1;
int rc = 0;
int arg = 1;
int rc = 0;
+ setup_git_directory();
+
while (arg < argc && argv[arg][0] == '-') {
if (argv[arg][1] == 't') {
get_tree = 1;
while (arg < argc && argv[arg][0] == '-') {
if (argv[arg][1] == 't') {
get_tree = 1;