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

We are about to do some pre-processing of that value, and we
will do more in the near future.
  • Loading branch information
ilyagr committed Jun 28, 2024
1 parent e483410 commit a578e1c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 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 @@ -131,7 +131,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
6 changes: 3 additions & 3 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,7 +215,7 @@ 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 slices = single_hunk.map(|content| content.0.as_slice());
Expand Down Expand Up @@ -461,7 +461,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 @@ -1024,6 +1024,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 a578e1c

Please sign in to comment.