ref-filter: add 'ref-filter.h'
[git/git.git] / ref-filter.h
CommitLineData
69b1cf91
KN
1#ifndef REF_FILTER_H
2#define REF_FILTER_H
3
4#include "sha1-array.h"
5#include "refs.h"
6#include "commit.h"
7#include "parse-options.h"
8
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
15
16struct atom_value {
17 const char *s;
18 unsigned long ul; /* used for sorting when not FIELD_STR */
19};
20
21struct ref_sorting {
22 struct ref_sorting *next;
23 int atom; /* index into used_atom array (internal) */
24 unsigned reverse : 1;
25};
26
27struct ref_array_item {
28 unsigned char objectname[20];
29 int flag;
30 const char *symref;
31 struct atom_value *value;
32 char *refname;
33};
34
35struct ref_array {
36 int nr, alloc;
37 struct ref_array_item **items;
38};
39
40struct ref_filter {
41 const char **name_patterns;
42};
43
44struct ref_filter_cbdata {
45 struct ref_array array;
46 struct ref_filter filter;
47};
48
49/* Callback function for for_each_*ref(). This filters the refs based on the filters set */
50int ref_filter_handler(const char *refname, const struct object_id *oid, int flag, void *cb_data);
51/* Clear all memory allocated to ref_array */
52void ref_array_clear(struct ref_array *array);
53/* Parse format string and sort specifiers */
54int 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 */
56int verify_ref_format(const char *format);
57/* Sort the given ref_array as per the ref_sorting provided */
58void ref_array_sort(struct ref_sorting *sort, struct ref_array *array);
59/* Print the ref using the given format and quote_style */
60void show_ref_array_item(struct ref_array_item *info, const char *format, int quote_style);
61/* Callback function for parsing the sort option */
62int parse_opt_ref_sorting(const struct option *opt, const char *arg, int unset);
63/* Default sort option based on refname */
64struct ref_sorting *ref_default_sorting(void);
65
66#endif /* REF_FILTER_H */