sha1-name.c: remove the_repo from get_oid_mb()

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Nguyễn Thái Ngọc Duy
2019-04-16 16:33:41 +07:00
committed by Junio C Hamano
parent 65e5046400
commit 0daf7ff6c0
2 changed files with 13 additions and 8 deletions

View File

@ -1338,7 +1338,9 @@ static int interpret_nth_prior_checkout(struct repository *r,
return retval;
}
int get_oid_mb(const char *name, struct object_id *oid)
int repo_get_oid_mb(struct repository *r,
const char *name,
struct object_id *oid)
{
struct commit *one, *two;
struct commit_list *mbs;
@ -1348,27 +1350,29 @@ int get_oid_mb(const char *name, struct object_id *oid)
dots = strstr(name, "...");
if (!dots)
return get_oid(name, oid);
return repo_get_oid(r, name, oid);
if (dots == name)
st = get_oid("HEAD", &oid_tmp);
st = repo_get_oid(r, "HEAD", &oid_tmp);
else {
struct strbuf sb;
strbuf_init(&sb, dots - name);
strbuf_add(&sb, name, dots - name);
st = get_oid_committish(sb.buf, &oid_tmp);
st = repo_get_oid_committish(r, sb.buf, &oid_tmp);
strbuf_release(&sb);
}
if (st)
return st;
one = lookup_commit_reference_gently(the_repository, &oid_tmp, 0);
one = lookup_commit_reference_gently(r, &oid_tmp, 0);
if (!one)
return -1;
if (get_oid_committish(dots[3] ? (dots + 3) : "HEAD", &oid_tmp))
if (repo_get_oid_committish(r, dots[3] ? (dots + 3) : "HEAD", &oid_tmp))
return -1;
two = lookup_commit_reference_gently(the_repository, &oid_tmp, 0);
two = lookup_commit_reference_gently(r, &oid_tmp, 0);
if (!two)
return -1;
if (r != the_repository)
BUG("sorry get_merge_bases() can't take struct repository yet");
mbs = get_merge_bases(one, two);
if (!mbs || mbs->next)
st = -1;