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