refs.c: remove the_repo from expand_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 0b1dbf53dfeed20bd9bc34631e04c5db37ee6121
3 files changed +8 -6
refs.c
+6 -4
@@ -558,12 +558,13 @@ static char *substitute_branch_name(struct repository *r,
558 int dwim_ref(const char *str, int len, struct object_id *oid, char **ref)
559 {
560 char *last_branch = substitute_branch_name(the_repository, &str, &len);
561 - int refs_found = expand_ref(str, len, oid, ref);
561 + int refs_found = expand_ref(the_repository, str, len, oid, ref);
562 free(last_branch);
563 return refs_found;
564 }
565
566 -int expand_ref(const char *str, int len, struct object_id *oid, char **ref)
566 +int expand_ref(struct repository *repo, const char *str, int len,
567 + struct object_id *oid, char **ref)
568 {
569 const char **p, *r;
570 int refs_found = 0;
@@ -578,8 +579,9 @@ int expand_ref(const char *str, int len, struct object_id *oid, char **ref)
579 this_result = refs_found ? &oid_from_ref : oid;
580 strbuf_reset(&fullref);
581 strbuf_addf(&fullref, *p, len, str);
581 - r = resolve_ref_unsafe(fullref.buf, RESOLVE_REF_READING,
582 - this_result, &flag);
582 + r = refs_resolve_ref_unsafe(get_main_ref_store(repo),
583 + fullref.buf, RESOLVE_REF_READING,
584 + this_result, &flag);
585 if (r) {
586 if (!refs_found++)
587 *ref = xstrdup(r);
refs.h
+1 -1
@@ -148,7 +148,7 @@ int refname_match(const char *abbrev_name, const char *full_name);
148 struct argv_array;
149 void expand_ref_prefix(struct argv_array *prefixes, const char *prefix);
150
151 -int expand_ref(const char *str, int len, struct object_id *oid, char **ref);
151 +int expand_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref);
152 int dwim_ref(const char *str, int len, struct object_id *oid, char **ref);
153 int dwim_log(const char *str, int len, struct object_id *oid, char **ref);
154
upload-pack.c
+1 -1
@@ -834,7 +834,7 @@ static int process_deepen_not(const char *line, struct string_list *deepen_not,
834 if (skip_prefix(line, "deepen-not ", &arg)) {
835 char *ref = NULL;
836 struct object_id oid;
837 - if (expand_ref(arg, strlen(arg), &oid, &ref) != 1)
837 + if (expand_ref(the_repository, arg, strlen(arg), &oid, &ref) != 1)
838 die("git upload-pack: ambiguous deepen-not: %s", line);
839 string_list_append(deepen_not, ref);
840 free(ref);