]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ds/ahead-behind'
authorJunio C Hamano <gitster@pobox.com>
Thu, 6 Apr 2023 20:38:21 +0000 (13:38 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 6 Apr 2023 20:38:21 +0000 (13:38 -0700)
"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

1  2 
builtin/tag.c
commit-graph.c
commit-graph.h
commit-reach.c
ref-filter.c
ref-filter.h

diff --cc builtin/tag.c
Simple merge
diff --cc commit-graph.c
Simple merge
diff --cc commit-graph.h
Simple merge
diff --cc commit-reach.c
Simple merge
diff --cc ref-filter.c
index ed802778da7208377d9054f2de1805f91be39509,c724ff941132c3dba55634bf4b22524229dbe460..25831e3336470a73656135c31b0a8100fc6971a8
@@@ -600,8 -587,23 +601,24 @@@ static int rest_atom_parser(struct ref_
        return 0;
  }
  
 -static int head_atom_parser(struct ref_format *format, struct used_atom *atom,
+ 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:<committish>)"));
+       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 UNUSED,
 +                          struct used_atom *atom,
                            const char *arg, struct strbuf *err)
  {
        if (arg)
diff --cc ref-filter.h
index daa6d02017489d5b6454790503afaa0b6079a08e,c9a1149517797d34c843e5904145a4f6259cc32d..ae51ace3a2099427daee953a1b778542d94361ec
@@@ -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,