summaryrefslogtreecommitdiff
path: root/notes.c
diff options
context:
space:
mode:
authorPatryk Obara <patryk.obara@gmail.com>2018-01-28 00:13:18 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-01-30 18:42:36 (GMT)
commitbbca96d579b31900c9c0ad39299a3c9a3bd276f9 (patch)
tree9980654efa40c1db4a70e605079b639cee6eb5db /notes.c
parentb7d591d17b0497597c2152ae86bd8aa4220d6961 (diff)
downloadgit-bbca96d579b31900c9c0ad39299a3c9a3bd276f9.zip
git-bbca96d579b31900c9c0ad39299a3c9a3bd276f9.tar.gz
git-bbca96d579b31900c9c0ad39299a3c9a3bd276f9.tar.bz2
notes: convert write_notes_tree to object_id
Convert the definition and declaration of write_notes_tree to struct object_id and adjust usage of this function. Additionally, improve style of small part of this function, as old formatting made it hard to understand at glance what this part of code is doing. Signed-off-by: Patryk Obara <patryk.obara@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'notes.c')
-rw-r--r--notes.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/notes.c b/notes.c
index 3f4f945..09ef1ce 100644
--- a/notes.c
+++ b/notes.c
@@ -1123,11 +1123,12 @@ int for_each_note(struct notes_tree *t, int flags, each_note_fn fn,
return for_each_note_helper(t, t->root, 0, 0, flags, fn, cb_data);
}
-int write_notes_tree(struct notes_tree *t, unsigned char *result)
+int write_notes_tree(struct notes_tree *t, struct object_id *result)
{
struct tree_write_stack root;
struct write_each_note_data cb_data;
int ret;
+ int flags;
if (!t)
t = &default_notes_tree;
@@ -1141,12 +1142,13 @@ int write_notes_tree(struct notes_tree *t, unsigned char *result)
cb_data.next_non_note = t->first_non_note;
/* Write tree objects representing current notes tree */
- ret = for_each_note(t, FOR_EACH_NOTE_DONT_UNPACK_SUBTREES |
- FOR_EACH_NOTE_YIELD_SUBTREES,
- write_each_note, &cb_data) ||
- write_each_non_note_until(NULL, &cb_data) ||
- tree_write_stack_finish_subtree(&root) ||
- write_sha1_file(root.buf.buf, root.buf.len, tree_type, result);
+ flags = FOR_EACH_NOTE_DONT_UNPACK_SUBTREES |
+ FOR_EACH_NOTE_YIELD_SUBTREES;
+ ret = for_each_note(t, flags, write_each_note, &cb_data) ||
+ write_each_non_note_until(NULL, &cb_data) ||
+ tree_write_stack_finish_subtree(&root) ||
+ write_sha1_file(root.buf.buf, root.buf.len, tree_type,
+ result->hash);
strbuf_release(&root.buf);
return ret;
}