mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-29 14:25:45 +03:00
clippy
This commit is contained in:
parent
7860dd3c97
commit
effc5fa183
@ -437,29 +437,25 @@ impl Repository {
|
||||
tree_builder.upsert(
|
||||
"session",
|
||||
build_session_tree(self)
|
||||
.context("failed to build session tree")?
|
||||
.into(),
|
||||
.context("failed to build session tree")?,
|
||||
git::FileMode::Tree,
|
||||
);
|
||||
tree_builder.upsert(
|
||||
"wd",
|
||||
build_wd_tree(self, project_repository)
|
||||
.context("failed to build working directory tree")?
|
||||
.into(),
|
||||
.context("failed to build working directory tree")?,
|
||||
git::FileMode::Tree,
|
||||
);
|
||||
tree_builder.upsert(
|
||||
"logs",
|
||||
build_log_tree(self, project_repository)
|
||||
.context("failed to build logs tree")?
|
||||
.into(),
|
||||
.context("failed to build logs tree")?,
|
||||
git::FileMode::Tree,
|
||||
);
|
||||
tree_builder.upsert(
|
||||
"branches",
|
||||
build_branches_tree(self)
|
||||
.context("failed to build branches tree")?
|
||||
.into(),
|
||||
.context("failed to build branches tree")?,
|
||||
git::FileMode::Tree,
|
||||
);
|
||||
|
||||
@ -658,7 +654,7 @@ fn build_wd_tree(
|
||||
let wd_tree_entry = tree.get_name("wd").unwrap();
|
||||
let wd_tree = gb_repository
|
||||
.git_repository
|
||||
.find_tree(wd_tree_entry.id().into())?;
|
||||
.find_tree(wd_tree_entry.id())?;
|
||||
index.read_tree((&wd_tree).into())?;
|
||||
|
||||
let session_wd_reader = reader::DirReader::open(gb_repository.session_wd_path());
|
||||
@ -724,7 +720,7 @@ fn build_wd_tree(
|
||||
Err(git::Error::NotFound(_)) => build_wd_tree_from_repo(gb_repository, project_repository)
|
||||
.context("failed to build wd index"),
|
||||
Err(e) => {
|
||||
return Err(e.into());
|
||||
Err(e.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,14 +118,14 @@ impl<'repo> TreeBuilder<'repo> {
|
||||
}
|
||||
|
||||
pub fn write(&mut self) -> Result<Oid> {
|
||||
let repo: &git2::Repository = self.repo.into();
|
||||
let repo: &git2::Repository = self.repo;
|
||||
if let Some(base) = self.base {
|
||||
let tree_id = self.builder.create_updated(&repo, base.into())?;
|
||||
let tree_id = self.builder.create_updated(repo, base)?;
|
||||
Ok(tree_id.into())
|
||||
} else {
|
||||
let empty_tree_id = repo.treebuilder(None)?.write()?;
|
||||
let empty_tree = repo.find_tree(empty_tree_id)?;
|
||||
let tree_id = self.builder.create_updated(&repo, &empty_tree)?;
|
||||
let tree_id = self.builder.create_updated(repo, &empty_tree)?;
|
||||
Ok(tree_id.into())
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ impl Reader for CommitReader<'_> {
|
||||
Ok(entry) => entry,
|
||||
Err(_) => return Ok(0),
|
||||
};
|
||||
let blob = match self.repository.find_blob(entry.id().into()) {
|
||||
let blob = match self.repository.find_blob(entry.id()) {
|
||||
Ok(blob) => blob,
|
||||
Err(_) => return Ok(0),
|
||||
};
|
||||
@ -181,7 +181,7 @@ impl Reader for CommitReader<'_> {
|
||||
Ok(entry) => entry,
|
||||
Err(_) => return Err(Error::NotFound),
|
||||
};
|
||||
let blob = match self.repository.find_blob(entry.id().into()) {
|
||||
let blob = match self.repository.find_blob(entry.id()) {
|
||||
Ok(blob) => blob,
|
||||
Err(_) => return Err(Error::NotFound),
|
||||
};
|
||||
|
@ -1722,7 +1722,7 @@ pub fn write_tree(
|
||||
let bytes: &[u8] = path_str.as_bytes();
|
||||
|
||||
let blob_oid = git_repository.blob(bytes)?;
|
||||
builder.upsert(rel_path, blob_oid.into(), filemode);
|
||||
builder.upsert(rel_path, blob_oid, filemode);
|
||||
} else if let Ok(tree_entry) = base_tree.get_path(rel_path) {
|
||||
if file.binary {
|
||||
let new_blob_oid = &file.hunks[0].diff;
|
||||
@ -1756,12 +1756,12 @@ pub fn write_tree(
|
||||
// create a blob
|
||||
let new_blob_oid = git_repository.blob(&new_content)?;
|
||||
// upsert into the builder
|
||||
builder.upsert(rel_path, new_blob_oid.into(), filemode);
|
||||
builder.upsert(rel_path, new_blob_oid, filemode);
|
||||
}
|
||||
} else {
|
||||
// create a git blob from a file on disk
|
||||
let blob_oid = git_repository.blob_path(&full_path)?;
|
||||
builder.upsert(rel_path, blob_oid.into(), filemode);
|
||||
builder.upsert(rel_path, blob_oid, filemode);
|
||||
}
|
||||
} else if base_tree.get_path(rel_path).is_ok() {
|
||||
// remove file from index if it exists in the base tree
|
||||
@ -1775,7 +1775,7 @@ pub fn write_tree(
|
||||
// now write out the tree
|
||||
let tree_oid = builder.write().context("failed to write updated tree")?;
|
||||
|
||||
Ok(tree_oid.into())
|
||||
Ok(tree_oid)
|
||||
}
|
||||
|
||||
fn _print_tree(repo: &git2::Repository, tree: &git2::Tree) -> Result<()> {
|
||||
|
Loading…
Reference in New Issue
Block a user