uutils / diffutils Goto Github PK
View Code? Open in Web Editor NEWDrop-in replacement of diffutils in Rust
License: Apache License 2.0
Drop-in replacement of diffutils in Rust
License: Apache License 2.0
Upstream tests are here:
https://git.savannah.gnu.org/cgit/diffutils.git/tree/tests
When passing in "-" as a parameter on the CLI invokation to use the standard input for either of the input files, in conjunction with the -c
or -u
options, the filenames displayed should be "-", not "/dev/stdin", to be consistent with GNU's implementation:
echo foo > foo
echo bar | /usr/bin/diff -u foo -
--- foo 2024-04-03 18:55:48.837847038 +0200
+++ - 2024-04-03 18:58:47.031319515 +0200
@@ -1 +1 @@
-foo
+bar
echo bar | cargo run --release -- -u foo -
--- foo
+++ /dev/stdin
@@ -1 +1 @@
-foo
+bar
tanmay@tanmay-lenovo:~/Desktop/projects/uutils/diffutils$ diff -c fruits_old.txt fruits_new.txt
*** fruits_old.txt 2024-03-24 23:43:05.189597645 +0530
--- fruits_new.txt 2024-03-24 23:35:08.922581904 +0530
***************
*** 1,3 ****
Apple
! Banana
Cherry
--- 1,3 ----
Apple
! Fig
Cherry
tanmay@tanmay-lenovo:~/Desktop/projects/uutils/diffutils$ cargo run -- -c fruits_old.txt fruits_new.txt
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/diffutils -c fruits_old.txt fruits_new.txt`
*** fruits_old.txt
--- fruits_new.txt
***************
*** 1,3 ****
Apple
! Banana
Cherry
--- 1,3 ----
Apple
! Fig
Cherry
See GNU documentation for the -q
/--brief
option:
When you only want to find out whether files are different, and you don’t care what the differences are, you can use the summary output format. In this format, instead of showing the differences between the files, diff simply reports whether files differ. The --brief (-q) option selects this output format.
This format is especially useful when comparing the contents of two directories. It is also much faster than doing the normal line by line comparisons, because diff can stop analyzing the files as soon as it knows that there are any differences.
Currently uutils' diffutils only implements the diff
executable.
But GNU's diffutils also provide cmp
, diff3
and sdiff
.
This issue is a tracker for the implementation of the sdiff
utility.
Documentation: https://www.gnu.org/software/diffutils/manual/html_node/Invoking-sdiff.html.
Currently uutils' diffutils only implements the diff
executable.
But GNU's diffutils also provide cmp
, diff3
and sdiff
.
This issue is a tracker for the implementation of the cmp
utility.
Documentation: https://www.gnu.org/software/diffutils/manual/html_node/Invoking-cmp.html.
For the normal diff, when range of lines is a single line, the format differs from upstream.
(spotted when trying to run the upstream test suite, specifically that test)
Upstream compacts range "a,a" as just "a":
echo a > a
echo b > b
diff a b | head -1 # outputs "1c1"
Whereas this implementation doesn't compact it:
cargo run a b # incorrectly outputs "1,1c1,1"
Currently uutils' diffutils only implements the diff
executable.
But GNU's diffutils also provide cmp
, diff3
and sdiff
.
This issue is a tracker for the implementation of the diff3
utility.
Documentation: https://www.gnu.org/software/diffutils/manual/html_node/Invoking-diff3.html.
When run on Windows, the code coverage workflow fails because running the tests fails (this is issue #3).
But when run on ubuntu-latest and macos-latest, the workflows get consistently cancelled before they finish running.
See e.g.:
grcov ~ install
step gets cancelledTest
step gets cancelledThe current implementation of main
will always result in an exit code of 0, except when an error is raised, in which case the exit code will be 1.
GNU's implementation differs. Quoting the documentation:
An exit status of 0 means no differences were found, 1 means some differences were found, and 2 means trouble.
(similar to issue #10, but for the ed format)
For the ed diff format, when range of lines is a single line, the format differs from upstream.
Upstream compacts range "a,a" as just "a":
echo a > a
echo b > b
diff -e a b | head -1 # outputs "1c"
Whereas this implementation doesn't compact it:
cargo run -- -e a b # incorrectly outputs "1,1c"
When running cargo test
the following tests fail if ed is not installed:
They fail because they call Command::new("ed")
.
This seems to be failing consistently, at least on pushes to branches in my fork and in PRs.
See e.g. https://github.com/uutils/diffutils/actions/runs/8620214427/job/23626651978?pr=52 :
[2024-04-09T18:03:30.811Z] ['error'] There was an error running the uploader: Error uploading to [https://codecov.io:](https://codecov.io/) Error: There was an error fetching the storage URL during POST: 404 - {'detail': ErrorDetail(string='Unable to locate build via Github Actions API. Please upload with the Codecov repository upload token to resolve issue.', code='not_found')}
Could it be that the upload token has expired?
See GNU documentation for the -s
/--report-identical-files
option:
Normally diff is silent about pairs of files that contain no differences, but if you use the --report-identical-files (-s) option, it reports pairs of identical files.
---- context_diff::tests::test_permutations_reverse stdout ----
thread 'context_diff::tests::test_permutations_reverse' panicked at src\context_diff.rs:653:33:
Output { status: ExitStatus(ExitStatus(3)), stdout: "patching file target/context-diff//alefr\r\n", stderr: "Assertation failed!\r\n\r\nProgram: C:\\Strawberry\\c\\bin\\patch.exe\r\nFile: .\\src\\patch\\2.5.9\\patch-2.5.9-src\\patch.c, Line 354\r\n\r\nExpression: hunk\r\n" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- ed_diff::tests::test_permutations stdout ----
thread 'ed_diff::tests::test_permutations' panicked at src\ed_diff.rs:222:38:
called `Result::unwrap()` on an `Err` value: Error { kind: NotFound, message: "program not found" }
I wonder if this isn't the Windows "patch" command failing with \n ?!
(this goes together with #26)
See GNU documentation for the --tabsize=NUM
option:
diff normally assumes that tab stops are set every 8 print columns, but this can be altered by the --tabsize=columns option.
See GNU documentation for the -t
/--expand-tabs
option:
The first way is to have diff convert all tabs into the correct number of spaces before outputting them;
select this method with the --expand-tabs (-t) option.
See also #27.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.
Cargo.toml
chrono 0.4.38
diff 0.1.13
regex 1.10.4
same-file 1.0.6
unicode-width 0.1.11
pretty_assertions 1
assert_cmd 2.0.14
predicates 3.1.0
tempfile 3.10.1
fuzz/Cargo.toml
libfuzzer-sys 0.4
.github/workflows/ci.yml
actions/checkout v4
actions/checkout v4
actions/checkout v4
actions/checkout v4
actions/checkout v4
actions/upload-artifact v4
actions/checkout v4
codecov/codecov-action v4
.github/workflows/fuzzing.yml
actions/checkout v4
Swatinem/rust-cache v2
actions/checkout v4
Swatinem/rust-cache v2
actions/cache v4
actions/cache v4
.github/workflows/release.yml
actions/checkout v4
actions/upload-artifact v4
actions/checkout v4
swatinem/rust-cache v2
actions/download-artifact v4
actions/upload-artifact v4
actions/checkout v4
actions/download-artifact v4
actions/upload-artifact v4
actions/checkout v4
actions/download-artifact v4
actions/upload-artifact v4
actions/checkout v4
actions/download-artifact v4
ncipollo/release-action v1
ubuntu 20.04
ubuntu 20.04
ubuntu 20.04
In the "About" box on https://github.com/uutils/diffutils it should be "Drop-in" instead of "Dropped in"
Fetching upstream test suite from https://git.savannah.gnu.org/git/diffutils.git
Running 31 tests
./tests/run-upstream-testsuite.sh: line 95: cd: gt-basic.*: No such file or directory
basic FAIL
just like the coreutils, we should run the fuzzers in the CI to make sure we don't regress
https://github.com/uutils/coreutils/blob/main/.github/workflows/fuzzing.yml as example
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.