1#ifndef __COMMIT_REACH_H__ 2#define __COMMIT_REACH_H__ 3 4#include "commit-slab.h" 5 6struct commit; 7struct commit_list; 8struct contains_cache; 9struct ref_filter; 10 11struct commit_list *get_merge_bases_many(struct commit *one, 12 int n, 13 struct commit **twos); 14struct commit_list *get_merge_bases_many_dirty(struct commit *one, 15 int n, 16 struct commit **twos); 17struct commit_list *get_merge_bases(struct commit *one, struct commit *two); 18struct commit_list *get_octopus_merge_bases(struct commit_list *in); 19 20/* To be used only when object flags after this call no longer matter */ 21struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n, struct commit **twos); 22 23int is_descendant_of(struct commit *commit, struct commit_list *with_commit); 24int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit **reference); 25int in_merge_bases(struct commit *commit, struct commit *reference); 26 27/* 28 * Takes a list of commits and returns a new list where those 29 * have been removed that can be reached from other commits in 30 * the list. It is useful for, e.g., reducing the commits 31 * randomly thrown at the git-merge command and removing 32 * redundant commits that the user shouldn't have given to it. 33 * 34 * This function destroys the STALE bit of the commit objects' 35 * flags. 36 */ 37struct commit_list *reduce_heads(struct commit_list *heads); 38 39/* 40 * Like `reduce_heads()`, except it replaces the list. Use this 41 * instead of `foo = reduce_heads(foo);` to avoid memory leaks. 42 */ 43void reduce_heads_replace(struct commit_list **heads); 44 45int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid); 46 47/* 48 * Unknown has to be "0" here, because that's the default value for 49 * contains_cache slab entries that have not yet been assigned. 50 */ 51enum contains_result { 52 CONTAINS_UNKNOWN = 0, 53 CONTAINS_NO, 54 CONTAINS_YES 55}; 56 57define_commit_slab(contains_cache, enum contains_result); 58 59int commit_contains(struct ref_filter *filter, struct commit *commit, 60 struct commit_list *list, struct contains_cache *cache); 61 62int reachable(struct commit *from, unsigned int with_flag, 63 unsigned int assign_flag, time_t min_commit_date); 64 65/* 66 * Determine if every commit in 'from' can reach at least one commit 67 * that is marked with 'with_flag'. As we traverse, use 'assign_flag' 68 * as a marker for commits that are already visited. Do not walk 69 * commits with date below 'min_commit_date'. 70 */ 71int can_all_from_reach_with_flag(struct object_array *from, 72 unsigned int with_flag, 73 unsigned int assign_flag, 74 time_t min_commit_date); 75int can_all_from_reach(struct commit_list *from, struct commit_list *to, 76 int commit_date_cutoff); 77 78#endif