MCPcopy Create free account
hub / github.com/git/git / read_alternate_refs

Function read_alternate_refs

odb.c:399–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397}
398
399static 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
432struct alternate_refs_data {
433 odb_for_each_alternate_ref_fn *fn;

Callers 1

refs_from_alternate_cbFunction · 0.85

Calls 7

start_commandFunction · 0.85
xfdopenFunction · 0.85
strbuf_getline_lfFunction · 0.85
warningFunction · 0.85
finish_commandFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected