GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Handle directory-file and file-directory comparisons in the diff by TanmayPatil105 · Pull Request #56 · uutils/diffutils

Conversation

@TanmayPatil105

@TanmayPatil105 TanmayPatil105 commented Apr 20, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

All reactions
@TanmayPatil105

TanmayPatil105 commented Apr 20, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TanmayPatil105
TanmayPatil105 force-pushed the handle-directory-input branch from 8b2f67b to 7dacdb3 Compare April 20, 2024 17:06
@codecov

codecov Bot commented Apr 20, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

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     
Flag Coverage Δ
macos_latest 82.70% <100.00%> (+0.59%) ⬆️
ubuntu_latest 75.19% <76.66%> (+0.44%) ⬆️
windows_latest 15.24% <20.00%> (?)

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sylvestre

sylvestre commented Apr 21, 2024

Copy link
Copy Markdown
Collaborator

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


All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

TanmayPatil105 added 2 commits April 21, 2024 16:10
@TanmayPatil105
Handle directory-file and file-directory comparisons in the diff
39d2ece
GNU diff treats `diff DIRECTORY FILE` as `diff DIRECTORY/FILE FILE`
@TanmayPatil105
Add tests for diff FILE DIRECTORY
65993d6
@TanmayPatil105
TanmayPatil105 force-pushed the handle-directory-input branch from 46245f3 to 65993d6 Compare April 21, 2024 10:41
@TanmayPatil105
Windows: Fix tests
476e69e
@oSoMoN

oSoMoN commented Apr 23, 2024

Copy link
Copy Markdown
Collaborator

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

oSoMoN
oSoMoN reviewed Apr 23, 2024
View reviewed changes
Comment thread tests/integration.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/integration.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

TanmayPatil105 added 2 commits April 23, 2024 22:44
@TanmayPatil105
Create test files in temporary directory
0304391
@TanmayPatil105
Merge branch 'main' into handle-directory-input
8c6a648
@oSoMoN
oSoMoN merged commit e7dc655 into uutils:main Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@oSoMoN oSoMoN oSoMoN left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

3 participants

@TanmayPatil105 @sylvestre @oSoMoN
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.