Unified · Split
| @@ -210,6 +210,11 @@ pub(crate) mod function { · 209 unmodified lines | ||
| 210 | 210 | saw_ignored_directory |= is_ignored; |
| 211 | 211 | saw_untracked_directory |= entry.status == gix::dir::entry::Status::Untracked; |
| 212 | 212 | } |
| 213 | + | |
| 214 | + if gix::interrupt::is_triggered() { | |
| 215 | + execute = false; | |
| 216 | + } | |
| 217 | + let mut may_remove_this_entry = execute; | |
| 213 | 218 | writeln!( |
| 214 | 219 | out, |
| 215 | 220 | "{maybe}{suffix} {}{} {status}", |
| @@ -235,7 +240,18 @@ pub(crate) mod function { · 19 unmodified lines | ||
| 235 | 240 | "".into() |
| 236 | 241 | }, |
| 237 | 242 | }, |
| 238 | − maybe = if execute { "removing" } else { "WOULD remove" }, | |
| 243 | + maybe = if entry.property == Some(gix::dir::entry::Property::EmptyDirectoryAndCWD) { | |
| 244 | + may_remove_this_entry = false; | |
| 245 | + if execute { | |
| 246 | + "Refusing to remove empty current working directory" | |
| 247 | + } else { | |
| 248 | + "Would refuse to remove empty current working directory" | |
| 249 | + } | |
| 250 | + } else if execute { | |
| 251 | + "removing" | |
| 252 | + } else { | |
| 253 | + "WOULD remove" | |
| 254 | + }, | |
| 239 | 255 | suffix = match disk_kind { |
| 240 | 256 | Kind::Directory if entry.property == Some(gix::dir::entry::Property::EmptyDirectory) => { |
| 241 | 257 | " empty" |
| @@ -249,10 +265,7 @@ pub(crate) mod function { · 7 unmodified lines | ||
| 249 | 265 | }, |
| 250 | 266 | )?; |
| 251 | 267 | |
| 252 | − if gix::interrupt::is_triggered() { | |
| 253 | − execute = false; | |
| 254 | − } | |
| 255 | − if execute { | |
| 268 | + if may_remove_this_entry { | |
| 256 | 269 | let path = workdir.join(entry_path); |
| 257 | 270 | if disk_kind.is_dir() { |
| 258 | 271 | std::fs::remove_dir_all(path)?; |