Enable --strip-cr by default

Line ending differences between input files often leads to confusing
diffs, so remove carriage returns unless explicitly requested.

Fixes #653
Fixes #696
pull/676/merge
Wilfred Hughes 2024-04-09 08:34:58 +07:00
parent 287ddd7b42
commit f52ca706f3
2 changed files with 11 additions and 2 deletions

@ -1,5 +1,11 @@
## 0.58 (unreleased)
### Diffing
`--strip-cr` now defaults to `on`, so comparing a file with CRLF
endings with a file with unix line endings will not show spurious
changes.
## 0.57 (released 1st April 2024)
### Parsing

@ -208,8 +208,11 @@ json: Output the results as a machine-readable JSON array with an element per fi
)
.arg(
Arg::new("strip-cr").long("strip-cr")
.value_name("on/off")
.env("DFT_STRIP_CR")
.help("Remove any carriage return characters before diffing. This can be helpful when dealing with files on Windows that contain CRLF, i.e. `\\r\\n`.")
.possible_values(["on", "off"])
.default_value("on")
.help("Remove any carriage return characters before diffing. This can be helpful when dealing with files on Windows that contain CRLF, i.e. `\\r\\n`.\n\nWhen disabled, difftastic will consider multiline string literals (in code) or mutiline text (e.g. in HTML) to differ if the two input files have different line endings.")
)
.arg(
Arg::new("check-only").long("check-only")
@ -717,7 +720,7 @@ pub(crate) fn parse_args() -> Mode {
let set_exit_code = matches.is_present("exit-code");
let strip_cr = matches.is_present("strip-cr");
let strip_cr = matches.value_of("strip-cr") == Some("on");
let check_only = matches.is_present("check-only");