mirror of
https://github.com/git/git
synced 2024-07-07 19:39:27 +00:00
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:
parent
65e5046400
commit
0daf7ff6c0
3
cache.h
3
cache.h
|
@ -1386,6 +1386,7 @@ int repo_get_oid_committish(struct repository *r, const char *str, struct object
|
||||||
int repo_get_oid_tree(struct repository *r, const char *str, struct object_id *oid);
|
int repo_get_oid_tree(struct repository *r, const char *str, struct object_id *oid);
|
||||||
int repo_get_oid_treeish(struct repository *r, const char *str, struct object_id *oid);
|
int repo_get_oid_treeish(struct repository *r, const char *str, struct object_id *oid);
|
||||||
int repo_get_oid_blob(struct repository *r, const char *str, struct object_id *oid);
|
int repo_get_oid_blob(struct repository *r, const char *str, struct object_id *oid);
|
||||||
|
int repo_get_oid_mb(struct repository *r, const char *str, struct object_id *oid);
|
||||||
void maybe_die_on_misspelt_object_name(struct repository *repo,
|
void maybe_die_on_misspelt_object_name(struct repository *repo,
|
||||||
const char *name,
|
const char *name,
|
||||||
const char *prefix);
|
const char *prefix);
|
||||||
|
@ -1399,6 +1400,7 @@ extern enum get_oid_result get_oid_with_context(struct repository *repo, const c
|
||||||
#define get_oid_tree(str, oid) repo_get_oid_tree(the_repository, str, oid)
|
#define get_oid_tree(str, oid) repo_get_oid_tree(the_repository, str, oid)
|
||||||
#define get_oid_treeish(str, oid) repo_get_oid_treeish(the_repository, str, oid)
|
#define get_oid_treeish(str, oid) repo_get_oid_treeish(the_repository, str, oid)
|
||||||
#define get_oid_blob(str, oid) repo_get_oid_blob(the_repository, str, oid)
|
#define get_oid_blob(str, oid) repo_get_oid_blob(the_repository, str, oid)
|
||||||
|
#define get_oid_mb(str, oid) repo_get_oid_mb(the_repository, str, oid)
|
||||||
|
|
||||||
typedef int each_abbrev_fn(const struct object_id *oid, void *);
|
typedef int each_abbrev_fn(const struct object_id *oid, void *);
|
||||||
int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
|
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,
|
||||||
unsigned allowed);
|
unsigned allowed);
|
||||||
#define interpret_branch_name(str, len, buf, allowed) \
|
#define interpret_branch_name(str, len, buf, allowed) \
|
||||||
repo_interpret_branch_name(the_repository, str, len, buf, allowed)
|
repo_interpret_branch_name(the_repository, str, len, buf, allowed)
|
||||||
extern int get_oid_mb(const char *str, struct object_id *oid);
|
|
||||||
|
|
||||||
extern int validate_headref(const char *ref);
|
extern int validate_headref(const char *ref);
|
||||||
|
|
||||||
|
|
18
sha1-name.c
18
sha1-name.c
|
@ -1338,7 +1338,9 @@ static int interpret_nth_prior_checkout(struct repository *r,
|
||||||
return retval;
|
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 *one, *two;
|
||||||
struct commit_list *mbs;
|
struct commit_list *mbs;
|
||||||
|
@ -1348,27 +1350,29 @@ int get_oid_mb(const char *name, struct object_id *oid)
|
||||||
|
|
||||||
dots = strstr(name, "...");
|
dots = strstr(name, "...");
|
||||||
if (!dots)
|
if (!dots)
|
||||||
return get_oid(name, oid);
|
return repo_get_oid(r, name, oid);
|
||||||
if (dots == name)
|
if (dots == name)
|
||||||
st = get_oid("HEAD", &oid_tmp);
|
st = repo_get_oid(r, "HEAD", &oid_tmp);
|
||||||
else {
|
else {
|
||||||
struct strbuf sb;
|
struct strbuf sb;
|
||||||
strbuf_init(&sb, dots - name);
|
strbuf_init(&sb, dots - name);
|
||||||
strbuf_add(&sb, name, 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);
|
strbuf_release(&sb);
|
||||||
}
|
}
|
||||||
if (st)
|
if (st)
|
||||||
return st;
|
return st;
|
||||||
one = lookup_commit_reference_gently(the_repository, &oid_tmp, 0);
|
one = lookup_commit_reference_gently(r, &oid_tmp, 0);
|
||||||
if (!one)
|
if (!one)
|
||||||
return -1;
|
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;
|
return -1;
|
||||||
two = lookup_commit_reference_gently(the_repository, &oid_tmp, 0);
|
two = lookup_commit_reference_gently(r, &oid_tmp, 0);
|
||||||
if (!two)
|
if (!two)
|
||||||
return -1;
|
return -1;
|
||||||
|
if (r != the_repository)
|
||||||
|
BUG("sorry get_merge_bases() can't take struct repository yet");
|
||||||
mbs = get_merge_bases(one, two);
|
mbs = get_merge_bases(one, two);
|
||||||
if (!mbs || mbs->next)
|
if (!mbs || mbs->next)
|
||||||
st = -1;
|
st = -1;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user