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>
This commit is contained in:
Jeff King
2011-03-29 16:55:32 -04:00
committed by Junio C Hamano
parent 07514c83c2
commit 03bb5789cd
3 changed files with 13 additions and 10 deletions

10
notes.c
View File

@ -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);
}