builtin/bundle: have unbundle check for repo before opening its bundle
[git/gitster.git] / decorate.h
blob08af658d34afc3c209ee8e9ab5489e81bec2b9c9
1 #ifndef DECORATE_H
2 #define DECORATE_H
4 /*
5 * A data structure that associates Git objects to void pointers. See
6 * t/unit-tests/t-example-decorate.c for a demonstration of how to use these
7 * functions.
8 */
11 * An entry in the data structure.
13 struct decoration_entry {
14 const struct object *base;
15 void *decoration;
19 * The data structure.
21 * This data structure must be zero-initialized.
23 struct decoration {
25 * Not used by the decoration mechanism. Clients may use this for
26 * whatever they want.
28 const char *name;
31 * The capacity of "entries".
33 unsigned int size;
36 * The number of real Git objects (that is, entries with non-NULL
37 * "base").
39 unsigned int nr;
42 * The entries. This is an array of size "size", containing nr entries
43 * with non-NULL "base" and (size - nr) entries with NULL "base".
45 struct decoration_entry *entries;
49 * Add an association from the given object to the given pointer (which may be
50 * NULL), returning the previously associated pointer. If there is no previous
51 * association, this function returns NULL.
53 void *add_decoration(struct decoration *n, const struct object *obj, void *decoration);
56 * Return the pointer associated to the given object. If there is no
57 * association, this function returns NULL.
59 void *lookup_decoration(struct decoration *n, const struct object *obj);
62 * Clear all decoration entries, releasing any memory used by the structure.
63 * If free_cb is not NULL, it is called for every decoration value currently
64 * stored.
66 * After clearing, the decoration struct can be used again. The "name" field is
67 * retained.
69 void clear_decoration(struct decoration *n, void (*free_cb)(void *));
71 #endif