Skip to content

Commit

Permalink
notes: make expand_notes_ref globally accessible
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Mar 29, 2011
1 parent 07514c8 commit 03bb578
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
10 changes: 0 additions & 10 deletions builtin/notes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions notes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
3 changes: 3 additions & 0 deletions notes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 03bb578

Please sign in to comment.