summaryrefslogtreecommitdiff
path: root/merge-ort.h
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2020-10-27 02:08:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-10-27 05:36:10 (GMT)
commit17e5574b0446836af08136ae269b30767c05b1d7 (patch)
tree808c721a98bad7891f1c82153a4a2875f121bbf3 /merge-ort.h
parent2e673356aefa8ed19be3c878f966ad6189ecb510 (diff)
downloadgit-17e5574b0446836af08136ae269b30767c05b1d7.zip
git-17e5574b0446836af08136ae269b30767c05b1d7.tar.gz
git-17e5574b0446836af08136ae269b30767c05b1d7.tar.bz2
merge-ort: barebones API of new merge strategy with empty implementation
This is the beginning of a new merge strategy. While there are some API differences, and the implementation has some differences in behavior, it is essentially meant as an eventual drop-in replacement for merge-recursive.c. However, it is being built to exist side-by-side with merge-recursive so that we have plenty of time to find out how those differences pan out in the real world while people can still fall back to merge-recursive. (Also, I intend to avoid modifying merge-recursive during this process, to keep it stable.) The primary difference noticable here is that the updating of the working tree and index is not done simultaneously with the merge algorithm, but is a separate post-processing step. The new API is designed so that one can do repeated merges (e.g. during a rebase or cherry-pick) and only update the index and working tree one time at the end instead of updating it with every intermediate result. Also, one can perform a merge between two branches, neither of which match the index or the working tree, without clobbering the index or working tree. The next three commits will demonstrate various uses of this new API. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-ort.h')
-rw-r--r--merge-ort.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/merge-ort.h b/merge-ort.h
new file mode 100644
index 0000000..74adcca
--- /dev/null
+++ b/merge-ort.h
@@ -0,0 +1,58 @@
+#ifndef MERGE_ORT_H
+#define MERGE_ORT_H
+
+#include "merge-recursive.h"
+
+struct commit;
+struct tree;
+
+struct merge_result {
+ /* Whether the merge is clean */
+ int clean;
+
+ /*
+ * Result of merge. If !clean, represents what would go in worktree
+ * (thus possibly including files containing conflict markers).
+ */
+ struct tree *tree;
+
+ /*
+ * Additional metadata used by merge_switch_to_result() or future calls
+ * to merge_incore_*(). Includes data needed to update the index (if
+ * !clean) and to print "CONFLICT" messages. Not for external use.
+ */
+ void *priv;
+};
+
+/*
+ * rename-detecting three-way merge with recursive ancestor consolidation.
+ * working tree and index are untouched.
+ */
+void merge_incore_recursive(struct merge_options *opt,
+ struct commit_list *merge_bases,
+ struct commit *side1,
+ struct commit *side2,
+ struct merge_result *result);
+
+/*
+ * rename-detecting three-way merge, no recursion.
+ * working tree and index are untouched.
+ */
+void merge_incore_nonrecursive(struct merge_options *opt,
+ struct tree *merge_base,
+ struct tree *side1,
+ struct tree *side2,
+ struct merge_result *result);
+
+/* Update the working tree and index from head to result after incore merge */
+void merge_switch_to_result(struct merge_options *opt,
+ struct tree *head,
+ struct merge_result *result,
+ int update_worktree_and_index,
+ int display_update_msgs);
+
+/* Do needed cleanup when not calling merge_switch_to_result() */
+void merge_finalize(struct merge_options *opt,
+ struct merge_result *result);
+
+#endif