fix multiple files being added to index instead of one

This commit is contained in:
Stephan Dilly 2020-03-18 12:02:49 +01:00
parent 75c2f7af03
commit 2a823f3683
2 changed files with 15 additions and 2 deletions

View file

@ -271,7 +271,20 @@ impl App {
let mut index = repo.index().unwrap();
let path = Path::new(self.status.wt_items[i].path.as_str());
if let Ok(_) = index.add_all(path, IndexAddOption::DISABLE_PATHSPEC_MATCH, None) {
let cb = &mut |p: &Path, _matched_spec: &[u8]| -> i32 {
if p == path {
0
} else {
1
}
};
if let Ok(_) = index.add_all(
path,
IndexAddOption::DISABLE_PATHSPEC_MATCH | IndexAddOption::CHECK_PATHSPEC,
Some(cb as &mut git2::IndexMatchedPath),
) {
index.write().unwrap();
self.update();
}

View file

@ -1,7 +1,7 @@
use crossterm::event::{self, Event};
use std::time::Duration;
///
/// as
pub enum PollResult {
Timeout,
Event(Event),