refs.c: add repo_dwim_ref()

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Apr 6, 2019 at 18:34 UTC d8984c532a18419cdbc69641f981a0a4f553729c
2 files changed +10 -3
refs.c
+9 -3
@@ -555,14 +555,20 @@ static char *substitute_branch_name(struct repository *r,
555 return NULL;
556 }
557
558 -int dwim_ref(const char *str, int len, struct object_id *oid, char **ref)
558 +int repo_dwim_ref(struct repository *r, const char *str, int len,
559 + struct object_id *oid, char **ref)
560 {
560 - char *last_branch = substitute_branch_name(the_repository, &str, &len);
561 - int refs_found = expand_ref(the_repository, str, len, oid, ref);
561 + char *last_branch = substitute_branch_name(r, &str, &len);
562 + int refs_found = expand_ref(r, str, len, oid, ref);
563 free(last_branch);
564 return refs_found;
565 }
566
567 +int dwim_ref(const char *str, int len, struct object_id *oid, char **ref)
568 +{
569 + return repo_dwim_ref(the_repository, str, len, oid, ref);
570 +}
571 +
572 int expand_ref(struct repository *repo, const char *str, int len,
573 struct object_id *oid, char **ref)
574 {
refs.h
+1
@@ -149,6 +149,7 @@ struct argv_array;
149 void expand_ref_prefix(struct argv_array *prefixes, const char *prefix);
150
151 int expand_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref);
152 +int repo_dwim_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref);
153 int dwim_ref(const char *str, int len, struct object_id *oid, char **ref);
154 int dwim_log(const char *str, int len, struct object_id *oid, char **ref);
155