Merge branch 'sg/test-BUG'
[git.git] / commit-reach.h
blobfb8082a2ece94a94cf2f9a55ba95950caa41a914
1 #ifndef COMMIT_REACH_H
2 #define COMMIT_REACH_H
4 #include "commit.h"
5 #include "commit-slab.h"
7 struct commit_list;
8 struct ref_filter;
9 struct object_id;
10 struct object_array;
12 struct commit_list *get_merge_bases_many(struct commit *one,
13 int n,
14 struct commit **twos);
15 struct commit_list *get_merge_bases_many_dirty(struct commit *one,
16 int n,
17 struct commit **twos);
18 struct commit_list *get_merge_bases(struct commit *one, struct commit *two);
19 struct commit_list *get_octopus_merge_bases(struct commit_list *in);
21 /* To be used only when object flags after this call no longer matter */
22 struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n, struct commit **twos);
24 int is_descendant_of(struct commit *commit, struct commit_list *with_commit);
25 int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit **reference);
26 int in_merge_bases(struct commit *commit, struct commit *reference);
29 * Takes a list of commits and returns a new list where those
30 * have been removed that can be reached from other commits in
31 * the list. It is useful for, e.g., reducing the commits
32 * randomly thrown at the git-merge command and removing
33 * redundant commits that the user shouldn't have given to it.
35 * This function destroys the STALE bit of the commit objects'
36 * flags.
38 struct commit_list *reduce_heads(struct commit_list *heads);
41 * Like `reduce_heads()`, except it replaces the list. Use this
42 * instead of `foo = reduce_heads(foo);` to avoid memory leaks.
44 void reduce_heads_replace(struct commit_list **heads);
46 int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);
49 * Unknown has to be "0" here, because that's the default value for
50 * contains_cache slab entries that have not yet been assigned.
52 enum contains_result {
53 CONTAINS_UNKNOWN = 0,
54 CONTAINS_NO,
55 CONTAINS_YES
58 define_commit_slab(contains_cache, enum contains_result);
60 int commit_contains(struct ref_filter *filter, struct commit *commit,
61 struct commit_list *list, struct contains_cache *cache);
64 * Determine if every commit in 'from' can reach at least one commit
65 * that is marked with 'with_flag'. As we traverse, use 'assign_flag'
66 * as a marker for commits that are already visited. Do not walk
67 * commits with date below 'min_commit_date' or generation below
68 * 'min_generation'.
70 int can_all_from_reach_with_flag(struct object_array *from,
71 unsigned int with_flag,
72 unsigned int assign_flag,
73 time_t min_commit_date,
74 uint32_t min_generation);
75 int can_all_from_reach(struct commit_list *from, struct commit_list *to,
76 int commit_date_cutoff);
80 * Return a list of commits containing the commits in the 'to' array
81 * that are reachable from at least one commit in the 'from' array.
82 * Also add the given 'flag' to each of the commits in the returned list.
84 * This method uses the PARENT1 and PARENT2 flags during its operation,
85 * so be sure these flags are not set before calling the method.
87 struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
88 struct commit **to, int nr_to,
89 unsigned int reachable_flag);
91 #endif