mookid / diffr Goto Github PK
View Code? Open in Web Editor NEWYet another diff highlighting tool
License: MIT License
Yet another diff highlighting tool
License: MIT License
For performance reason, consecutive whitespaces are considered one word. The downside of this design decision is that when lines differ on the indentation, leading spaces are highlighted, which gives little interesting information:
One possible improvement would be either
Running version 0.1.4 on an amd64 Debian host. The minus line (deleted) is treated as just deletion, all highlighted by diffr, and the \ No newline at end of file
line and the following plus line (addition) are both not coloured at all.
FYI, I've packaged and merged diffr
on NetBSD, https://mail-index.netbsd.org/pkgsrc-changes/2020/11/26/msg224598.html
Thx!
Hey!
First of all, you made a great tool, thank you.
I've brought you some examples where diffr works unexpected.
diffr-weirdness-left.txt
diffr-weirdness-right.txt
So:
, :reward
and :reward ,
is bouncingcampaign_path(object)
should be ignored altogether, and there is a redundant )
highlightedAnd sorry, I don't speak rust and can't help improving it
diffr --help
prints this:
color_spec = face-name + ':' + attributes
attributes = <empty>
| attribute + ':' + attributes
This means that a color_spec
always ends with a colon, but I'm sure this wasn't intended. Maybe reword like this:
color_spec = face-name + ':' + attributes
attributes = attribute
| attribute + ':' + attributes
This is more restrictive than the original grammar because it requires at least one attribute. I don't know if that matches the implementation. But it would be easy to fix by allowing color_spec
to expand to either a bare face-name
or to face-name + ':' + attributes
.
Debian devs are positive about the upload and asked about providing a man page.
looks good so far. Would you maybe consider writing a manpage ? I know that's some effort but since upstream
doesn't have one yet that's a nice opportunity to contribute back.
https://salsa.debian.org/rust-team/debcargo-conf/-/merge_requests/485#note_393733
Not sure how this would be best implemented, but it would be nice to be able to specify different colors/highlighting styles.
- note: AAA
+ note: BBB CCC
In this diff, diffr aligns the space in the removed line with the space in the middle of the added line, rather than the space in the common prefix of both strings.
Is this a limitation of the algorithm or something that can be fixed on your end? It would be nicer to prioritize maximally long common prefixes so that we see "AAA" as removed and "BBB CCC" as added.
Another way to frame the problem would be to minimize the number of snakes. The above diff can be described with 1 snake but diffr_lib currently produces 2.
I haven't looked at the algorithm but it seems like a longest common subsequence tie being broken the wrong way, where maybe a simple heuristic for ties could produce much cleaner diffs.
On an older server running Debian 9 with rustc 1.34.2, pulling the latest git commit and building it fails with the error error[E0658]: use of unstable library feature 'iter_copied' (see issue #57127)
due to the change in 9666edc
I was able to patch the source to undo that change, leading to it successfully building. I used the following command:
perl -i -pe 's/\.copied/.cloned/g' diffr-lib/src/lib.rs diffr-lib/src/test.rs src/main.rs
Why was this change made? Is it needed? I don't know rust at all.
At least on window 7 diffr
seems to hang forever.
As far as I can tell, it seems like diffr
is not aware of encodings in any way and simply operates on and compares individual bytes. (At least I haven’t found any way to specify an encoding.)
This leads to issues with multi-byte encodings such as UTF-8 (not to mention “wide” encodings like UTF-16 or UTF-32) where diffr
will split up bytes belonging to a single encoded character when (for example) the byte sequences for a changed character have a common prefix, so that diffr
will insert different highlighting markup for these constituent characters.
Here is an example:
θ
α
�[0m--- 1.txt 2023-08-04 13:01:35.764424632 -0400�[0m �[0m+++ 2.txt 2023-08-04 13:01:42.592564739 -0400�[0m �[0m@@ -1 +1 @@�[0m �[0m�[31m-�[0m�[0m�[31m��[0m�[0m�[1m�[38;2;255;255;255m�[41m��[0m�[0m�[31m�[0m �[0m�[32m+�[0m�[0m�[32m��[0m�[0m�[1m�[38;2;255;255;255m�[42m��[0m�[0m�[32m�[0m
or, as displayed by less
in my terminal:
I was able to use GIT_PAGER=diffr
but then its not actually paging. Would be cool to see some examples of how to do this.
@mookid I am working on a proposal to include diffr
to the Debian packaging system.
The latest release happened on Mar 20, 2020 where diffr
has a dependency on diffr-lib
, an obstacle to the packaging as the dependency deserves a separate package.
Would you mind releasing version 1.5.0 containing #73, as well as other recent patches? I'll take care of packaging diffr
and sending a proposal to Debian maintainers.
(Since it's a bit hard to describe what I'm looking for without context.)
At a high level, I simply want my eyes to be naturally drawn to the relevant parts of modified lines.
When looking at a diff, I want changed lines to be highlighted green/red as usual.
However, for "modified" lines (i.e. lines which are not added or removed in full) I want to put more emphases on the specific parts of the line that have changed.
Sort of "double-highlighting", first highlighted green/red because the line is added/removed, then highlighted even more because this part of the line is what actually changed.
However, I don't want this "double-highlighting" to apply to new or removed lines, only modified lines.
--color
Faces:Currently there are two main color pallets which can be customized:
added
/removed
, which applies to entire lines, andrefine-added
/refine-removed
, which applies to any added or removed text (within either a modified line or fully added/removed line).refined-added
and refined-removed
are currently applied to completely added or completely removed lines.
For my use case above, it's not currently possible to target changed sections within changed lines, without affecting purely added/removed lines.
I suggest the following two targetable --color faces:
unchanged-added
and unchanged-removed
- for the parts of modified lines which are not changed, andonly-added
and only-removed
- for lines which are added/removed in full.With these, it would be possible to separate full-line changes from changes withing lines, and color each individually.
And for purely backwards-compatibility reasons:
unchanged-added
/unchanged-removed
should inherit from added
/removed
, andonly-added
/only-removed
should inherit from refine-added
/refine-removed
.If all options were specified, then added
/removed
would only apply to the +
/-
at the start of each line (and probably leading whitespace).
(One more note: I've described everything above as added/removed vs changed lines, but it may be more appropriate to implement this on changed blocks instead.)
Thoughts?
Hi, The following tests fail for me when building:
---- test_cli::color_ok stdout ----
thread 'test_cli::color_ok' panicked at 'spawn: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/test_cli.rs:83:17
---- test_cli::color_ok_multiple stdout ----
thread 'test_cli::color_ok_multiple' panicked at 'spawn: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/test_cli.rs:83:17
---- test_cli::debug_flag stdout ----
thread 'test_cli::debug_flag' panicked at 'spawn: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/test_cli.rs:83:17
---- test_cli::color_only_face_name stdout ----
thread 'test_cli::color_only_face_name' panicked at 'spawn: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/test_cli.rs:83:17
failures:
test_cli::color_invalid_attribute_name
test_cli::color_invalid_color_not_done
test_cli::color_invalid_color_value_ansi
test_cli::color_invalid_color_value_name
test_cli::color_invalid_color_value_rgb
test_cli::color_invalid_face_name
test_cli::color_ok
test_cli::color_ok_multiple
test_cli::color_only_face_name
test_cli::debug_flag
Do you happen to know how I can make them pass?
I've put up a repo for demonstrating this: https://github.com/kgrz/diffr-issue
I've seen this happen with dots, hyphens, =
and some words too. Another example:
It'd be handy to show a motivational side-by-side with diff-highlight
(on the same diff) in the readme.
Ideally without requiring additional tools. I tried fc file1 file2 | diffr
but it didn't work (I've heard fc is the equivalent of the diff command from linux). I'm on window 7 so I can't ue WSL, and I'd rather not have to install cygwin just to compare 2 files.
I always use a certain set of switches (--colors refine-added:none:background:0x33,0x66,0x33:bold --colors added:none:background:0x33,0x44,0x33 --colors refine-removed:none:background:0x66,0x33,0x33:bold --colors removed:none:background:0x44,0x33,0x33
) and would like to have that whereever I invoke diffr, currently I have to always work with aliases. An environment variable for default flags as fzf has with FZF_DEFAULT_OPTS
would be great.
Not all terminals support italics, but the one I use does! I think it could make some intuitive styles for refined text.
See https://scripter.co/git-diff-minified-js-and-css/
On the repository https://github.com/gohugoio/hugoDocs, git log -p -- themes/gohugoioTheme/static/dist/app.bundle.js | diffr
takes ~9min on my machine.
One problematic commit: 0960c5fb36e9abcf3b492a523943268e89066543
Explore possible workarounds:
Currently, in diffr's output, the leading +
and -
are highlighted with unique segment highlighting. This is not how GitHub diffs work, where the leading +
and -
receive common segment highlighting.
Relative to GitHub, diffr's current behavior is visually distracting. The leading +
or -
would be better off receiving common segment highlighting.
Non-blocking issue for now but might affect integration in the future.
warning: unnecessary trailing semicolon
--> src/tests_cli.rs:91:6
|
91 | };
| ^ help: remove this semicolon
|
= note: `#[warn(redundant_semicolons)]` on by default
warning: panic message is not a string literal
--> src/tests_cli.rs:25:17
|
25 | / format!(
26 | | "{}: expected empty, got\n\n{}",
27 | | quote_or_empty(prefix),
28 | | quote_or_empty(actual)
29 | | )
| |_________________^
|
= note: `#[warn(non_fmt_panics)]` on by default
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
= note: the assert!() macro supports formatting, so there's no need for the format!() macro here
help: remove the `format!(..)` macro call
|
25 ~
26 | "{}: expected empty, got\n\n{}",
27 | quote_or_empty(prefix),
28 | quote_or_empty(actual)
29 ~
|
warning: panic message is not a string literal
--> src/tests_cli.rs:33:17
|
33 | / format!(
34 | | "{}: expected at least\n\n{}\n\ngot\n\n{}",
35 | | prefix,
36 | | quote_or_empty(exp),
37 | | quote_or_empty(actual)
38 | | )
| |_________________^
|
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
= note: the assert!() macro supports formatting, so there's no need for the format!() macro here
help: remove the `format!(..)` macro call
|
33 ~
34 | "{}: expected at least\n\n{}\n\ngot\n\n{}",
...
37 | quote_or_empty(actual)
38 ~
|
warning: panic message is not a string literal
--> src/tests_cli.rs:42:17
|
42 | / format!(
43 | | "{}: expected\n\n{}\n\ngot\n\n{}",
44 | | prefix,
45 | | quote_or_empty(exp),
46 | | quote_or_empty(actual)
47 | | )
| |_________________^
|
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
= note: the assert!() macro supports formatting, so there's no need for the format!() macro here
help: remove the `format!(..)` macro call
|
42 ~
43 | "{}: expected\n\n{}\n\ngot\n\n{}",
...
46 | quote_or_empty(actual)
47 ~
|
warning: panic message is not a string literal
--> src/tests_cli.rs:94:9
|
94 | / format!(
95 | | "unexpected status: expected {} got {}",
96 | | string_of_status(descr.is_success),
97 | | string_of_status(output.status.success()),
98 | | )
| |_________^
|
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
= note: the assert!() macro supports formatting, so there's no need for the format!() macro here
help: remove the `format!(..)` macro call
|
94 ~
95 | "unexpected status: expected {} got {}",
96 | string_of_status(descr.is_success),
97 | string_of_status(output.status.success()),
98 ~
|
warning: `diffr` (bin "diffr" test) generated 5 warnings
Finished test [unoptimized + debuginfo] target(s) in 2.12s
I'm not getting diffr highlighting when using colordiff -y foo bar | diffr
. Would be neat to support that also.
On the following example:
@
-fn func(a,b,c) {
- x = g(a,b)
- y = if x {
- h(b,c)
- } else {
- 0
- }
- return x + y
-}
+// fn func(a,b,c) {
+// x = g(a,b)
+// y = if x {
+// h(b,c)
+// } else {
+// 0
+// }
+// return x + y
+// }
diffr displays the diff like that:
which is correct, but the highlighting of the whitespace-only tokens is distracting.
Currently, the path that the tests use to find the diffr
binary expects that the tests are being run from cargo:
Lines 59 to 65 in 2c87325
This can cause issues when packaging diffr for distributions (see NixOS/nixpkgs#69505, where doCheck = false
disables running the package's tests).
It would be great if there was a way to provide the path, with $CARGO_MANIFEST_DIR/target/debug/diffr
being a fallback, perhaps through a DIFFR_TESTS_BINARY_PATH
environment variable or something like that.
If I write this Python code:
print()
subprocess.call(['timew', 'untag', '@1'] + old_tags + [':yes'])
subprocess.call(['timew', 'tag', '@1'] + new_tags + [':yes'])
... and then extend it by inserting a new line and modifying the last two lines the following way:
ids = subprocess.check_output(['timew', 'get', 'dom.tracked.ids'])
print()
subprocess.call(['timew', 'untag'] + ids + old_tags + [':yes'])
subprocess.call(['timew', 'tag'] + ids + new_tags + [':yes'])
Then I get some strange output:
The second subprocess.call()
line is colored correctly.
But the first subprocess.call()
line seems to get excessive coloring.
The latter gets a bit reduced if I reduce arguments in the new inserted line, eg:
Now if I reduce it even more, colors seem to start working more or less properly:
I think it would be convenient if the --colors
parameter wasn't the only way to customize the colors. Maybe if --colors
is not provided, look in an environment variable? I guess using a config file is over-engineered.
For the time being, a short wrapper shell script will do the trick, of course.
example failed parse:
@@@ -54,9 -55,9 +55,13 @@@
this happens during merges.
When running git commit --verbose
git opens vim with
the diff so you can see whats being commited.
But this diff is not filtered using diffr.
I searched on the git documentation and could not find anything.
Can word-level diff be ignored for lines which are completely new or completely removed from a given diff? With the default configuration, added/removed lines are highlighted in there entirety.
I am only getting bold text for all changes, no colors. Are there some term requirements? Or required options that I am missing? diff-highlight
works fine (by default)
In upcoming release cargo-crev
will have cargo crev diff
command. Underneath it calls diff -r <src> <dst>
on two directories. I was thinking ... "I'll start with this, and switch to some library later". And now I see reddit post about diffr
. :)
Anyway... Please split this crate in two (or more) parts: one binary and library. This way I can just import it, and not rely on diff
binary (plus the better formatting, nice!). If you had some examples / other crates for actually generating diff
between directories, that would be awesome too.
Could please help me compiling your project a bit :)
First, I have rustup
1.18.3 (435397f48 2019-05-22) and cargo
1.36.0 (c4fcfb725 2019-05-15) installed. And $HOME/.cargo/bin
is present in my $PATH
.
Now, I cloned your repository, and if I try to run cargo build
in it, it installs crates (I see those in $HOME/.cargo/registry/index
) and then fails saying "error: Unknown option".
And if I try to run rusts src/main.rs
, it fails saying something like the following:
error[E0432]: unresolved import `clap`
--> src/main.rs:1:5
|
1 | use clap::{App, Arg};
| ^^^^ maybe a missing `extern crate clap;`?
error[E0433]: failed to resolve: maybe a missing `extern crate termcolor;`?
--> src/main.rs:7:5
|
7 | use termcolor::{
| ^^^^^^^^^ maybe a missing `extern crate termcolor;`?
[rest skipped]
As if it doesn't see installed crates from $HOME/.cargo/registry
for some reason... So, what could be wrong here? Any hints may be? :)
Thanks.
Is there a a way to highlight trailing ws in git logs using diffr?
I have a few commits that failed on jenkins due to the fact that I've missed those since ws is indistinguishable from normal changes and doesn't stand out except that lines are a tad longer...
This is what i'm using today
[core]
editor = '/usr/bin/nvim'
pager = diffr --colors refine-added:none:background:0x33,0x99,0x33:bold --colors added:none:background:0x33,0x55,0x33 --colors refine-removed:none:background:0x99,0x33,0x33:bold --colors removed:none:background:0x55,0x33,0x33 | less -R
[interactive]
difffilter = diffr --colors refine-added:none:background:0x33,0x99,0x33:bold --colors added:none:background:0x33,0x55,0x33 --colors refine-removed:none:background:0x99,0x33,0x33:bold --colors removed:none:background:0x55,0x33,0x33
Run inside schroot, Debian unstable.
warning: `diffr` (bin "diffr" test) generated 5 warnings
Finished test [unoptimized + debuginfo] target(s) in 2.12s
Running `/<<PKGBUILDDIR>>/target/x86_64-unknown-linux-gnu/debug/deps/diffr-0adc4b1ff5ef71b1`
running 38 tests
test diffr_lib::tests_lib::compress_path_test ... ok
test diffr_lib::tests_lib::diff_sequences_test_1 ... ok
test diffr_lib::tests_lib::diff_sequences_test_2 ... ok
test diffr_lib::tests_lib::diff_sequences_test_3 ... ok
test diffr_lib::tests_lib::diff_sequences_test_4 ... ok
test diffr_lib::tests_lib::diff_sequences_test_7 ... ok
test diffr_lib::tests_lib::diff_sequences_test_6 ... ok
test diffr_lib::tests_lib::find_splitting_point_test ... ok
test diffr_lib::tests_lib::diff_sequences_test_5 ... ok
test diffr_lib::tests_lib::issue15_2 ... ok
test diffr_lib::tests_lib::diff_sequences_test_8 ... ok
test diffr_lib::tests_lib::range_equality_test ... ok
test diffr_lib::tests_lib::split_lines_test ... ok
test diffr_lib::tests_lib::issue27 ... ok
test diffr_lib::tests_lib::split_lines_append_test ... ok
test diffr_lib::tests_lib::test_get_lcs ... ok
test diffr_lib::tests_lib::issue15 ... ok
test diffr_lib::tests_lib::tokenize_test ... ok
test tests_app::first_after_escape_test ... ok
test tests_app::parse_line_number_test ... ok
test diffr_lib::tests_lib::test_optimize_partition ... ok
test tests_app::skip_all_escape_code_test ... ok
test tests_app::skip_token_test ... ok
test tests_app::test_width ... ok
test diffr_lib::tests_lib::to_usize_checked_negative_test - should panic ... ok
test tests_cli::color_invalid_attribute_name ... FAILED
test tests_cli::color_invalid_color_not_done ... FAILED
test tests_cli::color_invalid_color_value_ansi ... FAILED
test tests_cli::color_invalid_color_value_name ... FAILED
test tests_cli::color_invalid_color_value_rgb ... FAILED
test tests_cli::color_ok ... FAILED
test tests_cli::color_invalid_face_name ... FAILED
test tests_cli::color_only_face_name ... FAILED
test tests_cli::color_ok_multiple ... FAILED
test tests_cli::debug_flag ... FAILED
test tests_cli::line_numbers_style ... FAILED
test tests_cli::test_bad_argument ... FAILED
test diffr_lib::tests_lib::test_lcs_random ... ok
failures:
---- tests_cli::color_invalid_attribute_name stdout ----
thread 'tests_cli::color_invalid_attribute_name' panicked at 'spawn: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/tests_cli.rs:83:29
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.63.0/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.63.0/library/core/src/panicking.rs:142:14
2: core::result::unwrap_failed
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1805:5
3: core::result::Result<T,E>::expect
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1055:23
4: diffr::tests_cli::test_cli
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:83:17
5: diffr::tests_cli::color_invalid_attribute_name
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:140:5
6: diffr::tests_cli::color_invalid_attribute_name::{{closure}}
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:139:1
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
8: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- tests_cli::color_invalid_color_not_done stdout ----
thread 'tests_cli::color_invalid_color_not_done' panicked at 'spawn: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/tests_cli.rs:83:29
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.63.0/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.63.0/library/core/src/panicking.rs:142:14
2: core::result::unwrap_failed
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1805:5
3: core::result::Result<T,E>::expect
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1055:23
4: diffr::tests_cli::test_cli
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:83:17
5: diffr::tests_cli::color_invalid_color_not_done
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:180:5
6: diffr::tests_cli::color_invalid_color_not_done::{{closure}}
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:179:1
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
8: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- tests_cli::color_invalid_color_value_ansi stdout ----
thread 'tests_cli::color_invalid_color_value_ansi' panicked at 'spawn: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/tests_cli.rs:83:29
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.63.0/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.63.0/library/core/src/panicking.rs:142:14
2: core::result::unwrap_failed
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1805:5
3: core::result::Result<T,E>::expect
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1055:23
4: diffr::tests_cli::test_cli
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:83:17
5: diffr::tests_cli::color_invalid_color_value_ansi
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:160:5
6: diffr::tests_cli::color_invalid_color_value_ansi::{{closure}}
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:159:1
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
8: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- tests_cli::color_invalid_color_value_name stdout ----
thread 'tests_cli::color_invalid_color_value_name' panicked at 'spawn: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/tests_cli.rs:83:29
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.63.0/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.63.0/library/core/src/panicking.rs:142:14
2: core::result::unwrap_failed
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1805:5
3: core::result::Result<T,E>::expect
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1055:23
4: diffr::tests_cli::test_cli
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:83:17
5: diffr::tests_cli::color_invalid_color_value_name
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:150:5
6: diffr::tests_cli::color_invalid_color_value_name::{{closure}}
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:149:1
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
8: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- tests_cli::color_invalid_color_value_rgb stdout ----
thread 'tests_cli::color_invalid_color_value_rgb' panicked at 'spawn: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/tests_cli.rs:83:29
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.63.0/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.63.0/library/core/src/panicking.rs:142:14
2: core::result::unwrap_failed
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1805:5
3: core::result::Result<T,E>::expect
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1055:23
4: diffr::tests_cli::test_cli
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:83:17
5: diffr::tests_cli::color_invalid_color_value_rgb
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:170:5
6: diffr::tests_cli::color_invalid_color_value_rgb::{{closure}}
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:169:1
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
8: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- tests_cli::color_ok stdout ----
thread 'tests_cli::color_ok' panicked at 'spawn: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/tests_cli.rs:83:29
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.63.0/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.63.0/library/core/src/panicking.rs:142:14
2: core::result::unwrap_failed
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1805:5
3: core::result::Result<T,E>::expect
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1055:23
4: diffr::tests_cli::test_cli
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:83:17
5: diffr::tests_cli::color_ok
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:190:5
6: diffr::tests_cli::color_ok::{{closure}}
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:189:1
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
8: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- tests_cli::color_invalid_face_name stdout ----
thread 'tests_cli::color_invalid_face_name' panicked at 'spawn: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/tests_cli.rs:83:29
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.63.0/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.63.0/library/core/src/panicking.rs:142:14
2: core::result::unwrap_failed
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1805:5
3: core::result::Result<T,E>::expect
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1055:23
4: diffr::tests_cli::test_cli
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:83:17
5: diffr::tests_cli::color_invalid_face_name
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:120:5
6: diffr::tests_cli::color_invalid_face_name::{{closure}}
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:119:1
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
8: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- tests_cli::color_only_face_name stdout ----
thread 'tests_cli::color_only_face_name' panicked at 'spawn: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/tests_cli.rs:83:29
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.63.0/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.63.0/library/core/src/panicking.rs:142:14
2: core::result::unwrap_failed
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1805:5
3: core::result::Result<T,E>::expect
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1055:23
4: diffr::tests_cli::test_cli
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:83:17
5: diffr::tests_cli::color_only_face_name
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:130:5
6: diffr::tests_cli::color_only_face_name::{{closure}}
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:129:1
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
8: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- tests_cli::color_ok_multiple stdout ----
thread 'tests_cli::color_ok_multiple' panicked at 'spawn: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/tests_cli.rs:83:29
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.63.0/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.63.0/library/core/src/panicking.rs:142:14
2: core::result::unwrap_failed
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1805:5
3: core::result::Result<T,E>::expect
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1055:23
4: diffr::tests_cli::test_cli
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:83:17
5: diffr::tests_cli::color_ok_multiple
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:200:5
6: diffr::tests_cli::color_ok_multiple::{{closure}}
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:199:1
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
8: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- tests_cli::debug_flag stdout ----
thread 'tests_cli::debug_flag' panicked at 'spawn: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/tests_cli.rs:83:29
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.63.0/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.63.0/library/core/src/panicking.rs:142:14
2: core::result::unwrap_failed
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1805:5
3: core::result::Result<T,E>::expect
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1055:23
4: diffr::tests_cli::test_cli
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:83:17
5: diffr::tests_cli::debug_flag
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:110:5
6: diffr::tests_cli::debug_flag::{{closure}}
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:109:1
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
8: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- tests_cli::line_numbers_style stdout ----
thread 'tests_cli::line_numbers_style' panicked at 'spawn: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/tests_cli.rs:83:29
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.63.0/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.63.0/library/core/src/panicking.rs:142:14
2: core::result::unwrap_failed
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1805:5
3: core::result::Result<T,E>::expect
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1055:23
4: diffr::tests_cli::test_cli
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:83:17
5: diffr::tests_cli::line_numbers_style
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:218:5
6: diffr::tests_cli::line_numbers_style::{{closure}}
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:214:1
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
8: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- tests_cli::test_bad_argument stdout ----
thread 'tests_cli::test_bad_argument' panicked at 'spawn: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/tests_cli.rs:83:29
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.63.0/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.63.0/library/core/src/panicking.rs:142:14
2: core::result::unwrap_failed
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1805:5
3: core::result::Result<T,E>::expect
at /usr/src/rustc-1.63.0/library/core/src/result.rs:1055:23
4: diffr::tests_cli::test_cli
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:83:17
5: diffr::tests_cli::test_bad_argument
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:248:5
6: diffr::tests_cli::test_bad_argument::{{closure}}
at /usr/share/cargo/registry/diffr-0.1.5/src/tests_cli.rs:247:1
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
8: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
failures:
tests_cli::color_invalid_attribute_name
tests_cli::color_invalid_color_not_done
tests_cli::color_invalid_color_value_ansi
tests_cli::color_invalid_color_value_name
tests_cli::color_invalid_color_value_rgb
tests_cli::color_invalid_face_name
tests_cli::color_ok
tests_cli::color_ok_multiple
tests_cli::color_only_face_name
tests_cli::debug_flag
tests_cli::line_numbers_style
tests_cli::test_bad_argument
test result: FAILED. 26 passed; 12 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.05s
error: test failed, to rerun pass `--bin diffr`
dh_auto_test: error: /usr/share/cargo/bin/cargo test --all returned exit code 101
make[1]: *** [debian/rules:6: override_dh_auto_test] Error 25
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
make: *** [debian/rules:3: binary] Error 2
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2
IntelliJ Idea Terminal:
Konsole:
I understand that the tool should by default only highlight the character changes and leave everything else untouched - however, white on bright green is barely legible, especially if, as in the first two examples the white isn't a pure white.
Couldn't you use a dark green background or smth?
Seems this originates from #31 - if the reason is that you don't want to add any colors, maybe you could make the text on the green background black again.
I figured, the reason is that "black" color more likely to blend with the dark "green" and "red" than white color.
Idk why, but in my case it is a bright and not a dark green ^^
diffr
seems to highlight unchanged parts. At least when there are a different number of leading spaces and dashes following those spaces.
$ diff -u <(printf ' -01234;\n --abc;\n --def;\n') <(printf ' -01234;\n --abc;\n --def;\n') | diffr
--- /dev/fd/63 2019-07-22 10:03:08.009841265 +0200
+++ /dev/fd/62 2019-07-22 10:03:08.013841298 +0200
@@ -1,3 +1,3 @@
- -01234;
- --abc;
- --def;
+ -01234;
+ --abc;
+ --def;
The second dash in --def
is colored in read, which shouldn't be the case.
$ diff -u <(printf ' -01234;\n --abc;\n --def;\n --jkl;\n --poi;\n') <(printf ' -01234;\n --abc;\n --def;\n --jkl;\n --poi;\n') | diffr
--- /dev/fd/63 2019-07-22 10:10:29.065613277 +0200
+++ /dev/fd/62 2019-07-22 10:10:29.065613277 +0200
@@ -1,5 +1,5 @@
- -01234;
- --abc;
- --def;
- --jkl;
- --poi;
+ -01234;
+ --abc;
+ --def;
+ --jkl;
+ --poi;
In this case the following dashes are highligthed:
-01234
: first dash--abc
: second dash--poi
: second dashIn both cases it should only highlight the leading spaces as that is the only part that changed.
With underscores the highlighting works fine:
$ diff -u <(printf ' _01234;\n __abc;\n __def;\n __jkl;\n __poi;\n') <(printf ' _01234;\n __abc;\n __def;\n __jkl;\n __poi;\n') | diffr
--- /dev/fd/63 2019-07-22 10:25:01.873156289 +0200
+++ /dev/fd/62 2019-07-22 10:25:01.877156323 +0200
@@ -1,5 +1,5 @@
- _01234;
- __abc;
- __def;
- __jkl;
- __poi;
+ _01234;
+ __abc;
+ __def;
+ __jkl;
+ __poi;
It would be nice if diffr
could support diff3 as generated by git during merges.
Currently it simply ignores changes from on side.
diffr highlights the whole lies instead of the last character of each line:
--- /dev/fd/63 2020-04-17 11:50:36.529229290 +0200
+++ /dev/fd/62 2020-04-17 11:50:36.529229290 +0200
@@ -1,27 +1,27 @@
-ATCACGG
-CGATGTG
-TTAGGCG
-TGACCAG
-ACAGTGG
-GCCAATG
-CAGATCG
-ACTTGAG
-GATCAGG
-TAGCTTG
-GGCTACG
-CTTGTAG
-AGTCAAG
+ATCACGA
+CGATGTA
+TTAGGCA
+TGACCAA
+ACAGTGA
+GCCAATA
+CAGATCA
+ACTTGAA
+GATCAGA
+TAGCTTA
+GGCTACA
+CTTGTAA
+AGTCAAC
AGTTCCG
ATGTCAG
-CCGTCCG
-GTAGAGG
-GTCCGCG
-GTGAAAG
-GTGGCCG
+CCGTCCC
+
+GTCCGCA
+GTGAAAC
+GTGGCCT
GTTTCGG
-CGTACGG
-GAGTGGG
-GGTAGCG
-ACTGATG
-ATGAGCG
-ATTCCTG
+CGTACGT
+GAGTGGA
+
+ACTGATA
+
+ATTCCTT
Not sure if this is out of scope for this project but I've always wanted line numbers for diffs instead of the @@ -xxx,y +xxx,y @@
syntax. Would be especially useful when there are large chunks.
Something like
diff --git a/src/index.js b/src/index.js
index d46a912..d34f309 100644
--- a/src/index.js
+++ b/src/index.js
@@ -13,7 +13,8 @@ const Button = ({ value, color, events }) => {
13: };
14: const textStyle = {
15: flex: 0,
- 16: fontFamily: 'sans-serif',
+ 16: fontFamily: 'serif',
+ 17: color: white,
18: };
19: return (
20: <div {...events} style={containerStyle}>
It might be useful to highlight tab characters (if only for Makefiles).
Also git allows to highlight trailing whitespaces, which is lost in diffr (because we trim all color codes).
First of all, thanks for the better diff-highlight utility!
I was comparing diffr
with the standard diff-highlight
as provided by git, and although diffr
gives better results, I noted its output somehow was less comfortable to look at. See:
git's diff-highlight
:
diffr
:
I figured, the reason is that "black" color more likely to blend with the dark "green" and "red" than white color. The diff-highlight
for that reason makes foreground letters white.
I think, it would make sense for diffr
to also use by default a color that blends less with the background, for example "white".
Currently, diffs obtained from git with the --color-moved flag parsed and re-highlighted completely, and the code move special highlighting is lost.
The color-moved information should be preserved.
On a diff with very long lines, diffr helps but reading unified diff is still hard.
Implement a flag that wraps long lines before highlighting differences. This is almost as running diff -u file1 file2 | fold | diffr
instead of diff -u file1 file2 | diffr
, except that the fold command is aware of leading "+/-" characters.
see https://blog.robertelder.org/terminal-diff-tool/ that tries to do something clever.
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.