diffutils icon indicating copy to clipboard operation
diffutils copied to clipboard

stdin: Handle directory input

Open TanmayPatil105 opened this issue 1 year ago • 5 comments

When handling stdin, GNU diff now behaves as follows:

  • If a file is input, it displays the current time as m_time
  • If a directory is input, it appends the other file_name to the canonicalized path of directory and reads and displays the m_time of that file

TanmayPatil105 avatar May 05 '24 12:05 TanmayPatil105

Codecov Report

Attention: Patch coverage is 47.05882% with 18 lines in your changes are missing coverage. Please review.

Project coverage is 75.12%. Comparing base (d922313) to head (f21689d).

Files Patch % Lines
src/params.rs 35.71% 5 Missing and 4 partials :warning:
src/context_diff.rs 42.85% 2 Missing and 2 partials :warning:
src/unified_diff.rs 42.85% 2 Missing and 2 partials :warning:
src/main.rs 83.33% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #73      +/-   ##
==========================================
- Coverage   75.46%   75.12%   -0.35%     
==========================================
  Files          10       10              
  Lines        2935     2959      +24     
  Branches      745      754       +9     
==========================================
+ Hits         2215     2223       +8     
- Misses        547      557      +10     
- Partials      173      179       +6     
Flag Coverage Δ
macos_latest 75.86% <47.05%> (-0.36%) :arrow_down:
ubuntu_latest 75.10% <44.11%> (-0.36%) :arrow_down:
windows_latest 15.44% <45.83%> (+0.02%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 05 '24 12:05 codecov[bot]

Okay, now this is tricky! There is no /dev/stdin on windows.

TanmayPatil105 avatar May 05 '24 12:05 TanmayPatil105

Hey @oSoMoN , can you review this PR?

TanmayPatil105 avatar May 07 '24 16:05 TanmayPatil105

Sorry for the long delay @TanmayPatil105, I haven't had time to dedicate to this project in the last few weeks. So what exactly is the use case you're addressing here? How would one pass a directory as stdin on the command line? Also, could you please add an integration test for that use case?

oSoMoN avatar Jun 04 '24 12:06 oSoMoN

So what exactly is the use case you're addressing here? How would one pass a directory as stdin on the command line?

Yeah, that is highly unlikely. However, since GNU diff 3.9, it has started handling redirected directory inputs. Additionally, this has also been included in the tests http://git.savannah.gnu.org/cgit/diffutils.git/tree/tests/stdin#n27.

Also, could you please add an integration test for that use case?

I had a go on it but I don't think so there's a way to redirect a directory as input through code. Is there a way?

TanmayPatil105 avatar Jun 08 '24 19:06 TanmayPatil105