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>

Nguyễn Thái Ngọc Duy committed Apr 16, 2019 at 16:33 UTC 0daf7ff6c0f877e4b518893b51d44e024fc88fb3
2 files changed +13 -8
cache.h
+2 -1
@@ -1386,6 +1386,7 @@ int repo_get_oid_committish(struct repository *r, const char *str, struct object
1386 int repo_get_oid_tree(struct repository *r, const char *str, struct object_id *oid);
1387 int repo_get_oid_treeish(struct repository *r, const char *str, struct object_id *oid);
1388 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);
1390 void maybe_die_on_misspelt_object_name(struct repository *repo,
1391 const char *name,
1392 const char *prefix);
@@ -1399,6 +1400,7 @@ extern enum get_oid_result get_oid_with_context(struct repository *repo, const c
1400 #define get_oid_tree(str, oid) repo_get_oid_tree(the_repository, str, oid)
1401 #define get_oid_treeish(str, oid) repo_get_oid_treeish(the_repository, str, oid)
1402 #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)
1404
1405 typedef int each_abbrev_fn(const struct object_id *oid, void *);
1406 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,
1488 unsigned allowed);
1489 #define interpret_branch_name(str, len, buf, allowed) \
1490 repo_interpret_branch_name(the_repository, str, len, buf, allowed)
1489 -extern int get_oid_mb(const char *str, struct object_id *oid);
1491
1492 extern int validate_headref(const char *ref);
1493
sha1-name.c
+11 -7
@@ -1338,7 +1338,9 @@ static int interpret_nth_prior_checkout(struct repository *r,
1338 return retval;
1339 }
1340
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)
1344 {
1345 struct commit *one, *two;
1346 struct commit_list *mbs;
@@ -1348,27 +1350,29 @@ int get_oid_mb(const char *name, struct object_id *oid)
1350
1351 dots = strstr(name, "...");
1352 if (!dots)
1351 - return get_oid(name, oid);
1353 + return repo_get_oid(r, name, oid);
1354 if (dots == name)
1353 - st = get_oid("HEAD", &oid_tmp);
1355 + st = repo_get_oid(r, "HEAD", &oid_tmp);
1356 else {
1357 struct strbuf sb;
1358 strbuf_init(&sb, dots - name);
1359 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);
1361 strbuf_release(&sb);
1362 }
1363 if (st)
1364 return st;
1363 - one = lookup_commit_reference_gently(the_repository, &oid_tmp, 0);
1365 + one = lookup_commit_reference_gently(r, &oid_tmp, 0);
1366 if (!one)
1367 return -1;
1368
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))
1370 return -1;
1369 - two = lookup_commit_reference_gently(the_repository, &oid_tmp, 0);
1371 + two = lookup_commit_reference_gently(r, &oid_tmp, 0);
1372 if (!two)
1373 return -1;
1374 + if (r != the_repository)
1375 + BUG("sorry get_merge_bases() can't take struct repository yet");
1376 mbs = get_merge_bases(one, two);
1377 if (!mbs || mbs->next)
1378 st = -1;