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 — diff: add -L/--label by jayhemnani9910 · Pull Request #314 · uutils/diffutils

Conversation

@jayhemnani9910

@jayhemnani9910 jayhemnani9910 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

diff -L LABEL / --label=LABEL is rejected (unrecognized option, exit 2). It names the inputs in the ---/+++ and ***/--- headers instead of the file name and time; git's external diff drivers, make check scripts and patch generators that diff temp files rely on it:

$ diff -u --label a/conf --label b/conf /tmp/x1 /tmp/x2
GNU:  --- a/conf
      +++ b/conf
      @@ -1,2 +1,2 @@ ...
main: unrecognized option '--label'   (exit 2)

-L X, -LX, --label X and --label=X are accepted anywhere among the arguments. The first labels the from-file and the second the to-file; a third is an error (too many file label options, exit 2), as in GNU. A labelled header has no timestamp. -q and -s use the labels in Files A and B differ / are identical. Normal, ed and side-by-side output have no header, so they are unchanged.

Tests: a parse_params test (two labels, and three as an error) and an integration test for -u, -c, -q and a third label; the integration test fails on main. cargo test: 133 unit and 24 integration tests pass (132 and 23 on main), cargo clippy -- -D warnings and fmt clean. Against GNU diff 3.12, 15 label cases give the same output and exit code; only the error text lacks GNU's diff: prefix, like the crate's other errors. The upstream GNU suite gives the same per-test results as main (8 pass, 21 fail, 4 skip).

Sorry, something went wrong.

Uh oh!

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

All reactions
Copilot AI balanced review requested due to automatic review settings October 24, 2026 07:20
Copilot AI reviewed Oct 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

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

All reactions
sylvestre
sylvestre reviewed Oct 24, 2026
View reviewed changes
Comment thread src/diff.rs Outdated
.to_label
.as_ref()
.unwrap_or(&params.to)
.to_string_lossy(),

@sylvestre sylvestre Oct 24, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

same label-or-path expression 4 times here and at line 107, could be a small helper on Params, no?

Sorry, something went wrong.

Uh oh!

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

All reactions

@jayhemnani9910 jayhemnani9910 Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done in 8c613e4: Params::names() returns the label or path for both files, and the two messages in diff.rs use it. The context and unified headers keep header_name, since they also print the modification time when there is no label.

Sorry, something went wrong.

Uh oh!

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

All reactions
sylvestre
sylvestre reviewed Oct 24, 2026
View reviewed changes
Comment thread src/params.rs Outdated
.strip_prefix("--label=")
.or_else(|| p.strip_prefix("-L"))
.map(OsString::from),
None => None,

@sylvestre sylvestre Oct 24, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

-L<non-utf8> ends up as "unrecognized option" while -L <non-utf8> works, could you please handle it with the bytes?

Sorry, something went wrong.

Uh oh!

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

All reactions

@jayhemnani9910 jayhemnani9910 Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Fixed in 8c613e4: -L<label> and --label=<label> are now matched on the argument's bytes, so -L$'\xffold' is read as a label like -L $'\xffold'. Added labels_non_utf8, which fails without the change.

The header still prints a non-UTF-8 label through to_string_lossy, the same as file names today, where GNU writes the raw bytes. I left that for a separate change.

Sorry, something went wrong.

Uh oh!

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

All reactions
@sylvestre

sylvestre commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator

sorry, needs to be rebased

All reactions

Sorry, something went wrong.

Uh oh!

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

@jayhemnani9910
jayhemnani9910 force-pushed the diff-label branch from 0345957 to 8c613e4 Compare October 24, 2026 14:20
Copilot AI balanced review requested due to automatic review settings October 24, 2026 14:20
Copilot AI reviewed Oct 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

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

All reactions
@jayhemnani9910

jayhemnani9910 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on main and moved the test to tests/by-util/test_diff.rs. cargo test passes, and cargo clippy -- -D warnings and cargo fmt --check are clean.

All reactions

Sorry, something went wrong.

Uh oh!

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

sylvestre
sylvestre reviewed Oct 25, 2026
View reviewed changes
Comment thread tests/by-util/test_diff.rs Outdated
(
vec!["-q", "-L", "old", "-L", "new"],
"Files old and new differ\n",
),

@sylvestre sylvestre Oct 25, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

could you please also test -s with labels and a trailing -L with no value (the 'requires an argument' path)?

Sorry, something went wrong.

Uh oh!

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

All reactions

@jayhemnani9910 jayhemnani9910 Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Added both to labels_replace_file_names in 500b7b3: -s -L old -L new on identical files prints Files old and new are identical with exit 0, and a trailing -L exits 2 with "option '-L' requires an argument". Same exit codes and -s output as GNU diff 3.12 (GNU words the missing-argument message differently).

Sorry, something went wrong.

Uh oh!

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

All reactions
Copilot AI balanced review requested due to automatic review settings October 25, 2026 10:21
Copilot AI reviewed Oct 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

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

All reactions
@jayhemnani9910

jayhemnani9910 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on main and squashed into one commit. Labels now go through write_file_header and are written as they are, with no quoting, and diff -r uses them in its diff line too, as GNU does. Added a test for each. cargo test passes, and 7 label cases match GNU diff 3.12.

All reactions

Sorry, something went wrong.

Uh oh!

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

@jayhemnani9910
jayhemnani9910 force-pushed the diff-label branch from 500b7b3 to 4f2d455 Compare November 3, 2026 13:54
Copilot AI balanced review requested due to automatic review settings November 3, 2026 13:54
Copilot AI reviewed Nov 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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. Try requesting a review at a lower effort level.

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.

Sorry, something went wrong.

Uh oh!

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

All reactions
@sylvestre

sylvestre commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

sorry but it needs to be rebased

All reactions

Sorry, something went wrong.

Uh oh!

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

@jayhemnani9910
jayhemnani9910 force-pushed the diff-label branch from 4f2d455 to 9c40848 Compare November 11, 2026 07:40
@jayhemnani9910

jayhemnani9910 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on main (bb44ff5), still one commit. The conflict was in Params, next to the new from_missing/to_missing fields, and both are kept. cargo test passes, and cargo fmt --check and cargo clippy -- -D warnings are clean. -u, -c, -s, -q and -N with -L old -L new match GNU diff 3.12, including a missing file with -N.

All reactions

Sorry, something went wrong.

Uh oh!

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

Copilot AI balanced review requested due to automatic review settings November 11, 2026 07:40
Copilot AI reviewed Nov 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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. Try requesting a review at a lower effort level.

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.

Sorry, something went wrong.

Uh oh!

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

All reactions
@jayhemnani9910
diff: add -L/--label
7c9ca07
@jayhemnani9910
jayhemnani9910 force-pushed the diff-label branch from 9c40848 to 7c9ca07 Compare November 12, 2026 19:01
Copilot AI balanced review requested due to automatic review settings November 12, 2026 19:01
Copilot AI reviewed Nov 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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. Try requesting a review at a lower effort level.

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.

Sorry, something went wrong.

Uh oh!

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

All reactions
@codspeed

codspeed Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 10.48%

3 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

⚠️ 16 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 16 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

⚡ 16 improved benchmarks
✅ 10 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ cmd_cmp_release_equal[25000] 27.3 µs 24 µs +13.7%
⚡ cmd_diff_release_equal[25000] 27.8 µs 24.5 µs +13.43%
⚡ cmd_cmp_release_equal[1000] 27.4 µs 24.1 µs +13.33%
⚡ cmd_cmp_release_equal[10000] 27.3 µs 24.2 µs +12.9%
⚡ cmd_cmp_release_equal[100] 27.2 µs 24.1 µs +12.81%
⚡ cmd_cmp_gnu_equal[25000] 25.8 µs 23 µs +12.21%
⚡ cmd_cmp_gnu_equal[10000] 25.8 µs 23 µs +12.21%
⚡ cmd_diff_release_equal[1000] 27.5 µs 24.6 µs +11.76%
⚡ cmd_diff_release_equal[10000] 26.9 µs 24.5 µs +9.95%
⚡ cmd_diff_gnu_equal[10000] 26 µs 24 µs +8.55%
⚡ cmd_diff_gnu_equal[25000] 26.1 µs 24 µs +8.53%
⚡ cmd_cmp_gnu_equal[100] 24.6 µs 22.8 µs +7.86%
⚡ cmd_cmp_gnu_equal[1000] 24.5 µs 22.7 µs +7.85%
⚡ cmd_diff_gnu_equal[100] 25.2 µs 23.4 µs +7.81%
⚡ cmd_diff_release_equal[100] 27.1 µs 25.2 µs +7.68%
⚡ cmd_diff_gnu_equal[1000] 25.2 µs 23.4 µs +7.53%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing jayhemnani9910:diff-label (7c9ca07) with main (82a5d8f)

Open in CodSpeed
All reactions

Sorry, something went wrong.

Uh oh!

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sylvestre sylvestre sylvestre left review comments
Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot 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

@jayhemnani9910 @sylvestre
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 01402520 — 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.