@@ -18,16 +18,16 @@ pub enum Error {
18
18
}
19
19
20
20
/// A way to configure [`commit()`](crate::commit()).
21
- #[ derive( Default , Debug , Copy , Clone ) ]
21
+ #[ derive( Default , Debug , Clone ) ]
22
22
pub struct Options {
23
23
/// If `true`, merging unrelated commits is allowed, with the merge-base being assumed as empty tree.
24
24
pub allow_missing_merge_base : bool ,
25
25
/// Options to define how trees should be merged.
26
26
pub tree_merge : crate :: tree:: Options ,
27
- /// Options to define how to merge blobs .
28
- ///
29
- /// Note that these are temporarily overwritten if multiple merge-bases are merged into one.
30
- pub blob_merge : crate :: blob :: platform :: merge :: Options ,
27
+ /// If `true`, do not merge multiple merge-bases into one. Instead, just use the first one .
28
+ // TODO: test
29
+ # [ doc ( alias = "no_recursive" , alias = "git2" ) ]
30
+ pub use_first_merge_base : bool ,
31
31
}
32
32
33
33
pub ( super ) mod function {
@@ -51,21 +51,29 @@ pub(super) mod function {
51
51
///
52
52
/// Note that `objects` *should* have an object cache to greatly accelerate tree-retrieval.
53
53
#[ allow( clippy:: too_many_arguments) ]
54
- pub fn commit < ' objects > (
54
+ pub fn commit < ' objects , E > (
55
55
our_commit : gix_hash:: ObjectId ,
56
56
their_commit : gix_hash:: ObjectId ,
57
57
mut labels : crate :: blob:: builtin_driver:: text:: Labels < ' _ > ,
58
58
graph : & mut gix_revwalk:: Graph < ' _ , ' _ , gix_revwalk:: graph:: Commit < gix_revision:: merge_base:: Flags > > ,
59
59
diff_resource_cache : & mut gix_diff:: blob:: Platform ,
60
60
blob_merge : & mut crate :: blob:: Platform ,
61
61
objects : & ' objects impl gix_object:: FindObjectOrHeader ,
62
+ write_blob_to_odb : impl FnMut ( & [ u8 ] ) -> Result < gix_hash:: ObjectId , E > ,
62
63
options : Options ,
63
- ) -> Result < crate :: tree:: Outcome < ' objects > , Error > {
64
+ ) -> Result < crate :: tree:: Outcome < ' objects > , Error >
65
+ where
66
+ E : Into < Box < dyn std:: error:: Error + Send + Sync + ' static > > ,
67
+ {
64
68
let merge_bases_commit_ids = gix_revision:: merge_base ( our_commit, & [ their_commit] , graph) ?;
65
69
let ( merge_base_commit_id, ancestor_name) = match merge_bases_commit_ids {
66
70
Some ( base_commit) if base_commit. len ( ) == 1 => ( base_commit[ 0 ] , None ) ,
67
71
Some ( base_commits) => {
68
- let virtual_base_tree = * base_commits. first ( ) . expect ( "TODO: merge multiple bases into one" ) ;
72
+ let virtual_base_tree = if options. use_first_merge_base {
73
+ * base_commits. first ( ) . expect ( "TODO: merge multiple bases into one" )
74
+ } else {
75
+ todo ! ( "merge multiple merge bases" )
76
+ } ;
69
77
( virtual_base_tree, Some ( "merged common ancestors" . into ( ) ) )
70
78
}
71
79
None => {
@@ -97,6 +105,7 @@ pub(super) mod function {
97
105
& their_tree_id,
98
106
labels,
99
107
objects,
108
+ write_blob_to_odb,
100
109
& mut state,
101
110
diff_resource_cache,
102
111
blob_merge,
0 commit comments