mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-29 23:57:51 +00:00
annotate: remove redundant .is_absent() test from get_file_contents()
Some checks are pending
binaries / Build binary artifacts (linux-aarch64-gnu, ubuntu-24.04, aarch64-unknown-linux-gnu) (push) Waiting to run
binaries / Build binary artifacts (linux-aarch64-musl, ubuntu-24.04, aarch64-unknown-linux-musl) (push) Waiting to run
binaries / Build binary artifacts (linux-x86_64-gnu, ubuntu-24.04, x86_64-unknown-linux-gnu) (push) Waiting to run
binaries / Build binary artifacts (linux-x86_64-musl, ubuntu-24.04, x86_64-unknown-linux-musl) (push) Waiting to run
binaries / Build binary artifacts (macos-aarch64, macos-14, aarch64-apple-darwin) (push) Waiting to run
binaries / Build binary artifacts (macos-x86_64, macos-13, x86_64-apple-darwin) (push) Waiting to run
binaries / Build binary artifacts (win-x86_64, windows-2022, x86_64-pc-windows-msvc) (push) Waiting to run
nix / flake check (macos-14) (push) Waiting to run
nix / flake check (ubuntu-latest) (push) Waiting to run
build / build (, macos-13) (push) Waiting to run
build / build (, macos-14) (push) Waiting to run
build / build (, ubuntu-latest) (push) Waiting to run
build / build (, windows-latest) (push) Waiting to run
build / build (--all-features, ubuntu-latest) (push) Waiting to run
build / Build jj-lib without Git support (push) Waiting to run
build / Check protos (push) Waiting to run
build / Check formatting (push) Waiting to run
build / Check that MkDocs can build the docs (push) Waiting to run
build / Check that MkDocs can build the docs with Poetry 1.8 (push) Waiting to run
build / cargo-deny (advisories) (push) Waiting to run
build / cargo-deny (bans licenses sources) (push) Waiting to run
build / Clippy check (push) Waiting to run
Codespell / Codespell (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-latest) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Some checks are pending
binaries / Build binary artifacts (linux-aarch64-gnu, ubuntu-24.04, aarch64-unknown-linux-gnu) (push) Waiting to run
binaries / Build binary artifacts (linux-aarch64-musl, ubuntu-24.04, aarch64-unknown-linux-musl) (push) Waiting to run
binaries / Build binary artifacts (linux-x86_64-gnu, ubuntu-24.04, x86_64-unknown-linux-gnu) (push) Waiting to run
binaries / Build binary artifacts (linux-x86_64-musl, ubuntu-24.04, x86_64-unknown-linux-musl) (push) Waiting to run
binaries / Build binary artifacts (macos-aarch64, macos-14, aarch64-apple-darwin) (push) Waiting to run
binaries / Build binary artifacts (macos-x86_64, macos-13, x86_64-apple-darwin) (push) Waiting to run
binaries / Build binary artifacts (win-x86_64, windows-2022, x86_64-pc-windows-msvc) (push) Waiting to run
nix / flake check (macos-14) (push) Waiting to run
nix / flake check (ubuntu-latest) (push) Waiting to run
build / build (, macos-13) (push) Waiting to run
build / build (, macos-14) (push) Waiting to run
build / build (, ubuntu-latest) (push) Waiting to run
build / build (, windows-latest) (push) Waiting to run
build / build (--all-features, ubuntu-latest) (push) Waiting to run
build / Build jj-lib without Git support (push) Waiting to run
build / Check protos (push) Waiting to run
build / Check formatting (push) Waiting to run
build / Check that MkDocs can build the docs (push) Waiting to run
build / Check that MkDocs can build the docs with Poetry 1.8 (push) Waiting to run
build / cargo-deny (advisories) (push) Waiting to run
build / cargo-deny (bans licenses sources) (push) Waiting to run
build / Clippy check (push) Waiting to run
Codespell / Codespell (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-latest) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Here we shouldn't care whether the file value is absent or a tree, for example.
This commit is contained in:
parent
d6026e46e9
commit
89a0f46986
1 changed files with 24 additions and 28 deletions
|
@ -251,34 +251,30 @@ fn get_file_contents(
|
|||
tree: &MergedTree,
|
||||
) -> Result<Vec<u8>, BackendError> {
|
||||
let file_value = tree.path_value(path)?;
|
||||
if file_value.is_absent() {
|
||||
Ok(Vec::new())
|
||||
} else {
|
||||
let effective_file_value = materialize_tree_value(store, path, file_value).block_on()?;
|
||||
match effective_file_value {
|
||||
MaterializedTreeValue::File { mut reader, id, .. } => {
|
||||
let mut file_contents = Vec::new();
|
||||
reader
|
||||
.read_to_end(&mut file_contents)
|
||||
.map_err(|e| BackendError::ReadFile {
|
||||
path: path.to_owned(),
|
||||
id,
|
||||
source: Box::new(e),
|
||||
})?;
|
||||
Ok(file_contents)
|
||||
}
|
||||
MaterializedTreeValue::FileConflict { id, contents, .. } => {
|
||||
let mut materialized_conflict_buffer = Vec::new();
|
||||
materialize_merge_result(&contents, &mut materialized_conflict_buffer).map_err(
|
||||
|io_err| BackendError::ReadFile {
|
||||
path: path.to_owned(),
|
||||
source: Box::new(io_err),
|
||||
id: id.first().clone().unwrap(),
|
||||
},
|
||||
)?;
|
||||
Ok(materialized_conflict_buffer)
|
||||
}
|
||||
_ => Ok(Vec::new()),
|
||||
let effective_file_value = materialize_tree_value(store, path, file_value).block_on()?;
|
||||
match effective_file_value {
|
||||
MaterializedTreeValue::File { mut reader, id, .. } => {
|
||||
let mut file_contents = Vec::new();
|
||||
reader
|
||||
.read_to_end(&mut file_contents)
|
||||
.map_err(|e| BackendError::ReadFile {
|
||||
path: path.to_owned(),
|
||||
id,
|
||||
source: Box::new(e),
|
||||
})?;
|
||||
Ok(file_contents)
|
||||
}
|
||||
MaterializedTreeValue::FileConflict { id, contents, .. } => {
|
||||
let mut materialized_conflict_buffer = Vec::new();
|
||||
materialize_merge_result(&contents, &mut materialized_conflict_buffer).map_err(
|
||||
|io_err| BackendError::ReadFile {
|
||||
path: path.to_owned(),
|
||||
source: Box::new(io_err),
|
||||
id: id.first().clone().unwrap(),
|
||||
},
|
||||
)?;
|
||||
Ok(materialized_conflict_buffer)
|
||||
}
|
||||
_ => Ok(Vec::new()),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue