| 55 | } |
| 56 | |
| 57 | int notes_cache_write(struct notes_cache *c) |
| 58 | { |
| 59 | struct object_id tree_oid, commit_oid; |
| 60 | |
| 61 | if (!c || !c->tree.initialized || !c->tree.update_ref || |
| 62 | !*c->tree.update_ref) |
| 63 | return -1; |
| 64 | if (!c->tree.dirty) |
| 65 | return 0; |
| 66 | |
| 67 | if (write_notes_tree(&c->tree, &tree_oid)) |
| 68 | return -1; |
| 69 | if (commit_tree(c->validity, strlen(c->validity), &tree_oid, NULL, |
| 70 | &commit_oid, NULL, NULL) < 0) |
| 71 | return -1; |
| 72 | if (refs_update_ref(get_main_ref_store(the_repository), "update notes cache", c->tree.update_ref, &commit_oid, |
| 73 | NULL, 0, UPDATE_REFS_QUIET_ON_ERR) < 0) |
| 74 | return -1; |
| 75 | |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid, |
| 80 | size_t *outsize) |
no test coverage detected