Commit Graph

329 Commits (efec7595047557eacf73c0e61103fa6532770ebc)

Author SHA1 Message Date
Wilfred Hughes efec759504 Only set language_used after a full syntactic diff
This fixes cases where the language is detected but the file hits the
byte limit.

Fixes #462.
2023-01-14 12:52:08 +07:00
Wilfred Hughes 6eed874362 Clarify field name 2023-01-14 12:30:54 +07:00
Wilfred Hughes 94b6117723 Define an --ignore-comments option and pass to parser
Initial work for #449
2023-01-10 08:47:58 +07:00
Wilfred Hughes 610a6e441d Ensure that textual fallback diffing has a parse language of None
Previously we still passed the parse language after exceeding the
graph limit, leading to incorrect underline highlighting.
2023-01-06 19:07:05 +07:00
Wilfred Hughes e8e5ca8e47 Replace tabs during display, so parsing sees the original source
Fixes #350
2023-01-01 22:44:47 +07:00
Wilfred Hughes 3766b944a8 Define a struct for DiffOptions 2022-12-22 09:11:59 +07:00
Wilfred Hughes cadceb20b0 Show whole file names too with --list-languages 2022-12-19 09:33:53 +07:00
Wilfred Hughes e0fcf2b84b Add a --check-only flag
Fixes #386
2022-12-18 23:55:22 +07:00
Wilfred Hughes abd5e07654 Add a has_syntactic_changes field 2022-12-18 23:21:36 +07:00
Wilfred Hughes b34cdabfdc Prefer has_changes to has_same for clarity 2022-12-18 23:17:05 +07:00
Wilfred Hughes a2f22cb17c Only set the exit code if --exit-code is set
This is important for usage with git log, which terminates on non-zero
exit codes.
2022-12-18 23:11:18 +07:00
Wilfred Hughes b7cfff3f27 Silence some clippy lints 2022-12-18 00:33:27 +07:00
Wilfred Hughes 6a46237bb0 Set the exit code when changes are found
Closes #285
2022-12-18 00:28:54 +07:00
Wilfred Hughes 7dd6bbd609 Implement Default on DisplayOptions 2022-12-17 23:49:18 +07:00
Wilfred Hughes aa067e636b Don't bother storing bytes of binary files 2022-12-17 23:44:48 +07:00
Wilfred Hughes 4b2e601de1 Store hunks in Summary 2022-12-17 23:42:20 +07:00
Wilfred Hughes 84a968cdbb cargo fmt 2022-12-08 10:28:24 +07:00
Wilfred Hughes 554fb18b7c Fix interleaved output when diffing directories
Fixes #437
2022-12-08 09:58:19 +07:00
Wilfred Hughes 923989d1a8 clippy fixes 2022-11-03 22:18:56 +07:00
Wilfred Hughes 02f1cca444 Display stdin CLI arguments as "(stdin)"
This improves display for #389, and makes language detection use
pattern matching on FileArgument rather than comparing literal
strings.
2022-10-14 13:46:30 +07:00
Wilfred Hughes b6ddd152d0 Add the ability to configure how many lines of context are shown
See #242
2022-10-13 12:34:52 +07:00
QuarticCat 2c6972c1b2
Fix more clippy warnings 2022-09-28 05:47:34 +07:00
Wilfred Hughes c638e8ab4b Factor out a file argument type 2022-09-26 09:23:25 +07:00
Wilfred Hughes 40aa103275 Remove obsolete TODO 2022-09-25 12:53:14 +07:00
Wilfred Hughes 3bf7dea04f Fix clippy lint name 2022-09-24 19:38:46 +07:00
Wilfred Hughes 345a88fe53 Support - as a CLI argument
Fixes #389
2022-09-24 17:23:47 +07:00
Wilfred Hughes ee688b43f2 --list-languages should respect --color
Fixes #387
2022-09-21 21:49:24 +07:00
Wilfred Hughes 7d849582ce Pass the detected language to the styling logic 2022-09-15 09:27:34 +07:00
Wilfred Hughes cd6b33ee28 Run the same tab replacement for --dump-ts and --dump-syntax
This is important for getting parse trees consistent with normal
diffing behaviour.
2022-09-09 22:43:13 +07:00
Wilfred Hughes b104c4be10 Fix sliders in a single global pass
Previously we fixed sliders in each 'possibly changed' region. This
meant that we couldn't fix sliders that needed to move outside the
region. The most common case was code of the form `foo, bar, baz`
where `, baz` was unchanged but we wanted to slide to `,`.

We now call `fix_all_sliders` for the toplevel tree on both
sides. This required some minor changes to the slider logic, as the
unchanged/novel regions could occur at any level of the tree.

(It was probably also the case that we were missing slider
opportunities previously, because we terminated as soon as we found an
outer slider for the nested case.)

This change has no performance impact, probably because tree diffing
is vastly more expensive (O(N^2)) than sliders (O(N)).

Fixes #327
2022-09-02 18:10:09 +07:00
Wilfred Hughes c70014a74a Add bold styling to --list-languages to help readability 2022-09-02 12:01:05 +07:00
Wilfred Hughes c0083fdca0 Display file extensions alphabetically 2022-09-02 11:59:30 +07:00
Wilfred Hughes faa5d0a51c Use language pretty-printer for --list-languages 2022-09-02 11:57:05 +07:00
Wilfred Hughes eabefd5612 Factor out language name pretty-printing 2022-09-02 11:56:51 +07:00
Wilfred Hughes fd571c98a7 Add a --list-languages option
Fixes #292
2022-09-02 11:41:05 +07:00
Wilfred Hughes b1b3756fa7 Attempt to detect and decode UTF-16 files too
Closes #345
2022-08-28 15:38:57 +07:00
Wilfred Hughes a247218811 Set +whole-archive on C/C++ libraries
This fixes the build for Rust 1.61+ on some machines. I can reliably
reproduce this locally, but CI does not exhibit this issue (I'm not
sure why).

The Rust compatibility notes document this change:
https://github.com/rust-lang/rust/blob/1.61.0/RELEASES.md#compatibility-notes

and eventually this will be supported by cc:
https://github.com/rust-lang/cc-rs/pull/671

Fixes #339
2022-08-27 17:28:04 +07:00
Wilfred Hughes fb38e7a24f Always use the RHS for language detection
Taking the longest path breaks if we have e.g. /dev/null and foo.py,
because foo.py is shorter.
2022-08-18 23:00:15 +07:00
Wilfred Hughes 38c6718c86 Improve handling of /dev/null paths when there are two CLI argsuments
When git calls us, we always know the file name. If we're called with
two arguments and one is /dev/null, use the other for language
detection and display.
2022-07-11 21:41:04 +07:00
Wilfred Hughes f10cfa00cc Limit the graph size based on the number of predecessors found
Fixes #183
Fixes #306
2022-07-03 18:23:17 +07:00
Wilfred Hughes 081b6fbe64 Move more into display/ 2022-05-25 09:33:53 +07:00
Wilfred Hughes d4285bed7c Move more files into diff/ 2022-05-25 09:31:12 +07:00
Wilfred Hughes c5fe152f25 Define a parse submodule 2022-05-25 09:28:12 +07:00
Wilfred Hughes 373d7d9d81 Define a diff submodule 2022-05-24 09:33:47 +07:00
Wilfred Hughes 8fe0fc13b5 Define a display submodule 2022-05-24 09:25:06 +07:00
Wilfred Hughes bfb2a5035c Pass DisplayOptions in more places 2022-05-13 19:48:26 +07:00
Wilfred Hughes 902c30f6cf Only print rename information when we're called from git
If the user explicitly runs `$ difft old.js new.js` there's no point
talking about renames.
2022-05-10 09:37:36 +07:00
Wilfred Hughes 1a6c5b8e7f Display rename information when before and after paths are different 2022-05-08 11:52:42 +07:00
Wilfred Hughes 4c7ab48091 Pass DisplayOptions as a single argument to print functions 2022-04-29 12:22:08 +07:00
Wilfred Hughes 12ef8f97da Allow syntax highlighting to be disabled
Fixes #265
2022-04-29 12:12:21 +07:00