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

Function expand_ref

refs.c:805–838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

803}
804
805int expand_ref(struct repository *repo, const char *str, int len,
806 struct object_id *oid, char **ref)
807{
808 const char **p, *r;
809 int refs_found = 0;
810 struct strbuf fullref = STRBUF_INIT;
811
812 *ref = NULL;
813 for (p = ref_rev_parse_rules; *p; p++) {
814 struct object_id oid_from_ref;
815 struct object_id *this_result;
816 int flag;
817 struct ref_store *refs = get_main_ref_store(repo);
818
819 this_result = refs_found ? &oid_from_ref : oid;
820 strbuf_reset(&fullref);
821 strbuf_addf(&fullref, *p, len, str);
822 r = refs_resolve_ref_unsafe(refs, fullref.buf,
823 RESOLVE_REF_READING,
824 this_result, &flag);
825 if (r) {
826 if (!refs_found++)
827 *ref = xstrdup(r);
828 if (!repo_settings_get_warn_ambiguous_refs(repo))
829 break;
830 } else if ((flag & REF_ISSYMREF) && strcmp(fullref.buf, "HEAD")) {
831 warning(_("ignoring dangling symref %s"), fullref.buf);
832 } else if ((flag & REF_ISBROKEN) && strchr(fullref.buf, '/')) {
833 warning(_("ignoring broken ref %s"), fullref.buf);
834 }
835 }
836 strbuf_release(&fullref);
837 return refs_found;
838}
839
840int repo_dwim_log(struct repository *r, const char *str, int len,
841 struct object_id *oid, char **log)

Callers 2

process_deepen_notFunction · 0.85
repo_dwim_refFunction · 0.85

Calls 7

get_main_ref_storeFunction · 0.85
strbuf_addfFunction · 0.85
refs_resolve_ref_unsafeFunction · 0.85
xstrdupFunction · 0.85
warningFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected