builtin/merge-base: convert to struct object_id

Convert the remaining uses of unsigned char [20] to struct object_id. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Feb 21, 2017 at 23:47 UTC d0ae910af44cc3e8998e4c521784ae84198d945a
1 file changed +14 -14
builtin/merge-base.c
+14 -14
@@ -36,12 +36,12 @@ static const char * const merge_base_usage[] = {
36
37 static struct commit *get_commit_reference(const char *arg)
38 {
39 - unsigned char revkey[20];
39 + struct object_id revkey;
40 struct commit *r;
41
42 - if (get_sha1(arg, revkey))
42 + if (get_oid(arg, &revkey))
43 die("Not a valid object name %s", arg);
44 - r = lookup_commit_reference(revkey);
44 + r = lookup_commit_reference(revkey.hash);
45 if (!r)
46 die("Not a valid commit name %s", arg);
47
@@ -113,14 +113,14 @@ struct rev_collect {
113 unsigned int initial : 1;
114 };
115
116 -static void add_one_commit(unsigned char *sha1, struct rev_collect *revs)
116 +static void add_one_commit(struct object_id *oid, struct rev_collect *revs)
117 {
118 struct commit *commit;
119
120 - if (is_null_sha1(sha1))
120 + if (is_null_oid(oid))
121 return;
122
123 - commit = lookup_commit(sha1);
123 + commit = lookup_commit(oid->hash);
124 if (!commit ||
125 (commit->object.flags & TMP_MARK) ||
126 parse_commit(commit))
@@ -139,15 +139,15 @@ static int collect_one_reflog_ent(struct object_id *ooid, struct object_id *noid
139
140 if (revs->initial) {
141 revs->initial = 0;
142 - add_one_commit(ooid->hash, revs);
142 + add_one_commit(ooid, revs);
143 }
144 - add_one_commit(noid->hash, revs);
144 + add_one_commit(noid, revs);
145 return 0;
146 }
147
148 static int handle_fork_point(int argc, const char **argv)
149 {
150 - unsigned char sha1[20];
150 + struct object_id oid;
151 char *refname;
152 const char *commitname;
153 struct rev_collect revs;
@@ -155,7 +155,7 @@ static int handle_fork_point(int argc, const char **argv)
155 struct commit_list *bases;
156 int i, ret = 0;
157
158 - switch (dwim_ref(argv[0], strlen(argv[0]), sha1, &refname)) {
158 + switch (dwim_ref(argv[0], strlen(argv[0]), oid.hash, &refname)) {
159 case 0:
160 die("No such ref: '%s'", argv[0]);
161 case 1:
@@ -165,16 +165,16 @@ static int handle_fork_point(int argc, const char **argv)
165 }
166
167 commitname = (argc == 2) ? argv[1] : "HEAD";
168 - if (get_sha1(commitname, sha1))
168 + if (get_oid(commitname, &oid))
169 die("Not a valid object name: '%s'", commitname);
170
171 - derived = lookup_commit_reference(sha1);
171 + derived = lookup_commit_reference(oid.hash);
172 memset(&revs, 0, sizeof(revs));
173 revs.initial = 1;
174 for_each_reflog_ent(refname, collect_one_reflog_ent, &revs);
175
176 - if (!revs.nr && !get_sha1(refname, sha1))
177 - add_one_commit(sha1, &revs);
176 + if (!revs.nr && !get_oid(refname, &oid))
177 + add_one_commit(&oid, &revs);
178
179 for (i = 0; i < revs.nr; i++)
180 revs.commit[i]->object.flags &= ~TMP_MARK;