Repository navigation
find: Implement -samefile - #389
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #389 +/- ##
==========================================
+ Coverage 64.96% 65.43% +0.47%
==========================================
Files 32 33 +1
Lines 3810 3888 +78
Branches 874 892 +18
==========================================
+ Hits 2475 2544 +69
Misses 993 993
- Partials 342 351 +9 ☔ View full report in Codecov by Sentry. |
|
|
||
| #[test] | ||
| #[serial(working_dir)] | ||
| #[cfg(target_os = "linux")] |
There was a problem hiding this comment.
The -samefile option is primarily used in Linux/Unix systems to determine whether two files are the same file based on their inode (hard link) information.
The ino() method of the MetadataExt can be utilized to obtain the inode.
However, the equivalent file_index() method in std::os::windows::fs::MetadataExt (Rust Docs) on the Windows platform is still considered experimental, so I would recommend exercising caution when using it.
There was a problem hiding this comment.
So actually I haven't implemented it on Windows platform yet (has left FIXME mark).
|
|
||
| #[test] | ||
| #[serial(working_dir)] | ||
| #[cfg(target_os = "linux")] |
There was a problem hiding this comment.
| #[cfg(target_os = "linux")] | |
| #[cfg(unix)] |
There was a problem hiding this comment.
Thanks. Modified in latest commit. This target is more suitable than linux. : )
| #[cfg(unix)] | ||
| fn matches(&self, file_info: &walkdir::DirEntry, _matcher_io: &mut super::MatcherIO) -> bool { | ||
| let meta = file_info.metadata().unwrap(); | ||
| meta.ino() == self.metadata.ino() |
There was a problem hiding this comment.
You also need to check meta.dev(). Otherwise you'll return true for two unrelated files on different filesystems that happen to get the same inode number.
There was a problem hiding this comment.
Okay, I've added a check.
There was a problem hiding this comment.
There was a problem hiding this comment.
we have https://github.com/uutils/coreutils/blob/8cac375dddb4d4e87519c137c45fa831ac7f2619/src/uucore/src/lib/features/fs.rs#L559 it would not be a good candidate ?
Thanks! This has now been changed to uucore::fs::paths_refer_to_same_file in f612c0d and it works great!
|
And I waiting for #400 to review this first :) |
|
GNU testsuite comparison: |
|
@hanbings is that expected ? :) |
|
If we mean the GNU/BFS tests for the code in this PR itself, yes. |
|
GNU testsuite comparison: |
|
|
||
| #[cfg(not(unix))] | ||
| fn matches(&self, _file_info: &walkdir::DirEntry, _matcher_io: &mut super::MatcherIO) -> bool { | ||
| // FIXME |
There was a problem hiding this comment.
please create an issue for this once it landed
There was a problem hiding this comment.
There was a problem hiding this comment.
also, it supports windows? https://github.com/uutils/coreutils/blob/92665144c9ddf100d5044dc0c52af122a94587d0/src/uu/split/src/platform/windows.rs#L47
Oh! That's right! Changed to support multiple platforms. Thanks!
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
implement: #373
BFS test
+1 PASSand GNU testPASS +8/FAIL -20in commit bc8ae98