From 2f7b396ab883da7fb6e5f9673e12a1b66e713c86 Mon Sep 17 00:00:00 2001 From: Mattias Granlund Date: Sat, 20 Apr 2024 13:24:33 +0200 Subject: [PATCH] Remove extra indirector for blame function --- .../src/project_repository/repository.rs | 14 -------------- .../gitbutler-core/src/virtual_branches/virtual.rs | 5 ++--- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/crates/gitbutler-core/src/project_repository/repository.rs b/crates/gitbutler-core/src/project_repository/repository.rs index ead48bd09..3d69696aa 100644 --- a/crates/gitbutler-core/src/project_repository/repository.rs +++ b/crates/gitbutler-core/src/project_repository/repository.rs @@ -5,7 +5,6 @@ use std::{ }; use anyhow::{Context, Result}; -use git2::Blame; use super::conflicts; use crate::error::{AnyhowContextExt, Code, ErrorWithContext}; @@ -617,19 +616,6 @@ impl Repository { Err(RemoteError::Auth) } - - pub fn blame( - &self, - path: &path::Path, - min_line: u32, - max_line: u32, - oldest_commit: &git::Oid, - newest_commit: &git::Oid, - ) -> Result { - Ok(self - .git_repository - .blame(path, min_line, max_line, oldest_commit, newest_commit)?) - } } #[derive(Debug, thiserror::Error)] diff --git a/crates/gitbutler-core/src/virtual_branches/virtual.rs b/crates/gitbutler-core/src/virtual_branches/virtual.rs index abd1a943d..de089edc0 100644 --- a/crates/gitbutler-core/src/virtual_branches/virtual.rs +++ b/crates/gitbutler-core/src/virtual_branches/virtual.rs @@ -32,7 +32,6 @@ use crate::{ diff::{self}, Commit, Refname, RemoteRefname, }, - id::Id, keys, project_repository::{self, conflicts, LogUntil}, reader, users, @@ -1792,7 +1791,7 @@ fn get_applied_status( } for (path, hunks) in base_diffs.clone().into_iter() { for hunk in hunks { - let blame = project_repository.blame( + let blame = project_repository.git_repository.blame( &path, hunk.old_start, (hunk.old_start + hunk.old_lines).saturating_sub(1), @@ -1804,7 +1803,7 @@ fn get_applied_status( for blame_hunk in blame.iter() { let commit = blame_hunk.orig_commit_id(); if git::Oid::from(commit) != *target_sha { - let hash = Hunk::hash(&hunk.diff_lines.as_ref()); + let hash = Hunk::hash(hunk.diff_lines.as_ref()); git_hunk_map.insert(hash, branch.id); break; }