From: Junio C Hamano Date: Thu, 6 Apr 2023 20:38:21 +0000 (-0700) Subject: Merge branch 'ds/ahead-behind' X-Git-Tag: v2.41.0-rc0~106 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7727da99dfab82148c5b77eaf334b305fb835956;p=thirdparty%2Fgit.git Merge branch 'ds/ahead-behind' "git for-each-ref" learns '%(ahead-behind:)' 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 --- 7727da99dfab82148c5b77eaf334b305fb835956 diff --cc ref-filter.c index ed802778da,c724ff9411..25831e3336 --- a/ref-filter.c +++ b/ref-filter.c @@@ -600,8 -587,23 +601,24 @@@ static int rest_atom_parser(struct ref_ return 0; } + static int ahead_behind_atom_parser(struct ref_format *format, struct used_atom *atom, + const char *arg, struct strbuf *err) + { + struct string_list_item *item; + + if (!arg) + return strbuf_addf_ret(err, -1, _("expected format: %%(ahead-behind:)")); + + item = string_list_append(&format->bases, arg); + item->util = lookup_commit_reference_by_name(arg); + if (!item->util) + die("failed to find '%s'", arg); + + return 0; + } + -static int head_atom_parser(struct ref_format *format, struct used_atom *atom, +static int head_atom_parser(struct ref_format *format UNUSED, + struct used_atom *atom, const char *arg, struct strbuf *err) { if (arg) diff --cc ref-filter.h index daa6d02017,c9a1149517..ae51ace3a2 --- a/ref-filter.h +++ b/ref-filter.h @@@ -4,6 -4,8 +4,7 @@@ #include "oid-array.h" #include "refs.h" #include "commit.h" -#include "parse-options.h" + #include "string-list.h" /* Quoting styles */ #define QUOTE_NONE 0 @@@ -23,7 -25,7 +24,8 @@@ struct atom_value; struct ref_sorting; + struct ahead_behind_count; +struct option; enum ref_sorting_order { REF_SORTING_REVERSE = 1<<0,