support non root repo open

This commit is contained in:
Stephan Dilly 2020-03-20 02:42:06 +01:00
parent 44bb85091f
commit cb42dca0a3
2 changed files with 8 additions and 3 deletions

View file

@ -29,7 +29,6 @@ gitui
* [x] inspect diffs
* [x] commit
* [x] [input polling in thread](assets/perf_compare.jpg)
* [ ] support non-root git folder wd
* [ ] show content of new files
* [ ] discard untracked files (remove)
* [ ] use [notify](https://crates.io/crates/notify) to watch git

View file

@ -1,6 +1,7 @@
use git2::{
build::CheckoutBuilder, DiffFormat, DiffOptions, IndexAddOption,
ObjectType, Repository, StatusOptions, StatusShow,
ObjectType, Repository, RepositoryOpenFlags, StatusOptions,
StatusShow,
};
use std::path::Path;
@ -91,7 +92,12 @@ pub fn get_diff(p: &Path, stage: bool) -> Diff {
///
pub fn repo() -> Repository {
let repo = Repository::init("./").unwrap();
let repo = Repository::open_ext(
"./",
RepositoryOpenFlags::empty(),
Vec::<&Path>::new(),
)
.unwrap();
if repo.is_bare() {
panic!("bare repo")