This commit is contained in:
Stephan Dilly 2020-03-23 00:17:29 +01:00
parent 9580f8b489
commit 08a8e07322

View file

@ -1,8 +1,6 @@
use git2::{ use crate::utils;
DiffFormat, DiffOptions, Repository, RepositoryOpenFlags, use git2::{DiffFormat, DiffOptions};
};
use scopetime::scope_time; use scopetime::scope_time;
use std::path::Path;
/// ///
#[derive(Copy, Clone, PartialEq)] #[derive(Copy, Clone, PartialEq)]
@ -34,7 +32,7 @@ pub struct Diff(pub Vec<DiffLine>);
pub fn get_diff(p: String, stage: bool) -> Diff { pub fn get_diff(p: String, stage: bool) -> Diff {
scope_time!("get_diff"); scope_time!("get_diff");
let repo = repo(); let repo = utils::repo();
let mut opt = DiffOptions::new(); let mut opt = DiffOptions::new();
opt.pathspec(p); opt.pathspec(p);
@ -90,19 +88,3 @@ pub fn get_diff(p: String, stage: bool) -> Diff {
Diff(res) Diff(res)
} }
///
pub fn repo() -> Repository {
let repo = Repository::open_ext(
"./",
RepositoryOpenFlags::empty(),
Vec::<&Path>::new(),
)
.unwrap();
if repo.is_bare() {
panic!("bare repo")
}
repo
}