Skip to content

Commit 18b74e5

Browse files
bk2204gitster
authored andcommitted
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>
1 parent 8eb9460 commit 18b74e5

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

notes-utils.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,33 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,
77
const char *msg, size_t msg_len,
88
unsigned char *result_sha1)
99
{
10-
unsigned char tree_sha1[20];
10+
struct object_id tree_oid;
1111

1212
assert(t->initialized);
1313

14-
if (write_notes_tree(t, tree_sha1))
14+
if (write_notes_tree(t, tree_oid.hash))
1515
die("Failed to write notes tree to database");
1616

1717
if (!parents) {
1818
/* 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);
2222
if (parse_commit(parent))
2323
die("Failed to find/parse commit %s", t->ref);
2424
commit_list_insert(parent, &parents);
2525
}
2626
/* else: t->ref points to nothing, assume root/orphan commit */
2727
}
2828

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))
3030
die("Failed to commit notes tree to database");
3131
}
3232

3333
void commit_notes(struct notes_tree *t, const char *msg)
3434
{
3535
struct strbuf buf = STRBUF_INIT;
36-
unsigned char commit_sha1[20];
36+
struct object_id commit_oid;
3737

3838
if (!t)
3939
t = &default_notes_tree;
@@ -46,9 +46,9 @@ void commit_notes(struct notes_tree *t, const char *msg)
4646
strbuf_addstr(&buf, msg);
4747
strbuf_complete_line(&buf);
4848

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);
5050
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,
5252
UPDATE_REFS_DIE_ON_ERR);
5353

5454
strbuf_release(&buf);

0 commit comments

Comments
 (0)