Merge branch 'dl/complete-cherry-pick-revert-skip'
[git/git.git] / http-walker.c
CommitLineData
6eb7ed54 1#include "cache.h"
cf78ae4f 2#include "repository.h"
6eb7ed54 3#include "commit.h"
30ae764b 4#include "walker.h"
29508e1e 5#include "http.h"
94e99012 6#include "list.h"
abcbdc03 7#include "transport.h"
d6fe0036 8#include "packfile.h"
a80d72db 9#include "object-store.h"
7baa3e86 10
9cba13ca 11struct alt_base {
2afea3bc 12 char *base;
b3661567
DB
13 int got_indices;
14 struct packed_git *packs;
15 struct alt_base *next;
16};
17
e388ab74 18enum object_request_state {
1d389ab6
NH
19 WAITING,
20 ABORTED,
21 ACTIVE,
4b05548f 22 COMPLETE
1d389ab6 23};
6eb7ed54 24
9cba13ca 25struct object_request {
30ae764b 26 struct walker *walker;
16f0705d 27 struct object_id oid;
1d389ab6 28 struct alt_base *repo;
e388ab74 29 enum object_request_state state;
5424bc55 30 struct http_object_request *req;
94e99012 31 struct list_head node;
1d389ab6
NH
32};
33
e388ab74 34struct alternates_request {
30ae764b 35 struct walker *walker;
8e29f6a0 36 const char *base;
54ba4c5f 37 struct strbuf *url;
028c2976 38 struct strbuf *buffer;
acc075a8
NH
39 struct active_request_slot *slot;
40 int http_specific;
41};
42
30ae764b
DB
43struct walker_data {
44 const char *url;
45 int got_alternates;
46 struct alt_base *alt;
30ae764b
DB
47};
48
94e99012 49static LIST_HEAD(object_queue_head);
bc8f2652 50
30ae764b 51static void fetch_alternates(struct walker *walker, const char *base);
1d389ab6 52
29508e1e 53static void process_object_response(void *callback_data);
1d389ab6 54
30ae764b
DB
55static void start_object_request(struct walker *walker,
56 struct object_request *obj_req)
1d389ab6 57{
1d389ab6 58 struct active_request_slot *slot;
5424bc55 59 struct http_object_request *req;
1d389ab6 60
f0be0db1 61 req = new_http_object_request(obj_req->repo->base, &obj_req->oid);
5424bc55 62 if (req == NULL) {
e388ab74 63 obj_req->state = ABORTED;
1d389ab6
NH
64 return;
65 }
5424bc55 66 obj_req->req = req;
1d389ab6 67
5424bc55 68 slot = req->slot;
29508e1e 69 slot->callback_func = process_object_response;
e388ab74 70 slot->callback_data = obj_req;
1d389ab6 71
a7a8d378 72 /* Try to get the request started, abort the request on error */
e388ab74 73 obj_req->state = ACTIVE;
1d389ab6 74 if (!start_active_slot(slot)) {
e388ab74 75 obj_req->state = ABORTED;
5424bc55 76 release_http_object_request(req);
e388ab74 77 return;
1d389ab6 78 }
1d389ab6
NH
79}
80
e388ab74 81static void finish_object_request(struct object_request *obj_req)
1d389ab6 82{
5424bc55 83 if (finish_http_object_request(obj_req->req))
1d389ab6 84 return;
1d389ab6 85
5424bc55 86 if (obj_req->req->rename == 0)
16f0705d 87 walker_say(obj_req->walker, "got %s\n", oid_to_hex(&obj_req->oid));
1d389ab6
NH
88}
89
29508e1e
NH
90static void process_object_response(void *callback_data)
91{
e388ab74
NH
92 struct object_request *obj_req =
93 (struct object_request *)callback_data;
30ae764b
DB
94 struct walker *walker = obj_req->walker;
95 struct walker_data *data = walker->data;
96 struct alt_base *alt = data->alt;
29508e1e 97
5424bc55 98 process_http_object_request(obj_req->req);
e388ab74 99 obj_req->state = COMPLETE;
29508e1e 100
ccbbd8bf
JK
101 normalize_curl_result(&obj_req->req->curl_result,
102 obj_req->req->http_code,
103 obj_req->req->errorstr,
104 sizeof(obj_req->req->errorstr));
105
29508e1e 106 /* Use alternates if necessary */
5424bc55 107 if (missing_target(obj_req->req)) {
30ae764b 108 fetch_alternates(walker, alt->base);
e388ab74
NH
109 if (obj_req->repo->next != NULL) {
110 obj_req->repo =
111 obj_req->repo->next;
5424bc55 112 release_http_object_request(obj_req->req);
30ae764b 113 start_object_request(walker, obj_req);
29508e1e
NH
114 return;
115 }
116 }
117
e388ab74 118 finish_object_request(obj_req);
29508e1e
NH
119}
120
e388ab74 121static void release_object_request(struct object_request *obj_req)
1d389ab6 122{
5424bc55
TRC
123 if (obj_req->req !=NULL && obj_req->req->localfile != -1)
124 error("fd leakage in release: %d", obj_req->req->localfile);
1d389ab6 125
94e99012 126 list_del(&obj_req->node);
e388ab74 127 free(obj_req);
1d389ab6
NH
128}
129
a7a8d378 130#ifdef USE_CURL_MULTI
30ae764b 131static int fill_active_slot(struct walker *walker)
1d389ab6 132{
45c17412 133 struct object_request *obj_req;
94e99012 134 struct list_head *pos, *tmp, *head = &object_queue_head;
1d389ab6 135
94e99012
EW
136 list_for_each_safe(pos, tmp, head) {
137 obj_req = list_entry(pos, struct object_request, node);
e388ab74 138 if (obj_req->state == WAITING) {
98374a07 139 if (has_object_file(&obj_req->oid))
09db444f 140 obj_req->state = COMPLETE;
45c17412 141 else {
30ae764b 142 start_object_request(walker, obj_req);
45c17412
DB
143 return 1;
144 }
f1a906a3 145 }
8fcf7f9a 146 }
45c17412 147 return 0;
1d389ab6 148}
a7a8d378 149#endif
1d389ab6 150
30ae764b 151static void prefetch(struct walker *walker, unsigned char *sha1)
1d389ab6 152{
e388ab74 153 struct object_request *newreq;
30ae764b 154 struct walker_data *data = walker->data;
1d389ab6
NH
155
156 newreq = xmalloc(sizeof(*newreq));
30ae764b 157 newreq->walker = walker;
16f0705d 158 hashcpy(newreq->oid.hash, sha1);
30ae764b 159 newreq->repo = data->alt;
1d389ab6 160 newreq->state = WAITING;
5424bc55 161 newreq->req = NULL;
1d389ab6 162
e9176745 163 http_is_verbose = walker->get_verbosely;
94e99012 164 list_add_tail(&newreq->node, &object_queue_head);
29508e1e 165
a7a8d378 166#ifdef USE_CURL_MULTI
29508e1e
NH
167 fill_active_slots();
168 step_active_slots();
a7a8d378 169#endif
1d389ab6
NH
170}
171
abcbdc03
JK
172static int is_alternate_allowed(const char *url)
173{
174 const char *protocols[] = {
175 "http", "https", "ftp", "ftps"
176 };
177 int i;
178
de461388
EW
179 if (http_follow_config != HTTP_FOLLOW_ALWAYS) {
180 warning("alternate disabled by http.followRedirects: %s", url);
181 return 0;
182 }
183
abcbdc03
JK
184 for (i = 0; i < ARRAY_SIZE(protocols); i++) {
185 const char *end;
186 if (skip_prefix(url, protocols[i], &end) &&
187 starts_with(end, "://"))
188 break;
189 }
190
191 if (i >= ARRAY_SIZE(protocols)) {
192 warning("ignoring alternate with unknown protocol: %s", url);
193 return 0;
194 }
195 if (!is_transport_allowed(protocols[i], 0)) {
196 warning("ignoring alternate with restricted protocol: %s", url);
197 return 0;
198 }
199
200 return 1;
201}
202
e388ab74 203static void process_alternates_response(void *callback_data)
b3661567 204{
e388ab74
NH
205 struct alternates_request *alt_req =
206 (struct alternates_request *)callback_data;
30ae764b
DB
207 struct walker *walker = alt_req->walker;
208 struct walker_data *cdata = walker->data;
acc075a8 209 struct active_request_slot *slot = alt_req->slot;
30ae764b 210 struct alt_base *tail = cdata->alt;
8e29f6a0 211 const char *base = alt_req->base;
a04ff3ec 212 const char null_byte = '\0';
acc075a8
NH
213 char *data;
214 int i = 0;
1d389ab6 215
ccbbd8bf
JK
216 normalize_curl_result(&slot->curl_result, slot->http_code,
217 curl_errorstr, sizeof(curl_errorstr));
218
acc075a8
NH
219 if (alt_req->http_specific) {
220 if (slot->curl_result != CURLE_OK ||
028c2976 221 !alt_req->buffer->len) {
acc075a8
NH
222
223 /* Try reusing the slot to get non-http alternates */
224 alt_req->http_specific = 0;
54ba4c5f
JK
225 strbuf_reset(alt_req->url);
226 strbuf_addf(alt_req->url, "%s/objects/info/alternates",
227 base);
acc075a8 228 curl_easy_setopt(slot->curl, CURLOPT_URL,
54ba4c5f 229 alt_req->url->buf);
acc075a8
NH
230 active_requests++;
231 slot->in_use = 1;
c9826473
NH
232 if (slot->finished != NULL)
233 (*slot->finished) = 0;
a3f583cb 234 if (!start_active_slot(slot)) {
30ae764b 235 cdata->got_alternates = -1;
29508e1e 236 slot->in_use = 0;
c9826473
NH
237 if (slot->finished != NULL)
238 (*slot->finished) = 1;
1d389ab6 239 }
a3f583cb 240 return;
b3661567 241 }
acc075a8 242 } else if (slot->curl_result != CURLE_OK) {
be4a015b 243 if (!missing_target(slot)) {
30ae764b 244 cdata->got_alternates = -1;
acc075a8
NH
245 return;
246 }
b3661567
DB
247 }
248
a04ff3ec 249 fwrite_buffer((char *)&null_byte, 1, 1, alt_req->buffer);
028c2976
MH
250 alt_req->buffer->len--;
251 data = alt_req->buffer->buf;
1b0c1e67 252
028c2976 253 while (i < alt_req->buffer->len) {
b3661567 254 int posn = i;
028c2976 255 while (posn < alt_req->buffer->len && data[posn] != '\n')
b3661567
DB
256 posn++;
257 if (data[posn] == '\n') {
1b0c1e67
DB
258 int okay = 0;
259 int serverlen = 0;
260 struct alt_base *newalt;
b3661567 261 if (data[i] == '/') {
4c42aa1a
TRC
262 /*
263 * This counts
5df1e0d0
JH
264 * http://git.host/pub/scm/linux.git/
265 * -----------here^
266 * so memcpy(dst, base, serverlen) will
267 * copy up to "...git.host".
268 */
269 const char *colon_ss = strstr(base,"://");
270 if (colon_ss) {
271 serverlen = (strchr(colon_ss + 3, '/')
272 - base);
273 okay = 1;
274 }
1b0c1e67 275 } else if (!memcmp(data + i, "../", 3)) {
4c42aa1a
TRC
276 /*
277 * Relative URL; chop the corresponding
5df1e0d0
JH
278 * number of subpath from base (and ../
279 * from data), and concatenate the result.
280 *
281 * The code first drops ../ from data, and
282 * then drops one ../ from data and one path
283 * from base. IOW, one extra ../ is dropped
284 * from data than path is dropped from base.
285 *
286 * This is not wrong. The alternate in
287 * http://git.host/pub/scm/linux.git/
288 * to borrow from
289 * http://git.host/pub/scm/linus.git/
290 * is ../../linus.git/objects/. You need
291 * two ../../ to borrow from your direct
292 * neighbour.
293 */
1b0c1e67
DB
294 i += 3;
295 serverlen = strlen(base);
8fcf7f9a 296 while (i + 2 < posn &&
1b0c1e67
DB
297 !memcmp(data + i, "../", 3)) {
298 do {
299 serverlen--;
300 } while (serverlen &&
301 base[serverlen - 1] != '/');
302 i += 3;
303 }
a9486b02 304 /* If the server got removed, give up. */
8fcf7f9a 305 okay = strchr(base, ':') - base + 3 <
4c42aa1a 306 serverlen;
acc075a8 307 } else if (alt_req->http_specific) {
1b0c1e67
DB
308 char *colon = strchr(data + i, ':');
309 char *slash = strchr(data + i, '/');
310 if (colon && slash && colon < data + posn &&
311 slash < data + posn && colon < slash) {
312 okay = 1;
313 }
314 }
1b0c1e67 315 if (okay) {
59b8263a
RS
316 struct strbuf target = STRBUF_INIT;
317 strbuf_add(&target, base, serverlen);
d61434ae
JK
318 strbuf_add(&target, data + i, posn - i);
319 if (!strbuf_strip_suffix(&target, "objects")) {
320 warning("ignoring alternate that does"
321 " not end in 'objects': %s",
322 target.buf);
323 strbuf_release(&target);
324 } else if (is_alternate_allowed(target.buf)) {
abcbdc03
JK
325 warning("adding alternate object store: %s",
326 target.buf);
327 newalt = xmalloc(sizeof(*newalt));
328 newalt->next = NULL;
329 newalt->base = strbuf_detach(&target, NULL);
330 newalt->got_indices = 0;
331 newalt->packs = NULL;
332
333 while (tail->next != NULL)
334 tail = tail->next;
335 tail->next = newalt;
5cae73d5
EW
336 } else {
337 strbuf_release(&target);
abcbdc03 338 }
b3661567
DB
339 }
340 }
341 i = posn + 1;
342 }
bc8f2652 343
30ae764b 344 cdata->got_alternates = 1;
acc075a8
NH
345}
346
30ae764b 347static void fetch_alternates(struct walker *walker, const char *base)
acc075a8 348{
028c2976 349 struct strbuf buffer = STRBUF_INIT;
54ba4c5f 350 struct strbuf url = STRBUF_INIT;
acc075a8 351 struct active_request_slot *slot;
cb754fdf 352 struct alternates_request alt_req;
30ae764b 353 struct walker_data *cdata = walker->data;
acc075a8 354
4c42aa1a
TRC
355 /*
356 * If another request has already started fetching alternates,
357 * wait for them to arrive and return to processing this request's
358 * curl message
359 */
29508e1e 360#ifdef USE_CURL_MULTI
30ae764b 361 while (cdata->got_alternates == 0) {
29508e1e 362 step_active_slots();
acc075a8 363 }
29508e1e 364#endif
acc075a8
NH
365
366 /* Nothing to do if they've already been fetched */
30ae764b 367 if (cdata->got_alternates == 1)
acc075a8
NH
368 return;
369
370 /* Start the fetch */
30ae764b 371 cdata->got_alternates = 0;
acc075a8 372
30ae764b 373 if (walker->get_verbosely)
acc075a8 374 fprintf(stderr, "Getting alternates list for %s\n", base);
8fcf7f9a 375
54ba4c5f 376 strbuf_addf(&url, "%s/objects/info/http-alternates", base);
acc075a8 377
4c42aa1a
TRC
378 /*
379 * Use a callback to process the result, since another request
380 * may fail and need to have alternates loaded before continuing
381 */
acc075a8 382 slot = get_active_slot();
e388ab74 383 slot->callback_func = process_alternates_response;
30ae764b 384 alt_req.walker = walker;
acc075a8
NH
385 slot->callback_data = &alt_req;
386
387 curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);
29508e1e 388 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
54ba4c5f 389 curl_easy_setopt(slot->curl, CURLOPT_URL, url.buf);
acc075a8
NH
390
391 alt_req.base = base;
54ba4c5f 392 alt_req.url = &url;
acc075a8
NH
393 alt_req.buffer = &buffer;
394 alt_req.http_specific = 1;
395 alt_req.slot = slot;
396
397 if (start_active_slot(slot))
398 run_active_slot(slot);
399 else
30ae764b 400 cdata->got_alternates = -1;
acc075a8 401
028c2976 402 strbuf_release(&buffer);
54ba4c5f 403 strbuf_release(&url);
b3661567
DB
404}
405
30ae764b 406static int fetch_indices(struct walker *walker, struct alt_base *repo)
182005b9 407{
b8caac2b 408 int ret;
1d389ab6 409
b3661567 410 if (repo->got_indices)
182005b9
DB
411 return 0;
412
30ae764b 413 if (walker->get_verbosely)
6fd72e39 414 fprintf(stderr, "Getting pack list for %s\n", repo->base);
8fcf7f9a 415
b8caac2b
TRC
416 switch (http_get_info_packs(repo->base, &repo->packs)) {
417 case HTTP_OK:
418 case HTTP_MISSING_TARGET:
419 repo->got_indices = 1;
420 ret = 0;
421 break;
422 default:
5e3a7691 423 repo->got_indices = 0;
b8caac2b 424 ret = -1;
b3661567 425 }
182005b9 426
3a462bc9 427 return ret;
182005b9
DB
428}
429
07c19e72 430static int http_fetch_pack(struct walker *walker, struct alt_base *repo, unsigned char *sha1)
182005b9 431{
182005b9 432 struct packed_git *target;
49a0f240 433 int ret;
cb754fdf 434 struct slot_results results;
2264dfa5 435 struct http_pack_request *preq;
182005b9 436
30ae764b 437 if (fetch_indices(walker, repo))
182005b9 438 return -1;
b3661567 439 target = find_sha1_pack(sha1, repo->packs);
182005b9 440 if (!target)
b3661567 441 return -1;
182005b9 442
30ae764b 443 if (walker->get_verbosely) {
182005b9 444 fprintf(stderr, "Getting pack %s\n",
2bf1db78 445 hash_to_hex(target->hash));
182005b9 446 fprintf(stderr, " which contains %s\n",
2bf1db78 447 hash_to_hex(sha1));
182005b9
DB
448 }
449
2264dfa5
TRC
450 preq = new_http_pack_request(target, repo->base);
451 if (preq == NULL)
452 goto abort;
453 preq->lst = &repo->packs;
454 preq->slot->results = &results;
182005b9 455
2264dfa5
TRC
456 if (start_active_slot(preq->slot)) {
457 run_active_slot(preq->slot);
c8568e13 458 if (results.curl_result != CURLE_OK) {
2264dfa5
TRC
459 error("Unable to get pack file %s\n%s", preq->url,
460 curl_errorstr);
461 goto abort;
1d389ab6
NH
462 }
463 } else {
2264dfa5
TRC
464 error("Unable to start request");
465 goto abort;
182005b9
DB
466 }
467
2264dfa5
TRC
468 ret = finish_http_pack_request(preq);
469 release_http_pack_request(preq);
49a0f240 470 if (ret)
b721e01f 471 return ret;
49a0f240 472
182005b9 473 return 0;
2264dfa5
TRC
474
475abort:
476 return -1;
182005b9
DB
477}
478
53f31389
MW
479static void abort_object_request(struct object_request *obj_req)
480{
53f31389
MW
481 release_object_request(obj_req);
482}
483
2bf1db78 484static int fetch_object(struct walker *walker, unsigned char *hash)
6eb7ed54 485{
2bf1db78 486 char *hex = hash_to_hex(hash);
29508e1e 487 int ret = 0;
94e99012 488 struct object_request *obj_req = NULL;
5424bc55 489 struct http_object_request *req;
94e99012 490 struct list_head *pos, *head = &object_queue_head;
1d389ab6 491
94e99012
EW
492 list_for_each(pos, head) {
493 obj_req = list_entry(pos, struct object_request, node);
2bf1db78 494 if (hasheq(obj_req->oid.hash, hash))
94e99012
EW
495 break;
496 }
e388ab74 497 if (obj_req == NULL)
1d389ab6
NH
498 return error("Couldn't find request for %s in the queue", hex);
499
98374a07 500 if (has_object_file(&obj_req->oid)) {
5424bc55
TRC
501 if (obj_req->req != NULL)
502 abort_http_object_request(obj_req->req);
53f31389 503 abort_object_request(obj_req);
11f0dafe
NH
504 return 0;
505 }
506
a7a8d378 507#ifdef USE_CURL_MULTI
4c42aa1a 508 while (obj_req->state == WAITING)
29508e1e 509 step_active_slots();
a7a8d378 510#else
30ae764b 511 start_object_request(walker, obj_req);
a7a8d378 512#endif
6eb7ed54 513
5424bc55
TRC
514 /*
515 * obj_req->req might change when fetching alternates in the callback
516 * process_object_response; therefore, the "shortcut" variable, req,
517 * is used only after we're done with slots.
518 */
4c42aa1a 519 while (obj_req->state == ACTIVE)
5424bc55
TRC
520 run_active_slot(obj_req->req->slot);
521
522 req = obj_req->req;
4c42aa1a 523
5424bc55
TRC
524 if (req->localfile != -1) {
525 close(req->localfile);
526 req->localfile = -1;
313c4714 527 }
6eb7ed54 528
3d10f72e
JK
529 normalize_curl_result(&req->curl_result, req->http_code,
530 req->errorstr, sizeof(req->errorstr));
17966c0a 531
e388ab74 532 if (obj_req->state == ABORTED) {
29508e1e 533 ret = error("Request for %s aborted", hex);
5424bc55
TRC
534 } else if (req->curl_result != CURLE_OK &&
535 req->http_code != 416) {
536 if (missing_target(req))
e2029eb9
PB
537 ret = -1; /* Be silent, it is probably in a pack. */
538 else
539 ret = error("%s (curl_result = %d, http_code = %ld, sha1 = %s)",
5424bc55
TRC
540 req->errorstr, req->curl_result,
541 req->http_code, hex);
542 } else if (req->zret != Z_STREAM_END) {
30ae764b 543 walker->corrupt_object_found++;
5424bc55 544 ret = error("File %s (%s) corrupt", hex, req->url);
f0be0db1 545 } else if (!oideq(&obj_req->oid, &req->real_oid)) {
bd2afde8 546 ret = error("File %s has bad hash", hex);
5424bc55 547 } else if (req->rename < 0) {
ea657730 548 struct strbuf buf = STRBUF_INIT;
514c5fdd 549 loose_object_path(the_repository, &buf, &req->oid);
ea657730
CC
550 ret = error("unable to write sha1 filename %s", buf.buf);
551 strbuf_release(&buf);
6eb7ed54 552 }
49a0f240 553
5424bc55 554 release_http_object_request(req);
e388ab74 555 release_object_request(obj_req);
29508e1e 556 return ret;
6eb7ed54
DB
557}
558
2bf1db78 559static int fetch(struct walker *walker, unsigned char *hash)
b3661567 560{
30ae764b
DB
561 struct walker_data *data = walker->data;
562 struct alt_base *altbase = data->alt;
1d389ab6 563
2bf1db78 564 if (!fetch_object(walker, hash))
1d389ab6 565 return 0;
b3661567 566 while (altbase) {
2bf1db78 567 if (!http_fetch_pack(walker, altbase, hash))
b3661567 568 return 0;
30ae764b 569 fetch_alternates(walker, data->alt->base);
b3661567
DB
570 altbase = altbase->next;
571 }
2bf1db78 572 return error("Unable to find %s under %s", hash_to_hex(hash),
30ae764b 573 data->alt->base);
b3661567
DB
574}
575
c13b2633 576static int fetch_ref(struct walker *walker, struct ref *ref)
cd541a68 577{
30ae764b 578 struct walker_data *data = walker->data;
c13b2633 579 return http_fetch_ref(data->alt->base, ref);
cd541a68
DB
580}
581
30ae764b
DB
582static void cleanup(struct walker *walker)
583{
09ae9aca
TRC
584 struct walker_data *data = walker->data;
585 struct alt_base *alt, *alt_next;
586
587 if (data) {
588 alt = data->alt;
589 while (alt) {
590 alt_next = alt->next;
591
592 free(alt->base);
593 free(alt);
594
595 alt = alt_next;
596 }
597 free(data);
598 walker->data = NULL;
599 }
30ae764b
DB
600}
601
888692b7 602struct walker *get_http_walker(const char *url)
6eb7ed54 603{
9c880b3e 604 char *s;
30ae764b
DB
605 struct walker_data *data = xmalloc(sizeof(struct walker_data));
606 struct walker *walker = xmalloc(sizeof(struct walker));
6eb7ed54 607
30ae764b 608 data->alt = xmalloc(sizeof(*data->alt));
95244ae3 609 data->alt->base = xstrdup(url);
30ae764b 610 for (s = data->alt->base + strlen(data->alt->base) - 1; *s == '/'; --s)
9c880b3e 611 *s = 0;
6eb7ed54 612
30ae764b
DB
613 data->alt->got_indices = 0;
614 data->alt->packs = NULL;
615 data->alt->next = NULL;
616 data->got_alternates = -1;
fc57b6aa 617
30ae764b
DB
618 walker->corrupt_object_found = 0;
619 walker->fetch = fetch;
620 walker->fetch_ref = fetch_ref;
621 walker->prefetch = prefetch;
622 walker->cleanup = cleanup;
623 walker->data = data;
6eb7ed54 624
30ae764b
DB
625#ifdef USE_CURL_MULTI
626 add_fill_function(walker, (int (*)(void *)) fill_active_slot);
627#endif
8e29f6a0 628
30ae764b 629 return walker;
6eb7ed54 630}