test-reach: create new test tool for ref_newer
[git/raj.git] / commit-reach.h
blobb28bc22fcd4b426310b4a1feb40b13d15b766b62
1 #ifndef __COMMIT_REACH_H__
2 #define __COMMIT_REACH_H__
4 #include "commit-slab.h"
6 struct commit;
7 struct commit_list;
8 struct contains_cache;
9 struct ref_filter;
11 struct commit_list *get_merge_bases_many(struct commit *one,
12 int n,
13 struct commit **twos);
14 struct commit_list *get_merge_bases_many_dirty(struct commit *one,
15 int n,
16 struct commit **twos);
17 struct commit_list *get_merge_bases(struct commit *one, struct commit *two);
18 struct commit_list *get_octopus_merge_bases(struct commit_list *in);
20 /* To be used only when object flags after this call no longer matter */
21 struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n, struct commit **twos);
23 int is_descendant_of(struct commit *commit, struct commit_list *with_commit);
24 int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit **reference);
25 int in_merge_bases(struct commit *commit, struct commit *reference);
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.
34 * This function destroys the STALE bit of the commit objects'
35 * flags.
37 struct commit_list *reduce_heads(struct commit_list *heads);
40 * Like `reduce_heads()`, except it replaces the list. Use this
41 * instead of `foo = reduce_heads(foo);` to avoid memory leaks.
43 void reduce_heads_replace(struct commit_list **heads);
45 int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);
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.
51 enum contains_result {
52 CONTAINS_UNKNOWN = 0,
53 CONTAINS_NO,
54 CONTAINS_YES
57 define_commit_slab(contains_cache, enum contains_result);
59 int commit_contains(struct ref_filter *filter, struct commit *commit,
60 struct commit_list *list, struct contains_cache *cache);
62 int reachable(struct commit *from, unsigned int with_flag,
63 unsigned int assign_flag, time_t min_commit_date);
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'.
71 int 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);
76 #endif