mirror of
https://github.com/gitui-org/gitui
synced 2026-05-24 09:28:21 +00:00
fix crash when renaming/removing a file
This commit is contained in:
parent
ca6650b9de
commit
cd2938e9c1
3 changed files with 5 additions and 8 deletions
|
|
@ -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: renamed files cannot be added to index
|
||||
* [ ] allow selecting/diff index items
|
||||
* [ ] support unstaging
|
||||
* [ ] polling in thread
|
||||
|
|
|
|||
11
src/app.rs
11
src/app.rs
|
|
@ -4,6 +4,7 @@ use crate::{
|
|||
git_utils::{self, Diff, DiffLine, DiffLineType},
|
||||
};
|
||||
use crossterm::event::{Event, KeyCode, MouseEvent};
|
||||
use git2::IndexAddOption;
|
||||
use std::{borrow::Cow, cmp, path::Path};
|
||||
use tui::{
|
||||
backend::Backend,
|
||||
|
|
@ -270,13 +271,9 @@ impl App {
|
|||
let mut index = repo.index().unwrap();
|
||||
|
||||
let path = Path::new(self.status.wt_items[i].path.as_str());
|
||||
if path.is_file() {
|
||||
if let Ok(_) = index.add_path(path) {
|
||||
index.write().unwrap();
|
||||
self.update();
|
||||
}
|
||||
} else {
|
||||
unimplemented!("can only add files");
|
||||
if let Ok(_) = index.add_all(path, IndexAddOption::DISABLE_PATHSPEC_MATCH, None) {
|
||||
index.write().unwrap();
|
||||
self.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ impl StatusLists {
|
|||
StatusOptions::default()
|
||||
.show(show)
|
||||
.include_untracked(true)
|
||||
.renames_head_to_index(true)
|
||||
.recurse_untracked_dirs(true),
|
||||
))
|
||||
.unwrap();
|
||||
|
|
|
|||
Loading…
Reference in a new issue