Skip to content

Commit 0daf7ff

Browse files
pcloudsgitster
authored andcommitted
sha1-name.c: remove the_repo from get_oid_mb()
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 65e5046 commit 0daf7ff

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

cache.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,7 @@ int repo_get_oid_committish(struct repository *r, const char *str, struct object
13861386
int repo_get_oid_tree(struct repository *r, const char *str, struct object_id *oid);
13871387
int repo_get_oid_treeish(struct repository *r, const char *str, struct object_id *oid);
13881388
int repo_get_oid_blob(struct repository *r, const char *str, struct object_id *oid);
1389+
int repo_get_oid_mb(struct repository *r, const char *str, struct object_id *oid);
13891390
void maybe_die_on_misspelt_object_name(struct repository *repo,
13901391
const char *name,
13911392
const char *prefix);
@@ -1399,6 +1400,7 @@ extern enum get_oid_result get_oid_with_context(struct repository *repo, const c
13991400
#define get_oid_tree(str, oid) repo_get_oid_tree(the_repository, str, oid)
14001401
#define get_oid_treeish(str, oid) repo_get_oid_treeish(the_repository, str, oid)
14011402
#define get_oid_blob(str, oid) repo_get_oid_blob(the_repository, str, oid)
1403+
#define get_oid_mb(str, oid) repo_get_oid_mb(the_repository, str, oid)
14021404

14031405
typedef int each_abbrev_fn(const struct object_id *oid, void *);
14041406
int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
@@ -1486,7 +1488,6 @@ int repo_interpret_branch_name(struct repository *r,
14861488
unsigned allowed);
14871489
#define interpret_branch_name(str, len, buf, allowed) \
14881490
repo_interpret_branch_name(the_repository, str, len, buf, allowed)
1489-
extern int get_oid_mb(const char *str, struct object_id *oid);
14901491

14911492
extern int validate_headref(const char *ref);
14921493

sha1-name.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,9 @@ static int interpret_nth_prior_checkout(struct repository *r,
13381338
return retval;
13391339
}
13401340

1341-
int get_oid_mb(const char *name, struct object_id *oid)
1341+
int repo_get_oid_mb(struct repository *r,
1342+
const char *name,
1343+
struct object_id *oid)
13421344
{
13431345
struct commit *one, *two;
13441346
struct commit_list *mbs;
@@ -1348,27 +1350,29 @@ int get_oid_mb(const char *name, struct object_id *oid)
13481350

13491351
dots = strstr(name, "...");
13501352
if (!dots)
1351-
return get_oid(name, oid);
1353+
return repo_get_oid(r, name, oid);
13521354
if (dots == name)
1353-
st = get_oid("HEAD", &oid_tmp);
1355+
st = repo_get_oid(r, "HEAD", &oid_tmp);
13541356
else {
13551357
struct strbuf sb;
13561358
strbuf_init(&sb, dots - name);
13571359
strbuf_add(&sb, name, dots - name);
1358-
st = get_oid_committish(sb.buf, &oid_tmp);
1360+
st = repo_get_oid_committish(r, sb.buf, &oid_tmp);
13591361
strbuf_release(&sb);
13601362
}
13611363
if (st)
13621364
return st;
1363-
one = lookup_commit_reference_gently(the_repository, &oid_tmp, 0);
1365+
one = lookup_commit_reference_gently(r, &oid_tmp, 0);
13641366
if (!one)
13651367
return -1;
13661368

1367-
if (get_oid_committish(dots[3] ? (dots + 3) : "HEAD", &oid_tmp))
1369+
if (repo_get_oid_committish(r, dots[3] ? (dots + 3) : "HEAD", &oid_tmp))
13681370
return -1;
1369-
two = lookup_commit_reference_gently(the_repository, &oid_tmp, 0);
1371+
two = lookup_commit_reference_gently(r, &oid_tmp, 0);
13701372
if (!two)
13711373
return -1;
1374+
if (r != the_repository)
1375+
BUG("sorry get_merge_bases() can't take struct repository yet");
13721376
mbs = get_merge_bases(one, two);
13731377
if (!mbs || mbs->next)
13741378
st = -1;

0 commit comments

Comments
 (0)