@@ -6,7 +6,6 @@ use crate::{CargoResult, GlobalContext};
6
6
use anyhow:: Context ;
7
7
use cargo_util:: paths;
8
8
use gix:: bstr:: ByteSlice ;
9
- use gix:: diff:: rewrites:: tracker:: Change ;
10
9
use gix:: dir:: walk:: EmissionMode ;
11
10
use gix:: index:: entry:: Mode ;
12
11
use gix:: status:: tree_index:: TrackRenames ;
@@ -182,13 +181,11 @@ fn git(
182
181
relative_package_root ( repo, pkg. root ( ) ) . as_deref ( ) ,
183
182
& mut dirty_files,
184
183
) ?;
185
- // super::collect_statuses(git_repo, &[pathspec.as_str()], &mut dirty_files)?;
186
184
187
185
// Include each submodule so that the error message can provide
188
186
// specifically *which* files in a submodule are modified.
189
187
status_submodules (
190
188
repo,
191
- workdir,
192
189
& mut dirty_files,
193
190
& mut dirty_files_outside_of_package_root,
194
191
) ?;
@@ -199,7 +196,22 @@ fn git(
199
196
let cwd = ws. gctx ( ) . cwd ( ) ;
200
197
let mut dirty_src_files: Vec < _ > = src_files
201
198
. iter ( )
202
- . filter ( |src_file| dirty_files. iter ( ) . any ( |path| src_file. starts_with ( path) ) )
199
+ . filter ( |src_file| {
200
+ if let Some ( canon_src_file) = src_file. is_symlink_or_under_symlink ( ) . then ( || {
201
+ gix:: path:: realpath_opts (
202
+ & src_file,
203
+ ws. gctx ( ) . cwd ( ) ,
204
+ gix:: path:: realpath:: MAX_SYMLINKS ,
205
+ )
206
+ . unwrap_or_else ( |_| src_file. to_path_buf ( ) )
207
+ } ) {
208
+ dirty_files
209
+ . iter ( )
210
+ . any ( |path| canon_src_file. starts_with ( path) )
211
+ } else {
212
+ dirty_files. iter ( ) . any ( |path| src_file. starts_with ( path) )
213
+ }
214
+ } )
203
215
. map ( |p| p. as_ref ( ) )
204
216
. chain (
205
217
dirty_files_outside_pkg_root ( ws, pkg, & dirty_files_outside_of_package_root, src_files) ?
@@ -248,9 +260,10 @@ fn collect_statuses(
248
260
. status ( gix:: progress:: Discard ) ?
249
261
. dirwalk_options ( |opts| {
250
262
opts. emit_untracked ( gix:: dir:: walk:: EmissionMode :: Matching )
251
- // Also pick up ignored files (but not entire directories)
263
+ // Also pick up ignored files or whole directories
252
264
// to specifically catch overzealously ignored source files.
253
- // Later we will match these dirs by prefix.
265
+ // Later we will match these dirs by prefix, which is why collapsing
266
+ // them is desirable here.
254
267
. emit_ignored ( Some ( EmissionMode :: CollapseDirectory ) )
255
268
. emit_tracked ( false )
256
269
. recurse_repositories ( false )
@@ -295,13 +308,6 @@ fn collect_statuses(
295
308
continue ;
296
309
}
297
310
298
- // We completely ignore submodules
299
- if matches ! (
300
- status,
301
- gix:: status:: Item :: TreeIndex ( change) if change. entry_mode( ) . is_commit( ) )
302
- {
303
- continue ;
304
- }
305
311
dirty_files. push ( path) ;
306
312
}
307
313
Ok ( dirty_files_outside_of_package_root)
@@ -310,7 +316,6 @@ fn collect_statuses(
310
316
/// Helper to collect dirty statuses while recursing into submodules.
311
317
fn status_submodules (
312
318
repo : & gix:: Repository ,
313
- workdir : & Path ,
314
319
dirty_files : & mut Vec < PathBuf > ,
315
320
dirty_files_outside_of_package_root : & mut Vec < PathBuf > ,
316
321
) -> CargoResult < ( ) > {
@@ -321,12 +326,10 @@ fn status_submodules(
321
326
// Ignore submodules that don't open, they are probably not initialized.
322
327
// If its files are required, then the verification step should fail.
323
328
if let Some ( sub_repo) = submodule. open ( ) ? {
324
- status_submodules (
325
- & sub_repo,
326
- workdir,
327
- dirty_files,
328
- dirty_files_outside_of_package_root,
329
- ) ?;
329
+ let Some ( workdir) = sub_repo. workdir ( ) else {
330
+ continue ;
331
+ } ;
332
+ status_submodules ( & sub_repo, dirty_files, dirty_files_outside_of_package_root) ?;
330
333
dirty_files_outside_of_package_root. extend ( collect_statuses (
331
334
& sub_repo,
332
335
workdir,
@@ -391,15 +394,10 @@ fn dirty_files_outside_pkg_root(
391
394
)
392
395
. unwrap_or_else ( |_| src_file. to_owned ( ) ) ;
393
396
394
- if dirty_files_outside_of_package_root
397
+ dirty_files_outside_of_package_root
395
398
. iter ( )
396
399
. any ( |p| canon_src_path. starts_with ( p) )
397
- {
398
- // Use the canonicalized path as later we want to truncate it by the CWD, which is also canonicalized.
399
- Some ( canon_src_path)
400
- } else {
401
- None
402
- }
400
+ . then_some ( canon_src_path)
403
401
} )
404
402
. collect ( ) ;
405
403
Ok ( dirty_files)
0 commit comments