From d8984c532a18419cdbc69641f981a0a4f553729c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 6 Apr 2019 18:34:28 +0700 Subject: [PATCH] refs.c: add repo_dwim_ref() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- refs.c | 12 +++++++++--- refs.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/refs.c b/refs.c index 1f5864aa36..bd0fec5776 100644 --- a/refs.c +++ b/refs.c @@ -555,14 +555,20 @@ static char *substitute_branch_name(struct repository *r, return NULL; } -int dwim_ref(const char *str, int len, struct object_id *oid, char **ref) +int repo_dwim_ref(struct repository *r, const char *str, int len, + struct object_id *oid, char **ref) { - char *last_branch = substitute_branch_name(the_repository, &str, &len); - int refs_found = expand_ref(the_repository, str, len, oid, ref); + char *last_branch = substitute_branch_name(r, &str, &len); + int refs_found = expand_ref(r, str, len, oid, ref); free(last_branch); return refs_found; } +int dwim_ref(const char *str, int len, struct object_id *oid, char **ref) +{ + return repo_dwim_ref(the_repository, str, len, oid, ref); +} + int expand_ref(struct repository *repo, const char *str, int len, struct object_id *oid, char **ref) { diff --git a/refs.h b/refs.h index b630d5bde7..fd3dc1d0f4 100644 --- a/refs.h +++ b/refs.h @@ -149,6 +149,7 @@ struct argv_array; void expand_ref_prefix(struct argv_array *prefixes, const char *prefix); int expand_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref); +int repo_dwim_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref); int dwim_ref(const char *str, int len, struct object_id *oid, char **ref); int dwim_log(const char *str, int len, struct object_id *oid, char **ref);