|
| 1 | +use std::collections::HashSet; |
1 | 2 | use std::fmt::{self, Debug, Formatter};
|
2 | 3 | use std::fs;
|
3 | 4 | use std::path::{Path, PathBuf};
|
@@ -261,19 +262,36 @@ impl<'cfg> PathSource<'cfg> {
|
261 | 262 | opts.pathspec(suffix);
|
262 | 263 | }
|
263 | 264 | let statuses = repo.statuses(Some(&mut opts))?;
|
264 |
| - let untracked = statuses.iter().filter_map(|entry| match entry.status() { |
265 |
| - // Don't include Cargo.lock if it is untracked. Packaging will |
266 |
| - // generate a new one as needed. |
267 |
| - git2::Status::WT_NEW if entry.path() != Some("Cargo.lock") => { |
268 |
| - Some((join(root, entry.path_bytes()), None)) |
269 |
| - } |
270 |
| - _ => None, |
271 |
| - }); |
| 265 | + let mut skip_paths = HashSet::new(); |
| 266 | + let untracked: Vec<_> = statuses |
| 267 | + .iter() |
| 268 | + .filter_map(|entry| { |
| 269 | + match entry.status() { |
| 270 | + // Don't include Cargo.lock if it is untracked. Packaging will |
| 271 | + // generate a new one as needed. |
| 272 | + git2::Status::WT_NEW if entry.path() != Some("Cargo.lock") => { |
| 273 | + Some(Ok((join(root, entry.path_bytes()), None))) |
| 274 | + } |
| 275 | + git2::Status::WT_DELETED => { |
| 276 | + let path = match join(root, entry.path_bytes()) { |
| 277 | + Ok(p) => p, |
| 278 | + Err(e) => return Some(Err(e)), |
| 279 | + }; |
| 280 | + skip_paths.insert(path); |
| 281 | + None |
| 282 | + } |
| 283 | + _ => None, |
| 284 | + } |
| 285 | + }) |
| 286 | + .collect::<CargoResult<_>>()?; |
272 | 287 |
|
273 | 288 | let mut subpackages_found = Vec::new();
|
274 | 289 |
|
275 | 290 | for (file_path, is_dir) in index_files.chain(untracked) {
|
276 | 291 | let file_path = file_path?;
|
| 292 | + if skip_paths.contains(&file_path) { |
| 293 | + continue; |
| 294 | + } |
277 | 295 |
|
278 | 296 | // Filter out files blatantly outside this package. This is helped a
|
279 | 297 | // bit above via the `pathspec` function call, but we need to filter
|
|
0 commit comments