ref-filter: add 'ref-filter.h'
[git.git] / ref-filter.h
blob506ac8f3599af866da2437af2f245d046e981f42
1 #ifndef REF_FILTER_H
2 #define REF_FILTER_H
4 #include "sha1-array.h"
5 #include "refs.h"
6 #include "commit.h"
7 #include "parse-options.h"
9 /* Quoting styles */
10 #define QUOTE_NONE 0
11 #define QUOTE_SHELL 1
12 #define QUOTE_PERL 2
13 #define QUOTE_PYTHON 4
14 #define QUOTE_TCL 8
16 struct atom_value {
17 const char *s;
18 unsigned long ul; /* used for sorting when not FIELD_STR */
21 struct ref_sorting {
22 struct ref_sorting *next;
23 int atom; /* index into used_atom array (internal) */
24 unsigned reverse : 1;
27 struct ref_array_item {
28 unsigned char objectname[20];
29 int flag;
30 const char *symref;
31 struct atom_value *value;
32 char *refname;
35 struct ref_array {
36 int nr, alloc;
37 struct ref_array_item **items;
40 struct ref_filter {
41 const char **name_patterns;
44 struct ref_filter_cbdata {
45 struct ref_array array;
46 struct ref_filter filter;
49 /* Callback function for for_each_*ref(). This filters the refs based on the filters set */
50 int ref_filter_handler(const char *refname, const struct object_id *oid, int flag, void *cb_data);
51 /* Clear all memory allocated to ref_array */
52 void ref_array_clear(struct ref_array *array);
53 /* Parse format string and sort specifiers */
54 int parse_ref_filter_atom(const char *atom, const char *ep);
55 /* Used to verify if the given format is correct and to parse out the used atoms */
56 int verify_ref_format(const char *format);
57 /* Sort the given ref_array as per the ref_sorting provided */
58 void ref_array_sort(struct ref_sorting *sort, struct ref_array *array);
59 /* Print the ref using the given format and quote_style */
60 void show_ref_array_item(struct ref_array_item *info, const char *format, int quote_style);
61 /* Callback function for parsing the sort option */
62 int parse_opt_ref_sorting(const struct option *opt, const char *arg, int unset);
63 /* Default sort option based on refname */
64 struct ref_sorting *ref_default_sorting(void);
66 #endif /* REF_FILTER_H */