summaryrefslogtreecommitdiff
path: root/ref-filter.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-04-06 20:38:21 (GMT)
committerJunio C Hamano <gitster@pobox.com>2023-04-06 20:38:21 (GMT)
commit7727da99dfab82148c5b77eaf334b305fb835956 (patch)
tree99ea4038ce40c89d09592a94a715b642160216a8 /ref-filter.h
parentae73b2c8f1da39c39335ee76a0f95857712c22a7 (diff)
parentcbfe360b140fe92d9c4a763bf630c3b8ba431522 (diff)
downloadgit-7727da99dfab82148c5b77eaf334b305fb835956.zip
git-7727da99dfab82148c5b77eaf334b305fb835956.tar.gz
git-7727da99dfab82148c5b77eaf334b305fb835956.tar.bz2
Merge branch 'ds/ahead-behind'
"git for-each-ref" learns '%(ahead-behind:<base>)' that computes the distances from a single reference point in the history with bunch of commits in bulk. * ds/ahead-behind: commit-reach: add tips_reachable_from_bases() for-each-ref: add ahead-behind format atom commit-reach: implement ahead_behind() logic commit-graph: introduce `ensure_generations_valid()` commit-graph: return generation from memory commit-graph: simplify compute_generation_numbers() commit-graph: refactor compute_topological_levels() for-each-ref: explicitly test no matches for-each-ref: add --stdin option
Diffstat (limited to 'ref-filter.h')
-rw-r--r--ref-filter.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/ref-filter.h b/ref-filter.h
index daa6d02..ae51ace 100644
--- a/ref-filter.h
+++ b/ref-filter.h
@@ -4,6 +4,7 @@
#include "oid-array.h"
#include "refs.h"
#include "commit.h"
+#include "string-list.h"
/* Quoting styles */
#define QUOTE_NONE 0
@@ -23,6 +24,7 @@
struct atom_value;
struct ref_sorting;
+struct ahead_behind_count;
struct option;
enum ref_sorting_order {
@@ -40,6 +42,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,6 +51,9 @@ 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 {
@@ -80,9 +87,15 @@ struct ref_format {
/* 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_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) \
@@ -143,4 +156,15 @@ 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);
+
#endif /* REF_FILTER_H */