MCPcopy Index your code
hub / github.com/git/git / fetch_symref

Function fetch_symref

http-push.c:1562–1590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1560}
1561
1562static void fetch_symref(const char *path, char **symref, struct object_id *oid)
1563{
1564 char *url = xstrfmt("%s%s", repo->url, path);
1565 struct strbuf buffer = STRBUF_INIT;
1566 const char *name;
1567
1568 if (http_get_strbuf(url, &buffer, NULL) != HTTP_OK)
1569 die("Couldn't get %s for remote symref\n%s", url,
1570 curl_errorstr);
1571 free(url);
1572
1573 FREE_AND_NULL(*symref);
1574 oidclr(oid, the_repository->hash_algo);
1575
1576 if (buffer.len == 0)
1577 return;
1578
1579 /* Cut off trailing newline. */
1580 strbuf_rtrim(&buffer);
1581
1582 /* If it's a symref, set the refname; otherwise try for a sha1 */
1583 if (skip_prefix(buffer.buf, "ref: ", &name)) {
1584 *symref = xmemdupz(name, buffer.len - (name - buffer.buf));
1585 } else {
1586 get_oid_hex(buffer.buf, oid);
1587 }
1588
1589 strbuf_release(&buffer);
1590}
1591
1592static int verify_merge_base(struct object_id *head_oid, struct ref *remote)
1593{

Callers 1

delete_remote_branchFunction · 0.85

Calls 8

xstrfmtFunction · 0.85
http_get_strbufFunction · 0.85
oidclrFunction · 0.85
strbuf_rtrimFunction · 0.85
xmemdupzFunction · 0.85
get_oid_hexFunction · 0.85
strbuf_releaseFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected