1#ifndef REF_FILTER_H
2#define REF_FILTER_H
34
#include "sha1-array.h"
5#include "refs.h"
6#include "commit.h"
7#include "parse-options.h"
89
/* 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
1516
struct atom_value {
17const char *s;
18unsigned long ul; /* used for sorting when not FIELD_STR */
19};
2021
struct ref_sorting {
22struct ref_sorting *next;
23int atom; /* index into used_atom array (internal) */
24unsigned reverse : 1;
25};
2627
struct ref_array_item {
28unsigned char objectname[20];
29int flag;
30const char *symref;
31struct atom_value *value;
32char *refname;
33};
3435
struct ref_array {
36int nr, alloc;
37struct ref_array_item **items;
38};
3940
struct ref_filter {
41const char **name_patterns;
42};
4344
struct ref_filter_cbdata {
45struct ref_array array;
46struct ref_filter filter;
47};
4849
/* 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);
6566
#endif /* REF_FILTER_H */