From 61a7cca0c6504aee7bae7837582230561bdb81d4 Mon Sep 17 00:00:00 2001 From: Johan Herland Date: Sat, 13 Feb 2010 22:28:17 +0100 Subject: Notes API: write_notes_tree(): Store the notes tree in the database Uses for_each_note() to traverse the notes tree, and produces tree objects on the fly representing the "on-disk" version of the notes tree with appropriate fanout. Signed-off-by: Johan Herland Signed-off-by: Junio C Hamano --- notes.h | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'notes.h') diff --git a/notes.h b/notes.h index 2131912902..c49b7a512f 100644 --- a/notes.h +++ b/notes.h @@ -21,11 +21,23 @@ */ void init_notes(const char *notes_ref, int flags); -/* Add the given note object to the internal notes tree structure */ +/* + * Add the given note object to the internal notes tree structure + * + * IMPORTANT: The changes made by add_note() to the internal notes tree structure + * are not persistent until a subsequent call to write_notes_tree() returns + * zero. + */ void add_note(const unsigned char *object_sha1, const unsigned char *note_sha1); -/* Remove the given note object from the internal notes tree structure */ +/* + * Remove the given note object from the internal notes tree structure + * + * IMPORTANT: The changes made by remove_note() to the internal notes tree + * structure are not persistent until a subsequent call to write_notes_tree() + * returns zero. + */ void remove_note(const unsigned char *object_sha1); /* @@ -82,7 +94,27 @@ typedef int each_note_fn(const unsigned char *object_sha1, void *cb_data); int for_each_note(int flags, each_note_fn fn, void *cb_data); -/* Free (and de-initialize) the internal notes tree structure */ +/* + * Write the internal notes tree structure to the object database + * + * Creates a new tree object encapsulating the current state of the + * internal notes tree, and stores its SHA1 into the 'result' argument. + * + * Returns zero on success, non-zero on failure. + * + * IMPORTANT: Changes made to the internal notes tree structure are not + * persistent until this function has returned zero. Please also remember + * to create a corresponding commit object, and update the appropriate + * notes ref. + */ +int write_notes_tree(unsigned char *result); + +/* + * Free (and de-initialize) the internal notes tree structure + * + * IMPORTANT: Changes made to the notes tree since the last, successful + * call to write_notes_tree() will be lost. + */ void free_notes(void); /* Flags controlling how notes are formatted */ -- cgit v1.2.3