手动实现相对路径->绝对路径,解决add不存在文件panic问题

This commit is contained in:
mrbeanc
2023-12-22 14:39:41 +08:00
parent 451dbd9d01
commit 49a7220ad8
2 changed files with 33 additions and 7 deletions

View File

@@ -58,7 +58,6 @@ pub fn add(files: Vec<String>, all: bool, mut update: bool) {
}
fn add_a_file(file: &Path, index: &mut Index) {
//TODO 文件不存在会报错
if !is_inside_workdir(file) && file.exists() {
//文件不在工作区内
println!("fatal: '{}' is outside repository at '{}'", file.display(), get_working_dir().unwrap().display());