| 1195 | } |
| 1196 | |
| 1197 | int write_notes_tree(struct notes_tree *t, struct object_id *result) |
| 1198 | { |
| 1199 | struct tree_write_stack root; |
| 1200 | struct write_each_note_data cb_data; |
| 1201 | int ret; |
| 1202 | int flags; |
| 1203 | |
| 1204 | if (!t) |
| 1205 | t = &default_notes_tree; |
| 1206 | assert(t->initialized); |
| 1207 | |
| 1208 | /* Prepare for traversal of current notes tree */ |
| 1209 | root.next = NULL; /* last forward entry in list is grounded */ |
| 1210 | strbuf_init(&root.buf, 256 * (32 + the_hash_algo->hexsz)); /* assume 256 entries */ |
| 1211 | root.path[0] = root.path[1] = '\0'; |
| 1212 | cb_data.root = &root; |
| 1213 | cb_data.nn_list = &(t->first_non_note); |
| 1214 | cb_data.nn_prev = NULL; |
| 1215 | |
| 1216 | /* Write tree objects representing current notes tree */ |
| 1217 | flags = FOR_EACH_NOTE_DONT_UNPACK_SUBTREES | |
| 1218 | FOR_EACH_NOTE_YIELD_SUBTREES; |
| 1219 | ret = for_each_note(t, flags, write_each_note, &cb_data) || |
| 1220 | write_each_non_note_until(NULL, &cb_data) || |
| 1221 | tree_write_stack_finish_subtree(&root) || |
| 1222 | odb_write_object(the_repository->objects, root.buf.buf, |
| 1223 | root.buf.len, OBJ_TREE, result); |
| 1224 | strbuf_release(&root.buf); |
| 1225 | return ret; |
| 1226 | } |
| 1227 | |
| 1228 | void prune_notes(struct notes_tree *t, int flags) |
| 1229 | { |
no test coverage detected