diff options
Diffstat (limited to 'ref-filter.h')
-rw-r--r-- | ref-filter.h | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/ref-filter.h b/ref-filter.h index aa0eea4ecf..1524bc463a 100644 --- a/ref-filter.h +++ b/ref-filter.h @@ -1,10 +1,12 @@ #ifndef REF_FILTER_H #define REF_FILTER_H +#include "gettext.h" #include "oid-array.h" #include "refs.h" #include "commit.h" -#include "parse-options.h" +#include "string-list.h" +#include "strvec.h" /* Quoting styles */ #define QUOTE_NONE 0 @@ -24,6 +26,8 @@ struct atom_value; struct ref_sorting; +struct ahead_behind_count; +struct option; enum ref_sorting_order { REF_SORTING_REVERSE = 1<<0, @@ -40,6 +44,8 @@ struct ref_array_item { const char *symref; struct commit *commit; struct atom_value *value; + struct ahead_behind_count **counts; + char refname[FLEX_ARRAY]; }; @@ -47,10 +53,14 @@ struct ref_array { int nr, alloc; struct ref_array_item **items; struct rev_info *revs; + + struct ahead_behind_count *counts; + size_t counts_nr; }; struct ref_filter { const char **name_patterns; + struct strvec exclude; struct oid_array points_at; struct commit_list *with_commit; struct commit_list *no_commit; @@ -75,14 +85,23 @@ struct ref_format { const char *format; const char *rest; int quote_style; - int use_rest; int use_color; /* Internal state to ref-filter */ int need_color_reset_at_eol; + + /* List of bases for ahead-behind counts. */ + struct string_list bases; }; -#define REF_FORMAT_INIT { .use_color = -1 } +#define REF_FILTER_INIT { \ + .points_at = OID_ARRAY_INIT, \ + .exclude = STRVEC_INIT, \ +} +#define REF_FORMAT_INIT { \ + .use_color = -1, \ + .bases = STRING_LIST_INIT_DUP, \ +} /* Macros for checking --merged and --no-merged options */ #define _OPT_MERGED_NO_MERGED(option, filter, h) \ @@ -96,6 +115,9 @@ struct ref_format { #define OPT_REF_SORT(var) \ OPT_STRING_LIST(0, "sort", (var), \ N_("key"), N_("field name to sort on")) +#define OPT_REF_FILTER_EXCLUDE(var) \ + OPT_STRVEC(0, "exclude", &(var)->exclude, \ + N_("pattern"), N_("exclude refs which match pattern")) /* * API for filtering a set of refs. Based on the type of refs the user @@ -143,4 +165,18 @@ struct ref_array_item *ref_array_push(struct ref_array *array, const char *refname, const struct object_id *oid); +/* + * If the provided format includes ahead-behind atoms, then compute the + * ahead-behind values for the array of filtered references. Must be + * called after filter_refs() but before outputting the formatted refs. + * + * If this is not called, then any ahead-behind atoms will be blank. + */ +void filter_ahead_behind(struct repository *r, + struct ref_format *format, + struct ref_array *array); + +void ref_filter_init(struct ref_filter *filter); +void ref_filter_clear(struct ref_filter *filter); + #endif /* REF_FILTER_H */ |