Skip to content

Commit b5c5a44

Browse files
committed
working_copy: set MaterializedConflictData by caller of write_conflict()
Since file stats and conflict metadata are calculated from different sources, it's simpler to initialize FileState without MaterializedConflictData.
1 parent 3654b8b commit b5c5a44

File tree

1 file changed

+11
-30
lines changed

1 file changed

+11
-30
lines changed

lib/src/local_working_copy.rs

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -200,18 +200,13 @@ impl FileState {
200200
}
201201
}
202202

203-
fn for_file(
204-
executable: bool,
205-
size: u64,
206-
metadata: &Metadata,
207-
materialized_conflict_data: Option<MaterializedConflictData>,
208-
) -> Self {
203+
fn for_file(executable: bool, size: u64, metadata: &Metadata) -> Self {
209204
let executable = FileExecutableFlag::from_bool_lossy(executable);
210205
Self {
211206
file_type: FileType::Normal { executable },
212207
mtime: mtime_from_metadata(metadata),
213208
size,
214-
materialized_conflict_data,
209+
materialized_conflict_data: None,
215210
}
216211
}
217212

@@ -1743,12 +1738,7 @@ impl TreeState {
17431738
let metadata = file
17441739
.metadata()
17451740
.map_err(|err| checkout_error_for_stat_error(err, disk_path))?;
1746-
Ok(FileState::for_file(
1747-
executable,
1748-
size as u64,
1749-
&metadata,
1750-
None,
1751-
))
1741+
Ok(FileState::for_file(executable, size as u64, &metadata))
17521742
}
17531743

17541744
fn write_symlink(&self, disk_path: &Path, target: String) -> Result<FileState, CheckoutError> {
@@ -1772,7 +1762,6 @@ impl TreeState {
17721762
disk_path: &Path,
17731763
contents: &[u8],
17741764
executable: bool,
1775-
materialized_conflict_data: Option<MaterializedConflictData>,
17761765
) -> Result<FileState, CheckoutError> {
17771766
let contents = self
17781767
.target_eol_strategy
@@ -1800,12 +1789,7 @@ impl TreeState {
18001789
let metadata = file
18011790
.metadata()
18021791
.map_err(|err| checkout_error_for_stat_error(err, disk_path))?;
1803-
Ok(FileState::for_file(
1804-
executable,
1805-
size,
1806-
&metadata,
1807-
materialized_conflict_data,
1808-
))
1792+
Ok(FileState::for_file(executable, size, &metadata))
18091793
}
18101794

18111795
#[cfg_attr(windows, allow(unused_variables))]
@@ -1997,23 +1981,20 @@ impl TreeState {
19971981
conflict_marker_style,
19981982
conflict_marker_len,
19991983
);
2000-
let materialized_conflict_data = MaterializedConflictData {
1984+
let mut file_state = self
1985+
.write_conflict(&disk_path, &contents, file.executable.unwrap_or(false))
1986+
.await?;
1987+
file_state.materialized_conflict_data = Some(MaterializedConflictData {
20011988
conflict_marker_len: conflict_marker_len.try_into().unwrap_or(u32::MAX),
2002-
};
2003-
self.write_conflict(
2004-
&disk_path,
2005-
&contents,
2006-
file.executable.unwrap_or(false),
2007-
Some(materialized_conflict_data),
2008-
)
2009-
.await?
1989+
});
1990+
file_state
20101991
}
20111992
MaterializedTreeValue::OtherConflict { id } => {
20121993
// Unless all terms are regular files, we can't do much
20131994
// better than trying to describe the merge.
20141995
let contents = id.describe();
20151996
let executable = false;
2016-
self.write_conflict(&disk_path, contents.as_bytes(), executable, None)
1997+
self.write_conflict(&disk_path, contents.as_bytes(), executable)
20171998
.await?
20181999
}
20192000
};

0 commit comments

Comments
 (0)