notes: make expand_notes_ref globally accessible
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>
Jeff King committed
Mar 29, 2011 at 16:55 UTC
03bb5789cd97de989897e1c9de71a2831ada0544
3 files changed
+13
-10
builtin/notes.c
-10
@@ -100,16 +100,6 @@ struct msg_arg {
100
struct strbuf buf;
101
};
102
103
-static void expand_notes_ref(struct strbuf *sb)
104
-{
105
- if (!prefixcmp(sb->buf, "refs/notes/"))
106
- return; /* we're happy */
107
- else if (!prefixcmp(sb->buf, "notes/"))
108
- strbuf_insert(sb, 0, "refs/", 5);
109
- else
110
- strbuf_insert(sb, 0, "refs/notes/", 11);
111
-}
112
-
103
static int list_each_note(const unsigned char *object_sha1,
104
const unsigned char *note_sha1, char *note_path,
105
void *cb_data)
notes.c
+10
@@ -1285,3 +1285,13 @@ int copy_note(struct notes_tree *t,
1285
1286
return 0;
1287
}
1288
+
1289
+void expand_notes_ref(struct strbuf *sb)
1290
+{
1291
+ if (!prefixcmp(sb->buf, "refs/notes/"))
1292
+ return; /* we're happy */
1293
+ else if (!prefixcmp(sb->buf, "notes/"))
1294
+ strbuf_insert(sb, 0, "refs/", 5);
1295
+ else
1296
+ strbuf_insert(sb, 0, "refs/notes/", 11);
1297
+}
notes.h
+3
@@ -307,4 +307,7 @@ void string_list_add_refs_by_glob(struct string_list *list, const char *glob);
307
void string_list_add_refs_from_colon_sep(struct string_list *list,
308
const char *globs);
309
310
+/* Expand inplace a note ref like "foo" or "notes/foo" into "refs/notes/foo" */
311
+void expand_notes_ref(struct strbuf *sb);
312
+
313
#endif