ok/jj
1
0
Fork 0
forked from mirrors/jj

working_copy: reduce scope of a content variable

This also avoids reading non-file conflict from disk.
This commit is contained in:
Martin von Zweigbergk 2023-08-11 21:52:17 -07:00 committed by Martin von Zweigbergk
parent 585c212617
commit 33a93b6d2d

View file

@ -966,14 +966,14 @@ impl TreeState {
if let (Some(TreeValue::Conflict(conflict_id)), FileType::Normal { executable }) =
(&current_tree_value, &file_type)
{
let mut file = File::open(disk_path).map_err(|err| SnapshotError::IoError {
message: format!("Failed to open file {}", disk_path.display()),
err,
})?;
let mut content = vec![];
file.read_to_end(&mut content).unwrap();
let conflict = self.store.read_conflict(repo_path, conflict_id)?;
if let Some(old_file_ids) = conflict.to_file_merge() {
let mut file = File::open(disk_path).map_err(|err| SnapshotError::IoError {
message: format!("Failed to open file {}", disk_path.display()),
err,
})?;
let mut content = vec![];
file.read_to_end(&mut content).unwrap();
let new_file_ids = conflicts::update_from_content(
&old_file_ids,
self.store.as_ref(),