| 803 | } |
| 804 | |
| 805 | int 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 | |
| 840 | int repo_dwim_log(struct repository *r, const char *str, int len, |
| 841 | struct object_id *oid, char **log) |
no test coverage detected