From ca6650b9de44714da36fbda8b4743af7db58d303 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 18 Mar 2020 10:55:23 +0100 Subject: [PATCH] fix crash when trying to add files in new folderq --- README.md | 1 - src/app.rs | 12 ++++++++---- src/git_status.rs | 5 ++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5bc310e4..0126630b 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ Over the last 2 years my go to GUI tool for this was [fork](https://git-fork.com * [x] show added files on working dir changes * [x] support committing * [x] popup centered -* [ ] crash: adding a pic to index crashes * [ ] crash: renamed files cannot be added to index * [ ] allow selecting/diff index items * [ ] support unstaging diff --git a/src/app.rs b/src/app.rs index ce202c3c..11ba65fd 100644 --- a/src/app.rs +++ b/src/app.rs @@ -270,10 +270,14 @@ impl App { let mut index = repo.index().unwrap(); let path = Path::new(self.status.wt_items[i].path.as_str()); - index.add_path(path).unwrap(); - index.write().unwrap(); - - self.update(); + if path.is_file() { + if let Ok(_) = index.add_path(path) { + index.write().unwrap(); + self.update(); + } + } else { + unimplemented!("can only add files"); + } } } diff --git a/src/git_status.rs b/src/git_status.rs index 67448f09..7d4e5eaf 100644 --- a/src/git_status.rs +++ b/src/git_status.rs @@ -57,7 +57,10 @@ impl StatusLists { let statuses = repo .statuses(Some( - StatusOptions::default().show(show).include_untracked(true), + StatusOptions::default() + .show(show) + .include_untracked(true) + .recurse_untracked_dirs(true), )) .unwrap();