]> git.ipfire.org Git - thirdparty/git.git/blame - commit-reach.h
docs: address typos in Git v2.45 changelog
[thirdparty/git.git] / commit-reach.h
CommitLineData
0009d350
RJ
1#ifndef COMMIT_REACH_H
2#define COMMIT_REACH_H
5227c385 3
1406725b 4#include "commit.h"
920f93ca
DS
5#include "commit-slab.h"
6
5227c385 7struct commit_list;
920f93ca 8struct ref_filter;
1406725b
RJ
9struct object_id;
10struct object_array;
5227c385 11
76e2a099
JS
12int repo_get_merge_bases(struct repository *r,
13 struct commit *rev1,
14 struct commit *rev2,
15 struct commit_list **result);
53173805
JS
16int repo_get_merge_bases_many(struct repository *r,
17 struct commit *one, int n,
18 struct commit **twos,
19 struct commit_list **result);
5227c385 20/* To be used only when object flags after this call no longer matter */
caaf1a29
JS
21int repo_get_merge_bases_many_dirty(struct repository *r,
22 struct commit *one, int n,
23 struct commit **twos,
24 struct commit_list **result);
21a9651b 25
f87056ce 26int get_octopus_merge_bases(struct commit_list *in, struct commit_list **result);
5227c385 27
c1ea625f
CMAB
28int repo_is_descendant_of(struct repository *r,
29 struct commit *commit,
30 struct commit_list *with_commit);
4d5430f7
SB
31int repo_in_merge_bases(struct repository *r,
32 struct commit *commit,
33 struct commit *reference);
34int repo_in_merge_bases_many(struct repository *r,
35 struct commit *commit,
207c40e1
JS
36 int nr_reference, struct commit **reference,
37 int ignore_missing_commits);
5227c385 38
5227c385
DS
39/*
40 * Takes a list of commits and returns a new list where those
41 * have been removed that can be reached from other commits in
42 * the list. It is useful for, e.g., reducing the commits
43 * randomly thrown at the git-merge command and removing
44 * redundant commits that the user shouldn't have given to it.
45 *
46 * This function destroys the STALE bit of the commit objects'
47 * flags.
48 */
49struct commit_list *reduce_heads(struct commit_list *heads);
50
51/*
52 * Like `reduce_heads()`, except it replaces the list. Use this
53 * instead of `foo = reduce_heads(foo);` to avoid memory leaks.
54 */
55void reduce_heads_replace(struct commit_list **heads);
56
1d614d41
DS
57int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);
58
920f93ca
DS
59/*
60 * Unknown has to be "0" here, because that's the default value for
61 * contains_cache slab entries that have not yet been assigned.
62 */
63enum contains_result {
64 CONTAINS_UNKNOWN = 0,
65 CONTAINS_NO,
66 CONTAINS_YES
67};
68
69define_commit_slab(contains_cache, enum contains_result);
70
71int commit_contains(struct ref_filter *filter, struct commit *commit,
72 struct commit_list *list, struct contains_cache *cache);
73
ba3ca1ed
DS
74/*
75 * Determine if every commit in 'from' can reach at least one commit
76 * that is marked with 'with_flag'. As we traverse, use 'assign_flag'
77 * as a marker for commits that are already visited. Do not walk
4fbcca4e
DS
78 * commits with date below 'min_commit_date' or generation below
79 * 'min_generation'.
ba3ca1ed
DS
80 */
81int can_all_from_reach_with_flag(struct object_array *from,
82 unsigned int with_flag,
83 unsigned int assign_flag,
4fbcca4e 84 time_t min_commit_date,
d7f92784 85 timestamp_t min_generation);
1792bc12
DS
86int can_all_from_reach(struct commit_list *from, struct commit_list *to,
87 int commit_date_cutoff);
ba3ca1ed 88
fcb2c076
DS
89
90/*
91 * Return a list of commits containing the commits in the 'to' array
92 * that are reachable from at least one commit in the 'from' array.
93 * Also add the given 'flag' to each of the commits in the returned list.
94 *
95 * This method uses the PARENT1 and PARENT2 flags during its operation,
96 * so be sure these flags are not set before calling the method.
97 */
98struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
99 struct commit **to, int nr_to,
100 unsigned int reachable_flag);
101
fd67d149
DS
102struct ahead_behind_count {
103 /**
104 * As input, the *_index members indicate which positions in
105 * the 'tips' array correspond to the tip and base of this
106 * comparison.
107 */
108 size_t tip_index;
109 size_t base_index;
110
111 /**
112 * These values store the computed counts for each side of the
113 * symmetric difference:
114 *
115 * 'ahead' stores the number of commits reachable from the tip
116 * and not reachable from the base.
117 *
118 * 'behind' stores the number of commits reachable from the base
119 * and not reachable from the tip.
120 */
121 unsigned int ahead;
122 unsigned int behind;
123};
124
125/*
126 * Given an array of commits and an array of ahead_behind_count pairs,
127 * compute the ahead/behind counts for each pair.
128 */
129void ahead_behind(struct repository *r,
130 struct commit **commits, size_t commits_nr,
131 struct ahead_behind_count *counts, size_t counts_nr);
132
cbfe360b
DS
133/*
134 * For all tip commits, add 'mark' to their flags if and only if they
135 * are reachable from one of the commits in 'bases'.
136 */
137void tips_reachable_from_bases(struct repository *r,
138 struct commit_list *bases,
139 struct commit **tips, size_t tips_nr,
140 int mark);
141
5227c385 142#endif