gix_merge/commit/
mod.rs

1/// The error returned by [`commit()`](crate::commit()).
2#[derive(Debug, thiserror::Error)]
3#[allow(missing_docs)]
4pub enum Error {
5    #[error("Failed to obtain the merge base between the two commits to be merged")]
6    MergeBase(#[from] gix_revision::merge_base::Error),
7    #[error(transparent)]
8    VirtualMergeBase(#[from] virtual_merge_base::Error),
9    #[error(transparent)]
10    MergeTree(#[from] crate::tree::Error),
11    #[error("No common ancestor between {our_commit_id} and {their_commit_id}")]
12    NoMergeBase {
13        /// The commit on our side that was to be merged.
14        our_commit_id: gix_hash::ObjectId,
15        /// The commit on their side that was to be merged.
16        their_commit_id: gix_hash::ObjectId,
17    },
18    #[error("Could not find ancestor, our or their commit to extract tree from")]
19    FindCommit(#[from] gix_object::find::existing_object::Error),
20}
21
22/// A way to configure [`commit()`](crate::commit()).
23#[derive(Default, Debug, Clone)]
24pub struct Options {
25    /// If `true`, merging unrelated commits is allowed, with the merge-base being assumed as empty tree.
26    pub allow_missing_merge_base: bool,
27    /// Options to define how trees should be merged.
28    pub tree_merge: crate::tree::Options,
29    /// If `true`, do not merge multiple merge-bases into one. Instead, just use the first one.
30    // TODO: test
31    #[doc(alias = "no_recursive", alias = "git2")]
32    pub use_first_merge_base: bool,
33}
34
35/// The result of [`commit()`](crate::commit()).
36#[derive(Clone)]
37pub struct Outcome<'a> {
38    /// The outcome of the actual tree-merge.
39    pub tree_merge: crate::tree::Outcome<'a>,
40    /// The tree id of the base commit we used. This is either…
41    /// * the single merge-base we found
42    /// * the first of multiple merge-bases if [`use_first_merge_base`](Options::use_first_merge_base) was `true`.
43    /// * the merged tree of all merge-bases, which then isn't linked to an actual commit.
44    /// * an empty tree, if [`allow_missing_merge_base`](Options::allow_missing_merge_base) is enabled.
45    pub merge_base_tree_id: gix_hash::ObjectId,
46    /// The object ids of all the commits which were found to be merge-bases, or `None` if there was no merge-base.
47    pub merge_bases: Option<Vec<gix_hash::ObjectId>>,
48    /// A list of virtual commits that were created to merge multiple merge-bases into one, the last one being
49    /// the one we used as merge-base for the merge.
50    /// As they are not reachable by anything they will be garbage collected, but knowing them provides options.
51    /// Would be empty if no virtual commit was needed at all as there was only a single merge-base.
52    /// Otherwise, the last commit id is the one with the `merge_base_tree_id`.
53    pub virtual_merge_bases: Vec<gix_hash::ObjectId>,
54}
55
56pub(super) mod function;
57
58///
59pub mod virtual_merge_base;
60pub use virtual_merge_base::function::virtual_merge_base;