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] show added files on working dir changes
|
||||||
* [x] support committing
|
* [x] support committing
|
||||||
* [x] popup centered
|
* [x] popup centered
|
||||||
* [ ] crash: renamed files cannot be added to index
|
|
||||||
* [ ] allow selecting/diff index items
|
* [ ] allow selecting/diff index items
|
||||||
* [ ] support unstaging
|
* [ ] support unstaging
|
||||||
* [ ] polling in thread
|
* [ ] polling in thread
|
||||||
|
|
|
||||||
11
src/app.rs
11
src/app.rs
|
|
@ -4,6 +4,7 @@ use crate::{
|
||||||
git_utils::{self, Diff, DiffLine, DiffLineType},
|
git_utils::{self, Diff, DiffLine, DiffLineType},
|
||||||
};
|
};
|
||||||
use crossterm::event::{Event, KeyCode, MouseEvent};
|
use crossterm::event::{Event, KeyCode, MouseEvent};
|
||||||
|
use git2::IndexAddOption;
|
||||||
use std::{borrow::Cow, cmp, path::Path};
|
use std::{borrow::Cow, cmp, path::Path};
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
|
|
@ -270,13 +271,9 @@ impl App {
|
||||||
let mut index = repo.index().unwrap();
|
let mut index = repo.index().unwrap();
|
||||||
|
|
||||||
let path = Path::new(self.status.wt_items[i].path.as_str());
|
let path = Path::new(self.status.wt_items[i].path.as_str());
|
||||||
if path.is_file() {
|
if let Ok(_) = index.add_all(path, IndexAddOption::DISABLE_PATHSPEC_MATCH, None) {
|
||||||
if let Ok(_) = index.add_path(path) {
|
index.write().unwrap();
|
||||||
index.write().unwrap();
|
self.update();
|
||||||
self.update();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
unimplemented!("can only add files");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ impl StatusLists {
|
||||||
StatusOptions::default()
|
StatusOptions::default()
|
||||||
.show(show)
|
.show(show)
|
||||||
.include_untracked(true)
|
.include_untracked(true)
|
||||||
|
.renames_head_to_index(true)
|
||||||
.recurse_untracked_dirs(true),
|
.recurse_untracked_dirs(true),
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue