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

[PATCH 1/6] notes: make expand_notes_ref globally accessible

From
Jeff King <peff@peff.net>
Date
Mar 29, 2011, 20:55 UTC
Message-ID
<20110329205532.GA23466@sigill.intra.peff.net>
In-Reply-To
<20110329205307.GA30959@sigill.intra.peff.net>

This function is useful for other commands besides "git notes" which want to let users refer to notes by their shorthand name.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/notes.c |   10 ----------
 notes.c         |   10 ++++++++++
 notes.h         |    3 +++
 3 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/builtin/notes.c b/builtin/notes.c
index a0f310b..6227607 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -100,16 +100,6 @@ struct msg_arg {
 	struct strbuf buf;
 };
 
-static void expand_notes_ref(struct strbuf *sb)
-{
-	if (!prefixcmp(sb->buf, "refs/notes/"))
-		return; /* we're happy */
-	else if (!prefixcmp(sb->buf, "notes/"))
-		strbuf_insert(sb, 0, "refs/", 5);
-	else
-		strbuf_insert(sb, 0, "refs/notes/", 11);
-}
-
 static int list_each_note(const unsigned char *object_sha1,
 		const unsigned char *note_sha1, char *note_path,
 		void *cb_data)
diff --git a/notes.c b/notes.c
index a013c1b..f6b9b6a 100644
--- a/notes.c
+++ b/notes.c
@@ -1285,3 +1285,13 @@ int copy_note(struct notes_tree *t,
 
 	return 0;
 }
+
+void expand_notes_ref(struct strbuf *sb)
+{
+	if (!prefixcmp(sb->buf, "refs/notes/"))
+		return; /* we're happy */
+	else if (!prefixcmp(sb->buf, "notes/"))
+		strbuf_insert(sb, 0, "refs/", 5);
+	else
+		strbuf_insert(sb, 0, "refs/notes/", 11);
+}
diff --git a/notes.h b/notes.h
index 83bd6e0..60bdf28 100644
--- a/notes.h
+++ b/notes.h
@@ -307,4 +307,7 @@ void string_list_add_refs_by_glob(struct string_list *list, const char *glob);
 void string_list_add_refs_from_colon_sep(struct string_list *list,
 					 const char *globs);
 
+/* Expand inplace a note ref like "foo" or "notes/foo" into "refs/notes/foo" */
+void expand_notes_ref(struct strbuf *sb);
+
 #endif
-- 
1.7.4.2.7.g9407
Previous: Jeff KingNext: Jeff King
Message 7 of 23 in “revision.c: introduce --notes-ref= to use one notes ref only”
  1. revision.c: introduce --notes-ref= to use one notes ref onlyMichael J Gruber, Mar 29, 2011
  2. Johan HerlandMar 29, 2011
  3. Jeff KingMar 29, 2011
  4. Michael J GruberMar 29, 2011
  5. Junio C HamanoMar 29, 2011
  6. Jeff KingMar 29, 2011
  7. 1/6 notes: make expand_notes_ref globally accessibleJeff King, Mar 29, 2011
  8. 2/6 revision.c: refactor notes ref expansionJeff King, Mar 29, 2011
  9. 3/6 notes: refactor display notes extra refs fieldJeff King, Mar 29, 2011
  10. 4/6 notes: refactor display notes default handlingJeff King, Mar 29, 2011
  11. Junio C HamanoMar 29, 2011
  12. 5/6 revision.c: support --notes command-line optionJeff King, Mar 29, 2011
  13. 6/6 revision.c: make --no-notes reset --notes listJeff King, Mar 29, 2011
  14. Junio C HamanoMar 29, 2011
  15. Johan HerlandMar 29, 2011
  16. 7/6 log/pretty-options: Document --[no-]notes and deprecate old notes optionsJohan Herland, Mar 29, 2011
  17. Jeff KingMar 30, 2011
  18. 7/6 log/pretty-options: Document --[no-]notes and deprecate old notes optionsJohan Herland, Mar 30, 2011
  19. Jeff KingMar 30, 2011
  20. Jeff KingMar 29, 2011
  21. Jeff KingMar 29, 2011
  22. Michael J GruberMar 29, 2011
  23. Jeff KingMar 29, 2011

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.