notes: make expand_notes_ref globally accessible
authorJeff King <peff@peff.net>
Tue, 29 Mar 2011 20:55:32 +0000 (16:55 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 29 Mar 2011 21:29:17 +0000 (14:29 -0700)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/notes.c
notes.c
notes.h

index a0f310b72956dcb00d2a0899d39ddfb9f7811fa4..62276072fc7d6788b40dc8b27c578dfd8416c385 100644 (file)
@@ -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 a013c1bc638dbf5a8111183a3f9d154721ec5e04..f6b9b6a72aa7b157627c8d59e8b9025377f13d44 100644 (file)
--- 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 83bd6e0ec02a1a8650004f14cd7476eedbdff518..60bdf289a3fb053cf0010f66d7df41ae1d922b6a 100644 (file)
--- 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