diff --git a/README.md b/README.md index 0bf708a8..20abe88f 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,10 @@ terminal ui (tui) frontend for git written in rust * [x] only show diff of selected file * [x] change detection * [x] allow scrolling diff +* [x] support staging * [ ] show added files on working dir changes * [ ] allow selecting/diff index items -* [ ] support staging/unstaging +* [ ] support unstaging * [ ] support committing * [ ] polling in thread * [ ] support push/pull diff --git a/src/app.rs b/src/app.rs index c24b4d9d..66ba8939 100644 --- a/src/app.rs +++ b/src/app.rs @@ -160,7 +160,19 @@ impl App { self.fetch_status(); } - fn index_add(&mut self) {} + fn index_add(&mut self) { + if let Some(i) = self.status_select { + let repo = git_utils::repo(); + + let mut index = repo.index().unwrap(); + + let path = Path::new(self.status.wt_items[i].path.as_str()); + index.update_all(path, None).unwrap(); + index.write().unwrap(); + + self.update(); + } + } fn scroll(&mut self, inc: bool) { if inc {