From 455804d1ea2f7fd3701d4cd430aa3d4089baf7b2 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Wed, 26 Jun 2024 15:24:13 -0700 Subject: [PATCH] conflicts: Have materialize_merge_result take the object instead of a reference We are about to do some pre-processing of that value, and we will do more in the near future. --- cli/src/merge_tools/external.rs | 2 +- lib/src/conflicts.rs | 6 +++--- lib/tests/test_conflicts.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cli/src/merge_tools/external.rs b/cli/src/merge_tools/external.rs index 3025f376db7..9ac546c3525 100644 --- a/cli/src/merge_tools/external.rs +++ b/cli/src/merge_tools/external.rs @@ -144,7 +144,7 @@ pub fn run_mergetool_external( ) -> Result { let initial_output_content: Vec = if editor.merge_tool_edits_conflict_markers { let mut materialized_conflict = vec![]; - materialize_merge_result(&content, &mut materialized_conflict) + materialize_merge_result(content.clone(), &mut materialized_conflict) .expect("Writing to an in-memory buffer should never fail"); materialized_conflict } else { diff --git a/lib/src/conflicts.rs b/lib/src/conflicts.rs index bb7a60f2255..1ffd73ea1da 100644 --- a/lib/src/conflicts.rs +++ b/lib/src/conflicts.rs @@ -190,7 +190,7 @@ async fn materialize_tree_value_no_access_denied( if let Some(file_merge) = conflict.to_file_merge() { let file_merge = file_merge.simplify(); let content = extract_as_single_hunk(&file_merge, store, path).await?; - materialize_merge_result(&content, &mut contents) + materialize_merge_result(content, &mut contents) .expect("Failed to materialize conflict to in-memory buffer"); } else { // Unless all terms are regular files, we can't do much better than to try to @@ -214,7 +214,7 @@ async fn materialize_tree_value_no_access_denied( } pub fn materialize_merge_result( - single_hunk: &Merge, + single_hunk: Merge, output: &mut dyn Write, ) -> std::io::Result<()> { let slices = single_hunk.map(|content| content.0.as_slice()); @@ -477,7 +477,7 @@ pub async fn update_from_content( // copy. let mut old_content = Vec::with_capacity(content.len()); let merge_hunk = extract_as_single_hunk(simplified_file_ids, store, path).await?; - materialize_merge_result(&merge_hunk, &mut old_content).unwrap(); + materialize_merge_result(merge_hunk, &mut old_content).unwrap(); if content == old_content { return Ok(file_ids.clone()); } diff --git a/lib/tests/test_conflicts.rs b/lib/tests/test_conflicts.rs index 7f37b81f108..79325b1e106 100644 --- a/lib/tests/test_conflicts.rs +++ b/lib/tests/test_conflicts.rs @@ -1000,6 +1000,6 @@ fn materialize_conflict_string( let contents = extract_as_single_hunk(conflict, store, path) .block_on() .unwrap(); - materialize_merge_result(&contents, &mut result).unwrap(); + materialize_merge_result(contents, &mut result).unwrap(); String::from_utf8(result).unwrap() }