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>
brian m. carlson committed
Sep 5, 2016 at 20:08 UTC
151b2911c1279f3ea4b5bcc069a04348aeb9d811
3 files changed
+11
-11
builtin/checkout.c
+1
-1
@@ -973,7 +973,7 @@ static int parse_branchname_arg(int argc, const char **argv,
973
if (!strcmp(arg, "-"))
974
arg = "@{-1}";
975
976
- if (get_sha1_mb(arg, rev->hash)) {
976
+ if (get_oid_mb(arg, rev)) {
977
/*
978
* Either case (3) or (4), with <something> not being
979
* a commit, or an attempt to use case (1) with an
cache.h
+1
-1
@@ -1204,7 +1204,7 @@ extern char *sha1_to_hex(const unsigned char *sha1); /* static buffer result! */
1204
extern char *oid_to_hex(const struct object_id *oid); /* same static buffer as sha1_to_hex */
1205
1206
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);
1208
1209
extern int validate_headref(const char *ref);
1210
sha1_name.c
+9
-9
@@ -995,35 +995,35 @@ static int interpret_nth_prior_checkout(const char *name, int namelen,
995
return retval;
996
}
997
998
-int get_sha1_mb(const char *name, unsigned char *sha1)
998
+int get_oid_mb(const char *name, struct object_id *oid)
999
{
1000
struct commit *one, *two;
1001
struct commit_list *mbs;
1002
- unsigned char sha1_tmp[20];
1002
+ struct object_id oid_tmp;
1003
const char *dots;
1004
int st;
1005
1006
dots = strstr(name, "...");
1007
if (!dots)
1008
- return get_sha1(name, sha1);
1008
+ return get_oid(name, oid);
1009
if (dots == name)
1010
- st = get_sha1("HEAD", sha1_tmp);
1010
+ st = get_oid("HEAD", &oid_tmp);
1011
else {
1012
struct strbuf sb;
1013
strbuf_init(&sb, dots - name);
1014
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);
1016
strbuf_release(&sb);
1017
}
1018
if (st)
1019
return st;
1020
- one = lookup_commit_reference_gently(sha1_tmp, 0);
1020
+ one = lookup_commit_reference_gently(oid_tmp.hash, 0);
1021
if (!one)
1022
return -1;
1023
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))
1025
return -1;
1026
- two = lookup_commit_reference_gently(sha1_tmp, 0);
1026
+ two = lookup_commit_reference_gently(oid_tmp.hash, 0);
1027
if (!two)
1028
return -1;
1029
mbs = get_merge_bases(one, two);
@@ -1031,7 +1031,7 @@ int get_sha1_mb(const char *name, unsigned char *sha1)
1031
st = -1;
1032
else {
1033
st = 0;
1034
- hashcpy(sha1, mbs->item->object.oid.hash);
1034
+ oidcpy(oid, &mbs->item->object.oid);
1035
}
1036
free_commit_list(mbs);
1037
return st;