commit-reach.hon commit conditional markdown preprocessing (c8b1cd9)
   1#ifndef COMMIT_REACH_H
   2#define COMMIT_REACH_H
   3
   4#include "commit.h"
   5#include "commit-slab.h"
   6
   7struct commit_list;
   8struct ref_filter;
   9struct object_id;
  10struct object_array;
  11
  12struct commit_list *repo_get_merge_bases(struct repository *r,
  13                                         struct commit *rev1,
  14                                         struct commit *rev2);
  15struct commit_list *repo_get_merge_bases_many(struct repository *r,
  16                                              struct commit *one, int n,
  17                                              struct commit **twos);
  18/* To be used only when object flags after this call no longer matter */
  19struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r,
  20                                                    struct commit *one, int n,
  21                                                    struct commit **twos);
  22#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
  23#define get_merge_bases(r1, r2)           repo_get_merge_bases(the_repository, r1, r2)
  24#define get_merge_bases_many(one, n, two) repo_get_merge_bases_many(the_repository, one, n, two)
  25#define get_merge_bases_many_dirty(one, n, twos) repo_get_merge_bases_many_dirty(the_repository, one, n, twos)
  26#endif
  27
  28struct commit_list *get_octopus_merge_bases(struct commit_list *in);
  29
  30int is_descendant_of(struct commit *commit, struct commit_list *with_commit);
  31int repo_in_merge_bases(struct repository *r,
  32                        struct commit *commit,
  33                        struct commit *reference);
  34int repo_in_merge_bases_many(struct repository *r,
  35                             struct commit *commit,
  36                             int nr_reference, struct commit **reference);
  37#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
  38#define in_merge_bases(c1, c2) repo_in_merge_bases(the_repository, c1, c2)
  39#define in_merge_bases_many(c1, n, cs) repo_in_merge_bases_many(the_repository, c1, n, cs)
  40#endif
  41
  42/*
  43 * Takes a list of commits and returns a new list where those
  44 * have been removed that can be reached from other commits in
  45 * the list. It is useful for, e.g., reducing the commits
  46 * randomly thrown at the git-merge command and removing
  47 * redundant commits that the user shouldn't have given to it.
  48 *
  49 * This function destroys the STALE bit of the commit objects'
  50 * flags.
  51 */
  52struct commit_list *reduce_heads(struct commit_list *heads);
  53
  54/*
  55 * Like `reduce_heads()`, except it replaces the list. Use this
  56 * instead of `foo = reduce_heads(foo);` to avoid memory leaks.
  57 */
  58void reduce_heads_replace(struct commit_list **heads);
  59
  60int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);
  61
  62/*
  63 * Unknown has to be "0" here, because that's the default value for
  64 * contains_cache slab entries that have not yet been assigned.
  65 */
  66enum contains_result {
  67        CONTAINS_UNKNOWN = 0,
  68        CONTAINS_NO,
  69        CONTAINS_YES
  70};
  71
  72define_commit_slab(contains_cache, enum contains_result);
  73
  74int commit_contains(struct ref_filter *filter, struct commit *commit,
  75                    struct commit_list *list, struct contains_cache *cache);
  76
  77/*
  78 * Determine if every commit in 'from' can reach at least one commit
  79 * that is marked with 'with_flag'. As we traverse, use 'assign_flag'
  80 * as a marker for commits that are already visited. Do not walk
  81 * commits with date below 'min_commit_date' or generation below
  82 * 'min_generation'.
  83 */
  84int can_all_from_reach_with_flag(struct object_array *from,
  85                                 unsigned int with_flag,
  86                                 unsigned int assign_flag,
  87                                 time_t min_commit_date,
  88                                 uint32_t min_generation);
  89int can_all_from_reach(struct commit_list *from, struct commit_list *to,
  90                       int commit_date_cutoff);
  91
  92
  93/*
  94 * Return a list of commits containing the commits in the 'to' array
  95 * that are reachable from at least one commit in the 'from' array.
  96 * Also add the given 'flag' to each of the commits in the returned list.
  97 *
  98 * This method uses the PARENT1 and PARENT2 flags during its operation,
  99 * so be sure these flags are not set before calling the method.
 100 */
 101struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
 102                                         struct commit **to, int nr_to,
 103                                         unsigned int reachable_flag);
 104
 105#endif