Skip to content

diff: compare DIR/FILE with FILE when stdin is a directory - #318

Merged
sylvestre merged 1 commit into
diff-binaryfrom
diff-stdin-dir
Nov 3, 2026
Merged

sylvestre merged 1 commit into
diff-binaryfrom
diff-stdin-dir

Conversation

@sylvestre

Copy link
Copy Markdown
Collaborator

Stack created with GitHub Stacks CLI • Give Feedback 💬

@sylvestre
sylvestre added this pull request to stack #319 October 24, 2026 09:22
@github-actions

Copy link
Copy Markdown

GNU diffutils testsuite comparison:

Test results comparison:
  Current:   TOTAL: 33 / PASSED: 11 / FAILED: 18 / SKIPPED: 4
  Reference: TOTAL: 33 / PASSED: 8 / FAILED: 21 / SKIPPED: 4

Changes from main branch:
  TOTAL: +0
  PASSED: +3
  FAILED: -3

Test improvements (3):
  + binary
  + new-file
  + stdin

@codspeed

codspeed Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 9.11%

2 warnings

⚠️ 24 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 19 benchmarks with a significant change ran in a different software environment

Their base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the changes might come from this difference rather than from the code. Open an affected benchmark to see what changed.

See affected benchmarks

⚡ 3 improved benchmarks
❌ 16 regressed benchmarks
✅ 7 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ cmd_diff_release_equal[25000] 24.1 µs 28.1 µs -14.34%
❌ cmd_diff_gnu_equal[25000] 22.6 µs 26.3 µs -14.16%
❌ cmd_diff_gnu_equal[10000] 22.7 µs 26.3 µs -13.78%
❌ cmd_cmp_gnu_equal[25000] 22.6 µs 26 µs -13.19%
❌ cmd_cmp_gnu_equal[10000] 22.7 µs 26 µs -12.98%
❌ cmd_diff_gnu_equal[100] 22.2 µs 25.5 µs -12.83%
❌ cmd_cmp_release_equal[25000] 24.2 µs 27.7 µs -12.81%
❌ cmd_diff_gnu_equal[1000] 22.3 µs 25.5 µs -12.41%
❌ cmd_cmp_release_equal[1000] 24.4 µs 27.8 µs -12.22%
❌ cmd_diff_release_equal[1000] 24.4 µs 27.8 µs -12.21%
❌ cmd_diff_release_equal[10000] 24 µs 27.3 µs -11.99%
❌ cmd_cmp_release_equal[10000] 24.5 µs 27.7 µs -11.61%
❌ cmd_diff_release_equal[100] 24.3 µs 27.4 µs -11.24%
❌ cmd_cmp_gnu_equal[100] 22.4 µs 24.8 µs -9.67%
❌ cmd_cmp_gnu_equal[1000] 22.5 µs 24.8 µs -9.27%
❌ cmd_cmp_release_equal[100] 25.1 µs 27.6 µs -9.17%
⚡ cmp_parser 12.4 µs 10.6 µs +16.84%
⚡ diff_parser 6.1 ms 5.7 ms +6.82%
⚡ cmp_compare_files_different[100] 79.2 µs 76.7 µs +3.29%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing diff-stdin-dir (b5da98a) with diff-binary (b469e0a)1

Open in CodSpeed

Footnotes

  1. No successful run was found on diff-binary (83ebbfc) during the generation of this report, so 04c5b6b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@sylvestre
sylvestre removed this pull request from stack #319 October 24, 2026 13:01
@sylvestre
sylvestre added this pull request to stack #328 October 24, 2026 13:02
@sylvestre
sylvestre marked this pull request as ready for review October 24, 2026 13:14
Copilot AI balanced review requested due to automatic review settings October 24, 2026 13:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Copilot AI balanced review requested due to automatic review settings October 25, 2026 08:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Copilot AI balanced review requested due to automatic review settings November 2, 2026 08:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

1 open issue

Review effort: Lite

Comment thread src/diff.rs
Comment on lines +150 to +174
/// When standard input is a directory, returns the path of the entry in it
/// that has the same name as `other`, provided `other` is not a directory.
/// Entries are reached through `/dev/fd/0`, which only names the directory
/// itself where it links to the open file, as with Linux procfs.
#[cfg(any(target_os = "linux", target_os = "android"))]
fn stdin_directory_entry(other: &OsString) -> Option<OsString> {
use std::os::fd::AsFd;
use std::path::Path;

let stdin_is_dir = io::stdin()
.as_fd()
.try_clone_to_owned()
.ok()
.and_then(|fd| fs::File::from(fd).metadata().ok())
.is_some_and(|metadata| metadata.is_dir());
let other = Path::new(other);
if !stdin_is_dir || other.is_dir() {
return None;
}
Some(
Path::new("/dev/fd/0")
.join(other.file_name()?)
.into_os_string(),
)
}
@sylvestre
sylvestre merged commit 6e0c2c6 into main Nov 3, 2026
39 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants