Skip to content

Commit 151b291

Browse files
bk2204gitster
authored andcommitted
sha1_name: convert get_sha1_mb to struct object_id
All of the callers of this function use struct object_id, so rename it to get_oid_mb and make it take struct object_id instead of unsigned char *. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 71445a0 commit 151b291

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

builtin/checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ static int parse_branchname_arg(int argc, const char **argv,
973973
if (!strcmp(arg, "-"))
974974
arg = "@{-1}";
975975

976-
if (get_sha1_mb(arg, rev->hash)) {
976+
if (get_oid_mb(arg, rev)) {
977977
/*
978978
* Either case (3) or (4), with <something> not being
979979
* a commit, or an attempt to use case (1) with an

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ extern char *sha1_to_hex(const unsigned char *sha1); /* static buffer result! */
12041204
extern char *oid_to_hex(const struct object_id *oid); /* same static buffer as sha1_to_hex */
12051205

12061206
extern int interpret_branch_name(const char *str, int len, struct strbuf *);
1207-
extern int get_sha1_mb(const char *str, unsigned char *sha1);
1207+
extern int get_oid_mb(const char *str, struct object_id *oid);
12081208

12091209
extern int validate_headref(const char *ref);
12101210

sha1_name.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -995,43 +995,43 @@ static int interpret_nth_prior_checkout(const char *name, int namelen,
995995
return retval;
996996
}
997997

998-
int get_sha1_mb(const char *name, unsigned char *sha1)
998+
int get_oid_mb(const char *name, struct object_id *oid)
999999
{
10001000
struct commit *one, *two;
10011001
struct commit_list *mbs;
1002-
unsigned char sha1_tmp[20];
1002+
struct object_id oid_tmp;
10031003
const char *dots;
10041004
int st;
10051005

10061006
dots = strstr(name, "...");
10071007
if (!dots)
1008-
return get_sha1(name, sha1);
1008+
return get_oid(name, oid);
10091009
if (dots == name)
1010-
st = get_sha1("HEAD", sha1_tmp);
1010+
st = get_oid("HEAD", &oid_tmp);
10111011
else {
10121012
struct strbuf sb;
10131013
strbuf_init(&sb, dots - name);
10141014
strbuf_add(&sb, name, dots - name);
1015-
st = get_sha1_committish(sb.buf, sha1_tmp);
1015+
st = get_sha1_committish(sb.buf, oid_tmp.hash);
10161016
strbuf_release(&sb);
10171017
}
10181018
if (st)
10191019
return st;
1020-
one = lookup_commit_reference_gently(sha1_tmp, 0);
1020+
one = lookup_commit_reference_gently(oid_tmp.hash, 0);
10211021
if (!one)
10221022
return -1;
10231023

1024-
if (get_sha1_committish(dots[3] ? (dots + 3) : "HEAD", sha1_tmp))
1024+
if (get_sha1_committish(dots[3] ? (dots + 3) : "HEAD", oid_tmp.hash))
10251025
return -1;
1026-
two = lookup_commit_reference_gently(sha1_tmp, 0);
1026+
two = lookup_commit_reference_gently(oid_tmp.hash, 0);
10271027
if (!two)
10281028
return -1;
10291029
mbs = get_merge_bases(one, two);
10301030
if (!mbs || mbs->next)
10311031
st = -1;
10321032
else {
10331033
st = 0;
1034-
hashcpy(sha1, mbs->item->object.oid.hash);
1034+
oidcpy(oid, &mbs->item->object.oid);
10351035
}
10361036
free_commit_list(mbs);
10371037
return st;

0 commit comments

Comments
 (0)