Commit 3e718950 authored by Ben Boeckel's avatar Ben Boeckel

MergeCommand: add a lifetime

This is required because otherwise the merge command can be extracted
and the workarea dropped leaving the command stranded without a working
parent 0184b385
......@@ -5,6 +5,9 @@
* The `GitWorkArea::checkout` method now requires a mutable reference. This
is because checking out locks the index which means that it cannot be
shared while performing this action.
* The lifetime for merging has been moved to the `MergeCommand` structure.
This prevents the command from outliving the workarea it uses for conflict
# v3.1.2
......@@ -60,12 +60,16 @@ impl PartialEq for Conflict {
/// A command which has been prepared to create a merge commit.
pub struct MergeCommand {
pub struct MergeCommand<'a> {
/// The merge command.
command: Command,
/// Phantom entry which is used to tie a merge command's lifetime to the `GitWorkArea` to which
/// it applies.
_phantom: PhantomData<&'a str>,
impl MergeCommand {
impl<'a> MergeCommand<'a> {
/// Set the committer of the merge.
pub fn committer(&mut self, committer: &Identity) -> &mut Self {
......@@ -128,7 +132,7 @@ impl MergeCommand {
impl Debug for MergeCommand {
impl<'a> Debug for MergeCommand<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "MergeCommand")
......@@ -142,12 +146,7 @@ pub enum MergeResult<'a> {
/// The merge is ready to be committed.
/// The command may be executed in order to create the commit from the merged tree.
// Phantom entry which is used to tie a merge result's lifetime to the `GitWorkArea` to which
// it applies.
_Phantom(PhantomData<&'a str>),
/// The configuration for submodules within the tree.
......@@ -693,6 +692,7 @@ impl GitWorkArea {
Ok(MergeResult::Ready(MergeCommand {
command: commit_tree,
_phantom: PhantomData,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment