From 5938997a4938472f366ff3dc6bb7aef23011b38b Mon Sep 17 00:00:00 2001 From: mrbeanc Date: Tue, 2 Jan 2024 00:28:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=81=E8=AE=B8=E6=9C=89=E6=9C=AA=E8=B7=9F?= =?UTF-8?q?=E8=B8=AA=E6=96=87=E4=BB=B6=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 32211308330b352eed48e5fc7adf851883d90e3c) --- src/commands/switch.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/commands/switch.rs b/src/commands/switch.rs index 498cfb2..d56406e 100644 --- a/src/commands/switch.rs +++ b/src/commands/switch.rs @@ -31,7 +31,8 @@ fn switch_to_commit(commit_hash: Hash) { fn switch_to(branch: String, detach: bool) -> Result<(), SwitchErr> { // 检查更改 - if !status::changes_to_be_staged().is_empty() { + let unstaged = status::changes_to_be_staged(); // unstaged.new是未跟踪 不需要处理 + if !unstaged.deleted.is_empty() || !unstaged.modified.is_empty() { status::status(); println!("fatal: 你有未暂存的更改,切换分支会导致更改丢失"); return Err(SwitchErr::NoClean);