]> git.ipfire.org Git - thirdparty/git.git/blame - notes.h
Notes API: get_note(): Return the note annotating the given object
[thirdparty/git.git] / notes.h
CommitLineData
a97a7468
JS
1#ifndef NOTES_H
2#define NOTES_H
3
709f79b0
JH
4/*
5 * Flags controlling behaviour of notes tree initialization
6 *
7 * Default behaviour is to initialize the notes tree from the tree object
8 * specified by the given (or default) notes ref.
9 */
10#define NOTES_INIT_EMPTY 1
11
12/*
13 * Initialize internal notes tree structure with the notes tree at the given
14 * ref. If given ref is NULL, the value of the $GIT_NOTES_REF environment
15 * variable is used, and if that is missing, the default notes ref is used
16 * ("refs/notes/commits").
17 *
18 * If you need to re-intialize the internal notes tree structure (e.g. loading
19 * from a different notes ref), please first de-initialize the current notes
20 * tree by calling free_notes().
21 */
22void init_notes(const char *notes_ref, int flags);
23
2626b536
JH
24/* Add the given note object to the internal notes tree structure */
25void add_note(const unsigned char *object_sha1,
26 const unsigned char *note_sha1);
27
1ec666b0
JH
28/* Remove the given note object from the internal notes tree structure */
29void remove_note(const unsigned char *object_sha1);
30
9b391f21
JH
31/*
32 * Get the note object SHA1 containing the note data for the given object
33 *
34 * Return NULL if the given object has no notes.
35 */
36const unsigned char *get_note(const unsigned char *object_sha1);
37
27d57564
JH
38/* Free (and de-initialize) the internal notes tree structure */
39void free_notes(void);
40
a7e7eff6 41/* Flags controlling how notes are formatted */
c56fcc89
JH
42#define NOTES_SHOW_HEADER 1
43#define NOTES_INDENT 2
44
a7e7eff6
JH
45/*
46 * Fill the given strbuf with the notes associated with the given object.
47 *
48 * If the internal notes structure is not initialized, it will be auto-
49 * initialized to the default value (see documentation for init_notes() above).
50 *
51 * 'flags' is a bitwise combination of the above formatting flags.
52 */
53void format_note(const unsigned char *object_sha1, struct strbuf *sb,
c56fcc89 54 const char *output_encoding, int flags);
a97a7468
JS
55
56#endif