git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC/PATCHv8 04/10] Notes API: get_note(): Return the note annotating the given object

From
Johan Herland <johan@herland.net>
Date
Nov 20, 2009, 01:39 UTC
Message-ID
<1258681154-2167-5-git-send-email-johan@herland.net>
In-Reply-To
<1258681154-2167-1-git-send-email-johan@herland.net>
Created by a simple cleanup and rename of lookup_notes().
Signed-off-by: Johan Herland <johan@herland.net>
---
 notes.c |   15 ++++++++-------
 notes.h |    3 +++
 2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/notes.c b/notes.c
index 49a3e86..2196a5f 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.4.304.g1365c.dirty
Previous: Johan HerlandNext: Johan Herland
Message 5 of 26 in “[RFC/PATCHv8 00/10] git notes”
  1. Johan HerlandNov 20, 2009
  2. 01/10 Notes API: get_commit_notes() -> format_note() + remove the commit restrictionJohan Herland, Nov 20, 2009
  3. 02/10 Notes API: init_notes(): Initialize the notes tree from the given notes refJohan Herland, Nov 20, 2009
  4. 03/10 Notes API: add_note(): Add note objects to the internal notes tree structureJohan Herland, Nov 20, 2009
  5. 04/10 Notes API: get_note(): Return the note annotating the given objectJohan Herland, Nov 20, 2009
  6. 05/10 Notes API: for_each_note(): Traverse the entire notes tree with a callbackJohan Herland, Nov 20, 2009
  7. 06/10 Notes API: Allow multiple concurrent notes trees with new struct notes_treeJohan Herland, Nov 20, 2009
  8. 07/10 Refactor notes concatenation into a flexible interface for combining notesJohan Herland, Nov 20, 2009
  9. 08/10 fast-import: Proper notes tree manipulation using the notes APIJohan Herland, Nov 20, 2009
  10. Shawn O. PearceNov 26, 2009
  11. Johan HerlandNov 26, 2009
  12. Shawn O. PearceNov 26, 2009
  13. 09/10 Rename t9301 to t9350, to make room for more fast-import testsJohan Herland, Nov 20, 2009
  14. 10/10 Add more testcases to test fast-import of notesJohan Herland, Nov 20, 2009
  15. Junio C HamanoNov 20, 2009
  16. Johan HerlandNov 20, 2009
  17. Nanako ShiraishiNov 20, 2009
  18. Johannes SchindelinNov 20, 2009
  19. Junio C HamanoNov 20, 2009
  20. Junio C HamanoNov 20, 2009
  21. Alex RiesenJan 19, 2010
  22. Junio C HamanoJan 19, 2010
  23. Junio C HamanoJan 20, 2010
  24. Johannes SixtJan 20, 2010
  25. Junio C HamanoJan 20, 2010
  26. Alex RiesenJan 20, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.