Created by a simple cleanup and rename of lookup_notes(). Signed-off-by: Johan Herland <johan@xxxxxxxxxxx> --- notes.c | 15 ++++++++------- notes.h | 3 +++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/notes.c b/notes.c index 3c8a6e0..6a36ff9 100644 --- a/notes.c +++ b/notes.c @@ -377,12 +377,13 @@ void add_note(const unsigned char *object_sha1, const unsigned char *note_sha1) note_tree_insert(&root_node, 0, l, PTR_TYPE_NOTE); } -static unsigned char *lookup_notes(const unsigned char *object_sha1) +const unsigned char *get_note(const unsigned char *object_sha1) { - struct leaf_node *found = note_tree_find(&root_node, 0, object_sha1); - if (found) - return found->val_sha1; - return NULL; + struct leaf_node *found; + + assert(initialized); + found = note_tree_find(&root_node, 0, object_sha1); + return found ? found->val_sha1 : NULL; } void free_notes(void) @@ -396,7 +397,7 @@ void format_note(const unsigned char *object_sha1, struct strbuf *sb, const char *output_encoding, int flags) { static const char utf8[] = "utf-8"; - unsigned char *sha1; + const unsigned char *sha1; char *msg, *msg_p; unsigned long linelen, msglen; enum object_type type; @@ -404,7 +405,7 @@ void format_note(const unsigned char *object_sha1, struct strbuf *sb, if (!initialized) init_notes(NULL, 0); - sha1 = lookup_notes(object_sha1); + sha1 = get_note(object_sha1); if (!sha1) return; diff --git a/notes.h b/notes.h index 5f22852..21a8930 100644 --- a/notes.h +++ b/notes.h @@ -25,6 +25,9 @@ void init_notes(const char *notes_ref, int flags); void add_note(const unsigned char *object_sha1, const unsigned char *note_sha1); +/* Get the note object SHA1 containing the note data for the given object */ +const unsigned char *get_note(const unsigned char *object_sha1); + /* Free (and de-initialize) the internal notes tree structure */ void free_notes(void); -- 1.6.5.3.433.g11067 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html