]> git.ipfire.org Git - thirdparty/git.git/blame - commit-reach.h
commit-reach: prepare in_merge_bases[_many] to handle any repo
[thirdparty/git.git] / commit-reach.h
CommitLineData
5227c385
DS
1#ifndef __COMMIT_REACH_H__
2#define __COMMIT_REACH_H__
3
920f93ca
DS
4#include "commit-slab.h"
5
5227c385
DS
6struct commit;
7struct commit_list;
920f93ca
DS
8struct contains_cache;
9struct ref_filter;
5227c385 10
21a9651b
SB
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);
5227c385 17/* To be used only when object flags after this call no longer matter */
21a9651b
SB
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);
5227c385
DS
28
29int is_descendant_of(struct commit *commit, struct commit_list *with_commit);
4d5430f7
SB
30int repo_in_merge_bases(struct repository *r,
31 struct commit *commit,
32 struct commit *reference);
33int repo_in_merge_bases_many(struct repository *r,
34 struct commit *commit,
35 int 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
5227c385 40
5227c385
DS
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 */
57void reduce_heads_replace(struct commit_list **heads);
58
1d614d41
DS
59int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);
60
920f93ca
DS
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
73int commit_contains(struct ref_filter *filter, struct commit *commit,
74 struct commit_list *list, struct contains_cache *cache);
75
ba3ca1ed
DS
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
4fbcca4e
DS
80 * commits with date below 'min_commit_date' or generation below
81 * 'min_generation'.
ba3ca1ed
DS
82 */
83int can_all_from_reach_with_flag(struct object_array *from,
84 unsigned int with_flag,
85 unsigned int assign_flag,
4fbcca4e
DS
86 time_t min_commit_date,
87 uint32_t min_generation);
1792bc12
DS
88int can_all_from_reach(struct commit_list *from, struct commit_list *to,
89 int commit_date_cutoff);
ba3ca1ed 90
5227c385 91#endif