builtin/blame: convert file to use struct object_id

Convert this file to use struct object_id, and additionally convert some uses of the constant 40 to GIT_SHA1_HEXSZ. 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 110d26fce8a9912d457c091faf14be9cbc22e3b8
1 file changed +14 -14
builtin/blame.c
+14 -14
@@ -1941,7 +1941,7 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
1941 cp = nth_line(sb, ent->lno);
1942 for (cnt = 0; cnt < ent->num_lines; cnt++) {
1943 char ch;
1944 - int length = (opt & OUTPUT_LONG_OBJECT_NAME) ? 40 : abbrev;
1944 + int length = (opt & OUTPUT_LONG_OBJECT_NAME) ? GIT_SHA1_HEXSZ : abbrev;
1945
1946 if (suspect->commit->object.flags & UNINTERESTING) {
1947 if (blank_boundary)
@@ -2232,12 +2232,12 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)
2232 int pos;
2233
2234 for (parents = work_tree->parents; parents; parents = parents->next) {
2235 - const unsigned char *commit_sha1 = parents->item->object.oid.hash;
2236 - unsigned char blob_sha1[20];
2235 + const struct object_id *commit_oid = &parents->item->object.oid;
2236 + struct object_id blob_oid;
2237 unsigned mode;
2238
2239 - if (!get_tree_entry(commit_sha1, path, blob_sha1, &mode) &&
2240 - sha1_object_info(blob_sha1, NULL) == OBJ_BLOB)
2239 + if (!get_tree_entry(commit_oid->hash, path, blob_oid.hash, &mode) &&
2240 + sha1_object_info(blob_oid.hash, NULL) == OBJ_BLOB)
2241 return;
2242 }
2243
@@ -2251,13 +2251,13 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)
2251 die("no such path '%s' in HEAD", path);
2252 }
2253
2254 -static struct commit_list **append_parent(struct commit_list **tail, const unsigned char *sha1)
2254 +static struct commit_list **append_parent(struct commit_list **tail, const struct object_id *oid)
2255 {
2256 struct commit *parent;
2257
2258 - parent = lookup_commit_reference(sha1);
2258 + parent = lookup_commit_reference(oid->hash);
2259 if (!parent)
2260 - die("no such commit %s", sha1_to_hex(sha1));
2260 + die("no such commit %s", oid_to_hex(oid));
2261 return &commit_list_insert(parent, tail)->next;
2262 }
2263
@@ -2274,10 +2274,10 @@ static void append_merge_parents(struct commit_list **tail)
2274 }
2275
2276 while (!strbuf_getwholeline_fd(&line, merge_head, '\n')) {
2277 - unsigned char sha1[20];
2278 - if (line.len < 40 || get_sha1_hex(line.buf, sha1))
2277 + struct object_id oid;
2278 + if (line.len < GIT_SHA1_HEXSZ || get_oid_hex(line.buf, &oid))
2279 die("unknown line in '%s': %s", git_path_merge_head(), line.buf);
2280 - tail = append_parent(tail, sha1);
2280 + tail = append_parent(tail, &oid);
2281 }
2282 close(merge_head);
2283 strbuf_release(&line);
@@ -2306,7 +2306,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
2306 struct commit *commit;
2307 struct origin *origin;
2308 struct commit_list **parent_tail, *parent;
2309 - unsigned char head_sha1[20];
2309 + struct object_id head_oid;
2310 struct strbuf buf = STRBUF_INIT;
2311 const char *ident;
2312 time_t now;
@@ -2322,10 +2322,10 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
2322 commit->date = now;
2323 parent_tail = &commit->parents;
2324
2325 - if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_sha1, NULL))
2325 + if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL))
2326 die("no such ref: HEAD");
2327
2328 - parent_tail = append_parent(parent_tail, head_sha1);
2328 + parent_tail = append_parent(parent_tail, &head_oid);
2329 append_merge_parents(parent_tail);
2330 verify_working_tree_path(commit, path);
2331