Commit ce058b5a authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'merge-command-lifetime'

3e718950 MergeCommand: add a lifetime
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Reviewed-by: Brad King's avatarBrad King <brad.king@kitware.com>
Merge-request: !51
parents 0184b385 3e718950
......@@ -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
files.
# 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 {
self.command
......@@ -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.
Ready(MergeCommand),
#[doc(hidden)]
// Phantom entry which is used to tie a merge result's lifetime to the `GitWorkArea` to which
// it applies.
_Phantom(PhantomData<&'a str>),
Ready(MergeCommand<'a>),
}
/// 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