GeezerVison is showing github.com — Handle directory-file and file-directory comparisons in the diff by TanmayPatil105 · Pull Request #56 · uutils/diffutils
Conversation
GNU diff treats diff DIRECTORY FILE as diff DIRECTORY/FILE FILE
$ echo a > a
$ mkdir d
$ echo da > d/a
$ diff -u d a
--- d/a 2024-04-20 22:16:11.145369745 +0530
+++ a 2024-04-20 22:15:57.785813179 +0530
@@ -1 +1 @@
-da
+a
$ diff -u a d
--- a 2024-04-20 22:15:57.785813179 +0530
+++ d/a 2024-04-20 22:16:11.145369745 +0530
@@ -1 +1 @@
-a
+da
$ cargo run -- -u d a
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
Running `target/debug/diffutils -u d a`
--- d/a 2024-04-20 22:16:11.145369745 +0530
+++ a 2024-04-20 22:15:57.785813179 +0530
@@ -1 +1 @@
-da
+a
$ cargo run -- -u a d
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
Running `target/debug/diffutils -u a d`
--- a 2024-04-20 22:15:57.785813179 +0530
+++ d/a 2024-04-20 22:16:11.145369745 +0530
@@ -1 +1 @@
-a
+da
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Well, this will handle diff -u d a but not diff -u - a < d.
$ diff -u - a < d
--- -/a 2024-04-20 22:16:11.145369745 +0530
+++ a 2024-04-20 22:15:57.785813179 +0530
@@ -1 +1 @@
-da
+a
$ cargo run -- -u - a < d
Finished dev [unoptimized + debuginfo] target(s) in 0.10s
Running `target/debug/diffutils -u - a`
Failed to read from-file: Is a directory (os error 21)
GNU diff (3.9+) implementes stdin directory input using openat
See: https://git.savannah.gnu.org/cgit/diffutils.git/tree/src/diff.c#n1541
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
codecov
Bot
commented
Apr 20, 2024
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
All modified and coverable lines are covered by tests ✅
Project coverage is 81.82%. Comparing base (8de0ca6) to head (8c6a648).
Additional details and impacted files
@@ Coverage Diff @@
## main #56 +/- ##
==========================================
+ Coverage 81.78% 81.82% +0.03%
==========================================
Files 10 10
Lines 2877 2927 +50
Branches 740 747 +7
==========================================
+ Hits 2353 2395 +42
- Misses 503 509 +6
- Partials 21 23 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
sorry but your test fails on windows with:
---- read_from_directory stdout ----
---- read_from_directory stderr ----
thread 'main' panicked at tests\integration.rs:257:5:
assertion `left == right` failed
left: "--- target/integration/d\\a\tTIMESTAMP\n+++ target/integration/a\tTIMESTAMP\n@@ -1 +1 @@\n-da\n+a\n"
right: "--- target/integration/d/a\tTIMESTAMP\n+++ target/integration/a\tTIMESTAMP\n@@ -1 +1 @@\n-da\n+a\n"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
GNU diff treats `diff DIRECTORY FILE` as `diff DIRECTORY/FILE FILE`
Well, this will handle diff -u d a but not diff -u - a < d.
That would be nice to have, but it can be implemented in a followup PR.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
oSoMoN
oSoMoN left review comments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.