notes-utils: convert internals to struct object_id

Convert the internals of create_notes_comit and commit_notes to use 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 May 6, 2017 at 22:10 UTC 18b74e513d70830d4b30d0ef19ac225e1e081c73
1 file changed +9 -9
notes-utils.c
+9 -9
@@ -7,18 +7,18 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,
7 const char *msg, size_t msg_len,
8 unsigned char *result_sha1)
9 {
10 - unsigned char tree_sha1[20];
10 + struct object_id tree_oid;
11
12 assert(t->initialized);
13
14 - if (write_notes_tree(t, tree_sha1))
14 + if (write_notes_tree(t, tree_oid.hash))
15 die("Failed to write notes tree to database");
16
17 if (!parents) {
18 /* Deduce parent commit from t->ref */
19 - unsigned char parent_sha1[20];
20 - if (!read_ref(t->ref, parent_sha1)) {
21 - struct commit *parent = lookup_commit(parent_sha1);
19 + struct object_id parent_oid;
20 + if (!read_ref(t->ref, parent_oid.hash)) {
21 + struct commit *parent = lookup_commit(parent_oid.hash);
22 if (parse_commit(parent))
23 die("Failed to find/parse commit %s", t->ref);
24 commit_list_insert(parent, &parents);
@@ -26,14 +26,14 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,
26 /* else: t->ref points to nothing, assume root/orphan commit */
27 }
28
29 - if (commit_tree(msg, msg_len, tree_sha1, parents, result_sha1, NULL, NULL))
29 + if (commit_tree(msg, msg_len, tree_oid.hash, parents, result_sha1, NULL, NULL))
30 die("Failed to commit notes tree to database");
31 }
32
33 void commit_notes(struct notes_tree *t, const char *msg)
34 {
35 struct strbuf buf = STRBUF_INIT;
36 - unsigned char commit_sha1[20];
36 + struct object_id commit_oid;
37
38 if (!t)
39 t = &default_notes_tree;
@@ -46,9 +46,9 @@ void commit_notes(struct notes_tree *t, const char *msg)
46 strbuf_addstr(&buf, msg);
47 strbuf_complete_line(&buf);
48
49 - create_notes_commit(t, NULL, buf.buf, buf.len, commit_sha1);
49 + create_notes_commit(t, NULL, buf.buf, buf.len, commit_oid.hash);
50 strbuf_insert(&buf, 0, "notes: ", 7); /* commit message starts at index 7 */
51 - update_ref(buf.buf, t->update_ref, commit_sha1, NULL, 0,
51 + update_ref(buf.buf, t->update_ref, commit_oid.hash, NULL, 0,
52 UPDATE_REFS_DIE_ON_ERR);
53
54 strbuf_release(&buf);