diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2019-04-06 18:34:29 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-04-08 17:26:33 +0900 |
commit | 567009033f7ef4619c890f0e07d7e0b67136e1b1 (patch) | |
tree | b649c8f7ce9993c7faf2d6504390d6a27710ac89 /refs.c | |
parent | d8984c532a18419cdbc69641f981a0a4f553729c (diff) | |
download | git-567009033f7ef4619c890f0e07d7e0b67136e1b1.tar.gz |
refs.c: add repo_dwim_log()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r-- | refs.c | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -603,9 +603,11 @@ int expand_ref(struct repository *repo, const char *str, int len, return refs_found; } -int dwim_log(const char *str, int len, struct object_id *oid, char **log) +int repo_dwim_log(struct repository *r, const char *str, int len, + struct object_id *oid, char **log) { - char *last_branch = substitute_branch_name(the_repository, &str, &len); + struct ref_store *refs = get_main_ref_store(r); + char *last_branch = substitute_branch_name(r, &str, &len); const char **p; int logs_found = 0; struct strbuf path = STRBUF_INIT; @@ -617,13 +619,15 @@ int dwim_log(const char *str, int len, struct object_id *oid, char **log) strbuf_reset(&path); strbuf_addf(&path, *p, len, str); - ref = resolve_ref_unsafe(path.buf, RESOLVE_REF_READING, - &hash, NULL); + ref = refs_resolve_ref_unsafe(refs, path.buf, + RESOLVE_REF_READING, + &hash, NULL); if (!ref) continue; - if (reflog_exists(path.buf)) + if (refs_reflog_exists(refs, path.buf)) it = path.buf; - else if (strcmp(ref, path.buf) && reflog_exists(ref)) + else if (strcmp(ref, path.buf) && + refs_reflog_exists(refs, ref)) it = ref; else continue; @@ -639,6 +643,11 @@ int dwim_log(const char *str, int len, struct object_id *oid, char **log) return logs_found; } +int dwim_log(const char *str, int len, struct object_id *oid, char **log) +{ + return repo_dwim_log(the_repository, str, len, oid, log); +} + static int is_per_worktree_ref(const char *refname) { return !strcmp(refname, "HEAD") || |