| 397 | } |
| 398 | |
| 399 | static void read_alternate_refs(struct repository *repo, |
| 400 | const char *path, |
| 401 | odb_for_each_alternate_ref_fn *cb, |
| 402 | void *payload) |
| 403 | { |
| 404 | struct child_process cmd = CHILD_PROCESS_INIT; |
| 405 | struct strbuf line = STRBUF_INIT; |
| 406 | FILE *fh; |
| 407 | |
| 408 | fill_alternate_refs_command(repo, &cmd, path); |
| 409 | |
| 410 | if (start_command(&cmd)) |
| 411 | return; |
| 412 | |
| 413 | fh = xfdopen(cmd.out, "r"); |
| 414 | while (strbuf_getline_lf(&line, fh) != EOF) { |
| 415 | struct object_id oid; |
| 416 | const char *p; |
| 417 | |
| 418 | if (parse_oid_hex_algop(line.buf, &oid, &p, repo->hash_algo) || *p) { |
| 419 | warning(_("invalid line while parsing alternate refs: %s"), |
| 420 | line.buf); |
| 421 | break; |
| 422 | } |
| 423 | |
| 424 | cb(&oid, payload); |
| 425 | } |
| 426 | |
| 427 | fclose(fh); |
| 428 | finish_command(&cmd); |
| 429 | strbuf_release(&line); |
| 430 | } |
| 431 | |
| 432 | struct alternate_refs_data { |
| 433 | odb_for_each_alternate_ref_fn *fn; |
no test coverage detected