Skip to content

Commit 6a4849d

Browse files
committed
refactor: avoid borrowed git2::Oid as it's a copy type.
Usually this makes the affected code simpler.
1 parent c81b140 commit 6a4849d

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

crates/gitbutler-branch-actions/src/branch_manager/branch_removal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl BranchManager<'_> {
102102
.map(|file| (file.path, file.hunks))
103103
.collect::<Vec<(PathBuf, Vec<VirtualBranchHunk>)>>();
104104
let tree_oid =
105-
gitbutler_diff::write::hunks_onto_oid(self.ctx, &branch.head, files)?;
105+
gitbutler_diff::write::hunks_onto_oid(self.ctx, branch.head, files)?;
106106
let branch_tree = repo.find_tree(tree_oid)?;
107107
let mut result =
108108
repo.merge_trees(&base_tree, &final_tree, &branch_tree, None)?;

crates/gitbutler-branch-actions/src/status.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ pub fn get_applied_status_cached(
213213
// write updated state if not resolving
214214
if !ctx.is_resolving() {
215215
for (vbranch, files) in &mut hunks_by_branch {
216-
vbranch.tree = gitbutler_diff::write::hunks_onto_oid(ctx, &vbranch.head, files)?;
216+
vbranch.tree = gitbutler_diff::write::hunks_onto_oid(ctx, vbranch.head, files)?;
217217
vb_state
218218
.set_branch(vbranch.clone())
219219
.context(format!("failed to write virtual branch {}", vbranch.name))?;

crates/gitbutler-branch-actions/src/virtual.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub fn unapply_ownership(
158158
.map(|file| (file.path, file.hunks))
159159
.collect::<Vec<(PathBuf, Vec<VirtualBranchHunk>)>>();
160160
let tree_oid =
161-
gitbutler_diff::write::hunks_onto_oid(ctx, &integration_commit_id, files)?;
161+
gitbutler_diff::write::hunks_onto_oid(ctx, integration_commit_id, files)?;
162162
let branch_tree = repo.find_tree(tree_oid)?;
163163
let mut result = repo.merge_trees(&base_tree, &final_tree, &branch_tree, None)?;
164164
let final_tree_oid = result.write_tree_to(ctx.repository())?;
@@ -1043,7 +1043,7 @@ pub(crate) fn push(
10431043
};
10441044

10451045
ctx.push(
1046-
&vbranch.head,
1046+
vbranch.head,
10471047
&remote_branch,
10481048
with_force,
10491049
credentials,

crates/gitbutler-diff/src/write.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ use crate::GitHunk;
1515
// and writes it as a new tree for storage
1616
pub fn hunks_onto_oid<T>(
1717
ctx: &CommandContext,
18-
target: &git2::Oid,
18+
target: git2::Oid,
1919
files: impl IntoIterator<Item = (impl Borrow<PathBuf>, impl Borrow<Vec<T>>)>,
2020
) -> Result<git2::Oid>
2121
where
2222
T: Into<GitHunk> + Clone,
2323
{
24-
hunks_onto_commit(ctx, *target, files)
24+
hunks_onto_commit(ctx, target, files)
2525
}
2626

2727
pub fn hunks_onto_commit<T>(

crates/gitbutler-repo/src/change_reference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ pub fn push_change_reference(
146146
let commit =
147147
commit_by_branch_id_and_change_id(ctx, &vbranch, &handle, reference.change_id.clone())?;
148148
ctx.push(
149-
&commit.id(),
149+
commit.id(),
150150
&upstream_refname,
151151
with_force,
152152
credentials,

crates/gitbutler-repo/src/repository.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub trait RepoActionsExt {
1414
-> Result<()>;
1515
fn push(
1616
&self,
17-
head: &git2::Oid,
17+
head: git2::Oid,
1818
branch: &RemoteRefname,
1919
with_force: bool,
2020
credentials: &Helper,
@@ -67,14 +67,14 @@ impl RepoActionsExt for CommandContext {
6767
let refname =
6868
RemoteRefname::from_str(&format!("refs/remotes/{remote_name}/{branch_name}",))?;
6969

70-
match self.push(&commit_id, &refname, false, credentials, None, askpass) {
70+
match self.push(commit_id, &refname, false, credentials, None, askpass) {
7171
Ok(()) => Ok(()),
7272
Err(e) => Err(anyhow::anyhow!(e.to_string())),
7373
}?;
7474

7575
let empty_refspec = Some(format!(":refs/heads/{}", branch_name));
7676
match self.push(
77-
&commit_id,
77+
commit_id,
7878
&refname,
7979
false,
8080
credentials,
@@ -254,7 +254,7 @@ impl RepoActionsExt for CommandContext {
254254

255255
fn push(
256256
&self,
257-
head: &git2::Oid,
257+
head: git2::Oid,
258258
branch: &RemoteRefname,
259259
with_force: bool,
260260
credentials: &Helper,

0 commit comments

Comments
 (0)