X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;ds=sidebyside;f=notes.h;h=65fc3a66b2f575dd078cc390e7f5ea5cbebffc96;hb=48c250a121a425a1860226b6a7061aecfbab5246;hp=bad03ccab776d837751803623394667bfd1c7d11;hpb=4503bd5c3732b142667e14d214c21c46e8f3eeaa;p=git.git diff --git a/notes.h b/notes.h index bad03ccab..65fc3a66b 100644 --- a/notes.h +++ b/notes.h @@ -18,7 +18,7 @@ * combine_notes_concatenate(), which appends the contents of the new note to * the contents of the existing note. */ -typedef int combine_notes_fn(unsigned char *cur_sha1, const unsigned char *new_sha1); +typedef int (*combine_notes_fn)(unsigned char *cur_sha1, const unsigned char *new_sha1); /* Common notes combinators */ int combine_notes_concatenate(unsigned char *cur_sha1, const unsigned char *new_sha1); @@ -38,8 +38,9 @@ extern struct notes_tree { struct int_node *root; struct non_note *first_non_note, *prev_non_note; char *ref; - combine_notes_fn *combine_notes; + combine_notes_fn combine_notes; int initialized; + int dirty; } default_notes_tree; /* @@ -99,6 +100,15 @@ void remove_note(struct notes_tree *t, const unsigned char *object_sha1); const unsigned char *get_note(struct notes_tree *t, const unsigned char *object_sha1); +/* + * Copy a note from one object to another in the given notes_tree. + * + * Fails if the to_obj already has a note unless 'force' is true. + */ +int copy_note(struct notes_tree *t, + const unsigned char *from_obj, const unsigned char *to_obj, + int force, combine_notes_fn combine_fn); + /* * Flags controlling behaviour of for_each_note() * @@ -161,6 +171,9 @@ int for_each_note(struct notes_tree *t, int flags, each_note_fn fn, */ int write_notes_tree(struct notes_tree *t, unsigned char *result); +/* Flags controlling the operation of prune */ +#define NOTES_PRUNE_VERBOSE 1 +#define NOTES_PRUNE_DRYRUN 2 /* * Remove all notes annotating non-existing objects from the given notes tree * @@ -171,7 +184,7 @@ int write_notes_tree(struct notes_tree *t, unsigned char *result); * structure are not persistent until a subsequent call to write_notes_tree() * returns zero. */ -void prune_notes(struct notes_tree *t); +void prune_notes(struct notes_tree *t, int flags); /* * Free (and de-initialize) the given notes_tree structure @@ -198,4 +211,59 @@ void free_notes(struct notes_tree *t); 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; +}; + +/* + * Load the notes machinery for displaying several notes trees. + * + * If 'opt' is not NULL, then it specifies additional settings for the + * displaying: + * + * - suppress_default_notes indicates that the notes from + * core.notesRef and notes.displayRef should not be loaded. + * + * - extra_notes_refs may contain a list of globs (in the same style + * as notes.displayRef) where notes should be loaded from. + */ +void init_display_notes(struct display_notes_opt *opt); + +/* + * Append notes for the given 'object_sha1' from all trees set up by + * init_display_notes() to 'sb'. The 'flags' are a bitwise + * combination of + * + * - NOTES_SHOW_HEADER: add a 'Notes (refname):' header + * + * - NOTES_INDENT: indent the notes by 4 places + * + * 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); + +/* + * 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); + +/* + * Add all refs that match 'glob' to the 'list'. + */ +void string_list_add_refs_by_glob(struct string_list *list, const char *glob); + +/* + * Add all refs from a colon-separated glob list 'globs' to the end of + * 'list'. Empty components are ignored. This helper is used to + * parse GIT_NOTES_DISPLAY_REF style environment variables. + */ +void string_list_add_refs_from_colon_sep(struct string_list *list, + const char *globs); + #endif