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

Function send_ref

ls-refs.c:78–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76};
77
78static int send_ref(const struct reference *ref, void *cb_data)
79{
80 struct ls_refs_data *data = cb_data;
81 const char *refname_nons = strip_namespace(ref->name);
82
83 strbuf_reset(&data->buf);
84
85 if (ref_is_hidden(refname_nons, ref->name, &data->hidden_refs))
86 return 0;
87
88 if (!ref_match(&data->prefixes, refname_nons))
89 return 0;
90
91 if (ref->oid)
92 strbuf_addf(&data->buf, "%s %s", oid_to_hex(ref->oid), refname_nons);
93 else
94 strbuf_addf(&data->buf, "unborn %s", refname_nons);
95 if (data->symrefs && ref->flags & REF_ISSYMREF) {
96 int unused_flag;
97 struct object_id unused;
98 const char *symref_target = refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
99 ref->name,
100 0,
101 &unused,
102 &unused_flag);
103
104 if (!symref_target)
105 die("'%s' is a symref but it is not?", ref->name);
106
107 strbuf_addf(&data->buf, " symref-target:%s",
108 strip_namespace(symref_target));
109 }
110
111 if (data->peel && ref->oid) {
112 struct object_id peeled;
113 if (!reference_get_peeled_oid(the_repository, ref, &peeled))
114 strbuf_addf(&data->buf, " peeled:%s", oid_to_hex(&peeled));
115 }
116
117 strbuf_addch(&data->buf, '\n');
118 packet_fwrite(stdout, data->buf.buf, data->buf.len);
119
120 return 0;
121}
122
123static void send_possibly_unborn_head(struct ls_refs_data *data)
124{

Callers 1

Calls 11

strip_namespaceFunction · 0.85
ref_is_hiddenFunction · 0.85
ref_matchFunction · 0.85
strbuf_addfFunction · 0.85
oid_to_hexFunction · 0.85
refs_resolve_ref_unsafeFunction · 0.85
get_main_ref_storeFunction · 0.85
reference_get_peeled_oidFunction · 0.85
strbuf_addchFunction · 0.85
packet_fwriteFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected