From 2a823f3683230bd6d3385f4394cea109e2f493a6 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 18 Mar 2020 12:02:49 +0100 Subject: [PATCH] fix multiple files being added to index instead of one --- src/app.rs | 15 ++++++++++++++- src/poll.rs | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/app.rs b/src/app.rs index 315ba2de..f5edc823 100644 --- a/src/app.rs +++ b/src/app.rs @@ -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(); } diff --git a/src/poll.rs b/src/poll.rs index e6c94fe2..cf82fa96 100644 --- a/src/poll.rs +++ b/src/poll.rs @@ -1,7 +1,7 @@ use crossterm::event::{self, Event}; use std::time::Duration; -/// +/// as pub enum PollResult { Timeout, Event(Event),