Skip to content

Commit

Permalink
conflicts: Have materialize_merge_result take the object instead of a…
Browse files Browse the repository at this point in the history
… reference
  • Loading branch information
ilyagr committed Jul 18, 2024
1 parent ba5bfb8 commit dec776a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cli/src/merge_tools/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub fn run_mergetool_external(
) -> Result<MergedTreeId, ConflictResolveError> {
let initial_output_content: Vec<u8> = 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 {
Expand Down
8 changes: 4 additions & 4 deletions lib/src/conflicts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,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
Expand All @@ -215,10 +215,10 @@ async fn materialize_tree_value_no_access_denied(
}

pub fn materialize_merge_result(
single_hunk: &Merge<ContentHunk>,
single_hunk: Merge<ContentHunk>,
output: &mut dyn Write,
) -> std::io::Result<()> {
let merge_result = files::merge(single_hunk);
let merge_result = files::merge(&single_hunk);
match merge_result {
MergeResult::Resolved(content) => {
output.write_all(&content.0)?;
Expand Down Expand Up @@ -501,7 +501,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());
}
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/test_conflicts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

0 comments on commit dec776a

Please sign in to comment.