| 277 | } |
| 278 | |
| 279 | int walker_fetch(struct walker *walker, int targets, char **target, |
| 280 | const char **write_ref, const char *write_ref_log_details) |
| 281 | { |
| 282 | struct strbuf refname = STRBUF_INIT; |
| 283 | struct strbuf err = STRBUF_INIT; |
| 284 | struct ref_transaction *transaction = NULL; |
| 285 | struct object_id *oids; |
| 286 | char *msg = NULL; |
| 287 | int i, ret = -1; |
| 288 | |
| 289 | save_commit_buffer = 0; |
| 290 | |
| 291 | ALLOC_ARRAY(oids, targets); |
| 292 | |
| 293 | if (write_ref) { |
| 294 | transaction = ref_store_transaction_begin(get_main_ref_store(the_repository), |
| 295 | 0, &err); |
| 296 | if (!transaction) { |
| 297 | error("%s", err.buf); |
| 298 | goto done; |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | if (!walker->get_recover) { |
| 303 | refs_for_each_ref(get_main_ref_store(the_repository), |
| 304 | mark_complete, NULL); |
| 305 | } |
| 306 | |
| 307 | for (i = 0; i < targets; i++) { |
| 308 | if (interpret_target(walker, target[i], oids + i)) { |
| 309 | error("Could not interpret response from server '%s' as something to pull", target[i]); |
| 310 | goto done; |
| 311 | } |
| 312 | if (process(walker, lookup_unknown_object(the_repository, &oids[i]))) |
| 313 | goto done; |
| 314 | } |
| 315 | |
| 316 | if (loop(walker)) |
| 317 | goto done; |
| 318 | if (!write_ref) { |
| 319 | ret = 0; |
| 320 | goto done; |
| 321 | } |
| 322 | if (write_ref_log_details) { |
| 323 | msg = xstrfmt("fetch from %s", write_ref_log_details); |
| 324 | } else { |
| 325 | msg = NULL; |
| 326 | } |
| 327 | for (i = 0; i < targets; i++) { |
| 328 | if (!write_ref[i]) |
| 329 | continue; |
| 330 | strbuf_reset(&refname); |
| 331 | strbuf_addf(&refname, "refs/%s", write_ref[i]); |
| 332 | if (ref_transaction_update(transaction, refname.buf, |
| 333 | oids + i, NULL, NULL, NULL, 0, |
| 334 | msg ? msg : "fetch (unknown)", |
| 335 | &err)) { |
| 336 | error("%s", err.buf); |
no test coverage detected