attr.hon commit attr: eliminate global check_all_attr array (685b292)
   1#ifndef ATTR_H
   2#define ATTR_H
   3
   4/* An attribute is a pointer to this opaque structure */
   5struct git_attr;
   6
   7/* opaque structure used internally for attribute collection */
   8struct all_attrs_item;
   9
  10/*
  11 * Given a string, return the gitattribute object that
  12 * corresponds to it.
  13 */
  14struct git_attr *git_attr(const char *);
  15
  16/* Internal use */
  17extern const char git_attr__true[];
  18extern const char git_attr__false[];
  19
  20/* For public to check git_attr_check results */
  21#define ATTR_TRUE(v) ((v) == git_attr__true)
  22#define ATTR_FALSE(v) ((v) == git_attr__false)
  23#define ATTR_UNSET(v) ((v) == NULL)
  24
  25/*
  26 * Send one or more git_attr_check to git_check_attrs(), and
  27 * each 'value' member tells what its value is.
  28 * Unset one is returned as NULL.
  29 */
  30struct attr_check_item {
  31        const struct git_attr *attr;
  32        const char *value;
  33};
  34
  35struct attr_check {
  36        int nr;
  37        int alloc;
  38        struct attr_check_item *items;
  39        int all_attrs_nr;
  40        struct all_attrs_item *all_attrs;
  41};
  42
  43extern struct attr_check *attr_check_alloc(void);
  44extern struct attr_check *attr_check_initl(const char *, ...);
  45
  46extern struct attr_check_item *attr_check_append(struct attr_check *check,
  47                                                 const struct git_attr *attr);
  48
  49extern void attr_check_reset(struct attr_check *check);
  50extern void attr_check_clear(struct attr_check *check);
  51extern void attr_check_free(struct attr_check *check);
  52
  53/*
  54 * Return the name of the attribute represented by the argument.  The
  55 * return value is a pointer to a null-delimited string that is part
  56 * of the internal data structure; it should not be modified or freed.
  57 */
  58extern const char *git_attr_name(const struct git_attr *);
  59
  60extern int git_check_attr(const char *path, struct attr_check *check);
  61
  62/*
  63 * Retrieve all attributes that apply to the specified path.
  64 * check holds the attributes and their values.
  65 */
  66extern void git_all_attrs(const char *path, struct attr_check *check);
  67
  68enum git_attr_direction {
  69        GIT_ATTR_CHECKIN,
  70        GIT_ATTR_CHECKOUT,
  71        GIT_ATTR_INDEX
  72};
  73void git_attr_set_direction(enum git_attr_direction, struct index_state *);
  74
  75extern void attr_start(void);
  76
  77#endif /* ATTR_H */