path: root/commit-reach.h
diff options
authorDerrick Stolee <>2018-07-20 16:33:02 (GMT)
committerJunio C Hamano <>2018-07-20 22:38:54 (GMT)
commit5227c385667cadd3b34668329016755181fa98ea (patch)
treec6c414608bd5f050dd837be44444087d5ad20c16 /commit-reach.h
parentdade47c06cf849b0ca180a8e6383b55ea6f75812 (diff)
commit-reach: move walk methods from commit.c
There are several commit walks in the codebase. Group them together into a new commit-reach.c file and corresponding header. After we group these walks into one place, we can reduce duplicate logic by calling equivalent methods. The method declarations in commit.h are not touched by this commit and will be moved in a following commit. Many consumers need to point to commit-reach.h and that would bloat this commit. Signed-off-by: Derrick Stolee <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'commit-reach.h')
1 files changed, 42 insertions, 0 deletions
diff --git a/commit-reach.h b/commit-reach.h
new file mode 100644
index 0000000..1ea2696
--- /dev/null
+++ b/commit-reach.h
@@ -0,0 +1,42 @@
+#ifndef __COMMIT_REACH_H__
+#define __COMMIT_REACH_H__
+struct commit;
+struct commit_list;
+struct commit_list *get_merge_bases_many(struct commit *one,
+ int n,
+ struct commit **twos);
+struct commit_list *get_merge_bases_many_dirty(struct commit *one,
+ int n,
+ struct commit **twos);
+struct commit_list *get_merge_bases(struct commit *one, struct commit *two);
+struct commit_list *get_octopus_merge_bases(struct commit_list *in);
+/* To be used only when object flags after this call no longer matter */
+struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n, struct commit **twos);
+int is_descendant_of(struct commit *commit, struct commit_list *with_commit);
+int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit **reference);
+int in_merge_bases(struct commit *commit, struct commit *reference);
+ * Takes a list of commits and returns a new list where those
+ * have been removed that can be reached from other commits in
+ * the list. It is useful for, e.g., reducing the commits
+ * randomly thrown at the git-merge command and removing
+ * redundant commits that the user shouldn't have given to it.
+ *
+ * This function destroys the STALE bit of the commit objects'
+ * flags.
+ */
+struct commit_list *reduce_heads(struct commit_list *heads);
+ * Like `reduce_heads()`, except it replaces the list. Use this
+ * instead of `foo = reduce_heads(foo);` to avoid memory leaks.
+ */
+void reduce_heads_replace(struct commit_list **heads);