pub fn commit<'objects>(
our_commit: ObjectId,
their_commit: ObjectId,
labels: Labels<'_>,
graph: &mut Graph<'_, '_, Commit<Flags>>,
diff_resource_cache: &mut Platform,
blob_merge: &mut Platform,
objects: &'objects (impl FindObjectOrHeader + Write),
abbreviate_hash: &mut dyn FnMut(&oid) -> String,
options: Options,
) -> Result<Outcome<'objects>, Error>Expand description
Like tree(), but it takes only two commits, our_commit and their_commit to automatically
compute the merge-bases among them.
If there are multiple merge bases, these will be auto-merged into one, recursively, if
allow_missing_merge_base is true.
labels are names where current is a name for our_commit
and other is a name for their_commit.
If ancestor is unset, it will be set by us based on the
merge-bases of our_commit and their_commit.
The graph is used to find the merge-base between our_commit and their_commit, and can also act as cache
to speed up subsequent merge-base queries.
Use abbreviate_hash(id) to shorten the given id according to standard git shortening rules. It’s used in case
the ancestor-label isn’t explicitly set so that the merge base label becomes the shortened id.
Note that it’s a dyn closure only to make it possible to recursively call this function in case of multiple merge-bases.
write_object is used only if it’s allowed to merge multiple merge-bases into one, and if there
are multiple merge bases, and to write merged buffers as blobs.
§Performance
Note that objects should have an object cache to greatly accelerate tree-retrieval.
§Notes
When merging merge-bases recursively, the options are adjusted automatically to act like Git, i.e. merge binary blobs and resolve with ours, while resorting to using the base/ancestor in case of unresolvable conflicts.
§Deviation
- It’s known that certain conflicts around symbolic links can be auto-resolved. We don’t have an option for this at all, yet, primarily as Git seems to not implement the ours/theirs choice in other places even though it reasonably could. So we leave it to the caller to continue processing the returned tree at will.