diff options
Diffstat (limited to 'notes.h')
-rw-r--r-- | notes.h | 64 |
1 files changed, 33 insertions, 31 deletions
@@ -1,6 +1,8 @@ #ifndef NOTES_H #define NOTES_H +#include "string-list.h" + /* * Function type for combining two notes annotating the same object. * @@ -42,6 +44,7 @@ extern struct notes_tree { struct int_node *root; struct non_note *first_non_note, *prev_non_note; char *ref; + char *update_ref; combine_notes_fn combine_notes; int initialized; int dirty; @@ -70,12 +73,19 @@ const char *default_notes_ref(void); #define NOTES_INIT_EMPTY 1 /* + * By default, the notes tree is only readable, and the notes ref can be + * any treeish. The notes tree can however be made writable with this flag, + * in which case only strict ref names can be used. + */ +#define NOTES_INIT_WRITABLE 2 + +/* * Initialize the given notes_tree with the notes tree structure at the given * ref. If given ref is NULL, the value of the $GIT_NOTES_REF environment * variable is used, and if that is missing, the default notes ref is used * ("refs/notes/commits"). * - * If you need to re-intialize a notes_tree structure (e.g. when switching from + * If you need to re-initialize a notes_tree structure (e.g. when switching from * one notes ref to another), you must first de-initialize the notes_tree * structure by calling free_notes(struct notes_tree *). * @@ -111,8 +121,8 @@ void init_notes(struct notes_tree *t, const char *notes_ref, * are not persistent until a subsequent call to write_notes_tree() returns * zero. */ -int add_note(struct notes_tree *t, const unsigned char *object_sha1, - const unsigned char *note_sha1, combine_notes_fn combine_notes); +int add_note(struct notes_tree *t, const struct object_id *object_oid, + const struct object_id *note_oid, combine_notes_fn combine_notes); /* * Remove the given note object from the given notes_tree structure @@ -130,8 +140,8 @@ int remove_note(struct notes_tree *t, const unsigned char *object_sha1); * * Return NULL if the given object has no notes. */ -const unsigned char *get_note(struct notes_tree *t, - const unsigned char *object_sha1); +const struct object_id *get_note(struct notes_tree *t, + const struct object_id *object_oid); /* * Copy a note from one object to another in the given notes_tree. @@ -146,7 +156,7 @@ const unsigned char *get_note(struct notes_tree *t, * zero. */ int copy_note(struct notes_tree *t, - const unsigned char *from_obj, const unsigned char *to_obj, + const struct object_id *from_obj, const struct object_id *to_obj, int force, combine_notes_fn combine_notes); /* @@ -192,8 +202,8 @@ int copy_note(struct notes_tree *t, * - copy_note() * - free_notes() */ -typedef int each_note_fn(const unsigned char *object_sha1, - const unsigned char *note_sha1, char *note_path, +typedef int each_note_fn(const struct object_id *object_oid, + const struct object_id *note_oid, char *note_path, void *cb_data); int for_each_note(struct notes_tree *t, int flags, each_note_fn fn, void *cb_data); @@ -235,29 +245,11 @@ void prune_notes(struct notes_tree *t, int flags); */ void free_notes(struct notes_tree *t); -/* Flags controlling how notes are formatted */ -#define NOTES_SHOW_HEADER 1 -#define NOTES_INDENT 2 - -/* - * Fill the given strbuf with the notes associated with the given object. - * - * If the given notes_tree structure is not initialized, it will be auto- - * initialized to the default value (see documentation for init_notes() above). - * If the given notes_tree is NULL, the internal/default notes_tree will be - * used instead. - * - * 'flags' is a bitwise combination of the above formatting flags. - */ -void format_note(struct notes_tree *t, const unsigned char *object_sha1, - struct strbuf *sb, const char *output_encoding, int flags); - - struct string_list; struct display_notes_opt { - unsigned int suppress_default_notes:1; - struct string_list *extra_notes_refs; + int use_default_notes; + struct string_list extra_notes_refs; }; /* @@ -285,14 +277,14 @@ void init_display_notes(struct display_notes_opt *opt); * * You *must* call init_display_notes() before using this function. */ -void format_display_notes(const unsigned char *object_sha1, - struct strbuf *sb, const char *output_encoding, int flags); +void format_display_notes(const struct object_id *object_oid, + struct strbuf *sb, const char *output_encoding, int raw); /* * Load the notes tree from each ref listed in 'refs'. The output is * an array of notes_tree*, terminated by a NULL. */ -struct notes_tree **load_notes_trees(struct string_list *refs); +struct notes_tree **load_notes_trees(struct string_list *refs, int flags); /* * Add all refs that match 'glob' to the 'list'. @@ -307,4 +299,14 @@ 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); + +/* + * Similar to expand_notes_ref, but will check whether the ref can be located + * via get_sha1 first, and only falls back to expand_notes_ref in the case + * where get_sha1 fails. + */ +void expand_loose_notes_ref(struct strbuf *sb); + #endif |