git/ref-filter.h

#ifndef REF_FILTER_H
#define REF_FILTER_H

#include "gettext.h"
#include "oid-array.h"
#include "commit.h"
#include "string-list.h"
#include "strvec.h"
#include "commit-reach.h"

/* Quoting styles */
#define QUOTE_NONE
#define QUOTE_SHELL
#define QUOTE_PERL
#define QUOTE_PYTHON
#define QUOTE_TCL

#define FILTER_REFS_TAGS
#define FILTER_REFS_BRANCHES
#define FILTER_REFS_REMOTES
#define FILTER_REFS_OTHERS
#define FILTER_REFS_REGULAR
#define FILTER_REFS_DETACHED_HEAD
#define FILTER_REFS_PSEUDOREFS
#define FILTER_REFS_ROOT_REFS
#define FILTER_REFS_KIND_MASK

struct atom_value;
struct ref_sorting;
struct ahead_behind_count;
struct option;

enum ref_sorting_order {};

struct ref_array_item {};

struct ref_array {};

struct ref_filter {};

struct ref_format {};

#define REF_FILTER_INIT
#define REF_FORMAT_INIT

/*  Macros for checking --merged and --no-merged options */
#define _OPT_MERGED_NO_MERGED(option, filter, h)
#define OPT_MERGED(f, h)
#define OPT_NO_MERGED(f, h)

#define OPT_REF_SORT(var)
#define OPT_REF_FILTER_EXCLUDE(var)

/*
 * API for filtering a set of refs. Based on the type of refs the user
 * has requested, we iterate through those refs and apply filters
 * as per the given ref_filter structure and finally store the
 * filtered refs in the ref_array structure.
 */
int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int type);
/*
 * Filter refs using the given ref_filter and type, sort the contents
 * according to the given ref_sorting, format the filtered refs with the
 * given ref_format, and print them to stdout.
 */
void filter_and_format_refs(struct ref_filter *filter, unsigned int type,
			    struct ref_sorting *sorting,
			    struct ref_format *format);
/*  Clear all memory allocated to ref_array */
void ref_array_clear(struct ref_array *array);
/*  Used to verify if the given format is correct and to parse out the used atoms */
int verify_ref_format(struct ref_format *format);
/*  Sort the given ref_array as per the ref_sorting provided */
void ref_array_sort(struct ref_sorting *sort, struct ref_array *array);
/*  Set REF_SORTING_* sort_flags for all elements of a sorting list */
void ref_sorting_set_sort_flags_all(struct ref_sorting *sorting, unsigned int mask, int on);
/*  Based on the given format and quote_style, fill the strbuf */
int format_ref_array_item(struct ref_array_item *info,
			  struct ref_format *format,
			  struct strbuf *final_buf,
			  struct strbuf *error_buf);
/* Release a "struct ref_sorting" */
void ref_sorting_release(struct ref_sorting *);
/*  Convert list of sort options into ref_sorting */
struct ref_sorting *ref_sorting_options(struct string_list *);
/*  Function to parse --merged and --no-merged options */
int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset);
/*  Get the current HEAD's description */
char *get_head_description(void);
/*  Set up translated strings in the output. */
void setup_ref_filter_porcelain_msg(void);

/*
 * Print up to maxcount ref_array elements to stdout using the given
 * ref_format.
 */
void print_formatted_ref_array(struct ref_array *array, struct ref_format *format);

/*
 * Print a single ref, outside of any ref-filter. Note that the
 * name must be a fully qualified refname.
 */
void pretty_print_ref(const char *name, const struct object_id *oid,
		      struct ref_format *format);

/*
 * Push a single ref onto the array; this can be used to construct your own
 * ref_array without using filter_refs().
 */
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);

/*
 * If the provided format includes is-base atoms, then compute the base checks
 * for those tips against all refs.
 *
 * If this is not called, then any is-base atoms will be blank.
 */
void filter_is_base(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);

void ref_format_init(struct ref_format *format);
void ref_format_clear(struct ref_format *format);

#endif /*  REF_FILTER_H  */