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

Function guess_ref

remote.c:1140–1161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1138}
1139
1140static char *guess_ref(const char *name, struct ref *peer)
1141{
1142 struct strbuf buf = STRBUF_INIT;
1143
1144 const char *r = refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
1145 peer->name,
1146 RESOLVE_REF_READING,
1147 NULL, NULL);
1148 if (!r)
1149 return NULL;
1150
1151 if (starts_with(r, "refs/heads/")) {
1152 strbuf_addstr(&buf, "refs/heads/");
1153 } else if (starts_with(r, "refs/tags/")) {
1154 strbuf_addstr(&buf, "refs/tags/");
1155 } else {
1156 return NULL;
1157 }
1158
1159 strbuf_addstr(&buf, name);
1160 return strbuf_detach(&buf, NULL);
1161}
1162
1163static int match_explicit_lhs(struct ref *src,
1164 struct refspec_item *rs,

Callers 1

match_explicitFunction · 0.85

Calls 5

refs_resolve_ref_unsafeFunction · 0.85
get_main_ref_storeFunction · 0.85
starts_withFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_detachFunction · 0.85

Tested by

no test coverage detected