builtin/branch: convert 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 0c77cd24f87ef769aed77a73c752b358a04766e6
1 file changed +13 -13
builtin/branch.c
+13 -13
@@ -32,7 +32,7 @@ static const char * const builtin_branch_usage[] = {
32 };
33
34 static const char *head;
35 -static unsigned char head_sha1[20];
35 +static struct object_id head_oid;
36
37 static int branch_use_color = -1;
38 static char branch_colors[][COLOR_MAXLEN] = {
@@ -117,13 +117,13 @@ static int branch_merged(int kind, const char *name,
117 if (kind == FILTER_REFS_BRANCHES) {
118 struct branch *branch = branch_get(name);
119 const char *upstream = branch_get_upstream(branch, NULL);
120 - unsigned char sha1[20];
120 + struct object_id oid;
121
122 if (upstream &&
123 (reference_name = reference_name_to_free =
124 resolve_refdup(upstream, RESOLVE_REF_READING,
125 - sha1, NULL)) != NULL)
126 - reference_rev = lookup_commit_reference(sha1);
125 + oid.hash, NULL)) != NULL)
126 + reference_rev = lookup_commit_reference(oid.hash);
127 }
128 if (!reference_rev)
129 reference_rev = head_rev;
@@ -153,10 +153,10 @@ static int branch_merged(int kind, const char *name,
153 }
154
155 static int check_branch_commit(const char *branchname, const char *refname,
156 - const unsigned char *sha1, struct commit *head_rev,
156 + const struct object_id *oid, struct commit *head_rev,
157 int kinds, int force)
158 {
159 - struct commit *rev = lookup_commit_reference(sha1);
159 + struct commit *rev = lookup_commit_reference(oid->hash);
160 if (!rev) {
161 error(_("Couldn't look up commit object for '%s'"), refname);
162 return -1;
@@ -183,7 +183,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
183 int quiet)
184 {
185 struct commit *head_rev = NULL;
186 - unsigned char sha1[20];
186 + struct object_id oid;
187 char *name = NULL;
188 const char *fmt;
189 int i;
@@ -207,7 +207,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
207 }
208
209 if (!force) {
210 - head_rev = lookup_commit_reference(head_sha1);
210 + head_rev = lookup_commit_reference(head_oid.hash);
211 if (!head_rev)
212 die(_("Couldn't look up commit object for HEAD"));
213 }
@@ -235,7 +235,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
235 RESOLVE_REF_READING
236 | RESOLVE_REF_NO_RECURSE
237 | RESOLVE_REF_ALLOW_BAD_NAME,
238 - sha1, &flags);
238 + oid.hash, &flags);
239 if (!target) {
240 error(remote_branch
241 ? _("remote-tracking branch '%s' not found.")
@@ -245,13 +245,13 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
245 }
246
247 if (!(flags & (REF_ISSYMREF|REF_ISBROKEN)) &&
248 - check_branch_commit(bname.buf, name, sha1, head_rev, kinds,
248 + check_branch_commit(bname.buf, name, &oid, head_rev, kinds,
249 force)) {
250 ret = 1;
251 goto next;
252 }
253
254 - if (delete_ref(name, is_null_sha1(sha1) ? NULL : sha1,
254 + if (delete_ref(name, is_null_oid(&oid) ? NULL : oid.hash,
255 REF_NODEREF)) {
256 error(remote_branch
257 ? _("Error deleting remote-tracking branch '%s'")
@@ -267,7 +267,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
267 bname.buf,
268 (flags & REF_ISBROKEN) ? "broken"
269 : (flags & REF_ISSYMREF) ? target
270 - : find_unique_abbrev(sha1, DEFAULT_ABBREV));
270 + : find_unique_abbrev(oid.hash, DEFAULT_ABBREV));
271 }
272 delete_branch_config(bname.buf);
273
@@ -693,7 +693,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
693
694 track = git_branch_track;
695
696 - head = resolve_refdup("HEAD", 0, head_sha1, NULL);
696 + head = resolve_refdup("HEAD", 0, head_oid.hash, NULL);
697 if (!head)
698 die(_("Failed to resolve HEAD as a valid ref."));
699 if (!strcmp(head, "HEAD"))