From 9b391f218a5b732a5a8abae87d3165e97fe2f6f6 Mon Sep 17 00:00:00 2001 From: Johan Herland Date: Sat, 13 Feb 2010 22:28:15 +0100 Subject: Notes API: get_note(): Return the note annotating the given object Created by a simple cleanup and rename of lookup_notes(). Signed-off-by: Johan Herland Signed-off-by: Junio C Hamano --- notes.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'notes.c') diff --git a/notes.c b/notes.c index 2e82d71987..a0a85b4daf 100644 --- a/notes.c +++ b/notes.c @@ -462,12 +462,13 @@ void remove_note(const unsigned char *object_sha1) return note_tree_remove(&root_node, 0, &l); } -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) @@ -481,7 +482,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; @@ -489,7 +490,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; -- cgit v1.2.1