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, 12struct commit *rev1, 13struct commit *rev2); 14struct commit_list *repo_get_merge_bases_many(struct repository *r, 15struct commit *one,int n, 16struct 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, 19struct commit *one,int n, 20struct 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 29intis_descendant_of(struct commit *commit,struct commit_list *with_commit); 30intrepo_in_merge_bases(struct repository *r, 31struct commit *commit, 32struct commit *reference); 33intrepo_in_merge_bases_many(struct repository *r, 34struct commit *commit, 35int nr_reference,struct commit **reference); 36#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS 37#define in_merge_bases(c1, c2) repo_in_merge_bases(the_repository, c1, c2) 38#define in_merge_bases_many(c1, n, cs) repo_in_merge_bases_many(the_repository, c1, n, cs) 39#endif 40 41/* 42 * Takes a list of commits and returns a new list where those 43 * have been removed that can be reached from other commits in 44 * the list. It is useful for, e.g., reducing the commits 45 * randomly thrown at the git-merge command and removing 46 * redundant commits that the user shouldn't have given to it. 47 * 48 * This function destroys the STALE bit of the commit objects' 49 * flags. 50 */ 51struct commit_list *reduce_heads(struct commit_list *heads); 52 53/* 54 * Like `reduce_heads()`, except it replaces the list. Use this 55 * instead of `foo = reduce_heads(foo);` to avoid memory leaks. 56 */ 57voidreduce_heads_replace(struct commit_list **heads); 58 59intref_newer(const struct object_id *new_oid,const struct object_id *old_oid); 60 61/* 62 * Unknown has to be "0" here, because that's the default value for 63 * contains_cache slab entries that have not yet been assigned. 64 */ 65enum contains_result { 66 CONTAINS_UNKNOWN =0, 67 CONTAINS_NO, 68 CONTAINS_YES 69}; 70 71define_commit_slab(contains_cache,enum contains_result); 72 73intcommit_contains(struct ref_filter *filter,struct commit *commit, 74struct commit_list *list,struct contains_cache *cache); 75 76/* 77 * Determine if every commit in 'from' can reach at least one commit 78 * that is marked with 'with_flag'. As we traverse, use 'assign_flag' 79 * as a marker for commits that are already visited. Do not walk 80 * commits with date below 'min_commit_date' or generation below 81 * 'min_generation'. 82 */ 83intcan_all_from_reach_with_flag(struct object_array *from, 84unsigned int with_flag, 85unsigned int assign_flag, 86time_t min_commit_date, 87uint32_t min_generation); 88intcan_all_from_reach(struct commit_list *from,struct commit_list *to, 89int commit_date_cutoff); 90 91#endif