Repository navigation
diff: add -L/--label - #314
jayhemnani9910 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
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.
| .to_label | ||
| .as_ref() | ||
| .unwrap_or(¶ms.to) | ||
| .to_string_lossy(), |
There was a problem hiding this comment.
same label-or-path expression 4 times here and at line 107, could be a small helper on Params, no?
There was a problem hiding this comment.
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.
| .strip_prefix("--label=") | ||
| .or_else(|| p.strip_prefix("-L")) | ||
| .map(OsString::from), | ||
| None => None, |
There was a problem hiding this comment.
-L<non-utf8> ends up as "unrecognized option" while -L <non-utf8> works, could you please handle it with the bytes?
There was a problem hiding this comment.
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, needs to be rebased |
-L<label> and --label=<label> are matched on the argument's bytes, so a non-UTF-8 label attached to the option is read like a separate one. The label-or-path choice for both files moves into Params::names.
0345957 to
8c613e4
Compare
There was a problem hiding this comment.
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.
|
Rebased on main and moved the test to |
diff -L LABEL/--label=LABELis 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 checkscripts and patch generators that diff temp files rely on it:-L X,-LX,--label Xand--label=Xare 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.-qand-suse the labels inFiles A and B differ/are identical. Normal, ed and side-by-side output have no header, so they are unchanged.Tests: a
parse_paramstest (two labels, and three as an error) and an integration test for-u,-c,-qand 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 warningsand fmt clean. Against GNU diff 3.12, 15 label cases give the same output and exit code; only the error text lacks GNU'sdiff: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).