Skip to content

Commit f52ca70

Browse files
committed
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
1 parent 287ddd7 commit f52ca70

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## 0.58 (unreleased)
22

3+
### Diffing
4+
5+
`--strip-cr` now defaults to `on`, so comparing a file with CRLF
6+
endings with a file with unix line endings will not show spurious
7+
changes.
8+
39
## 0.57 (released 1st April 2024)
410

511
### Parsing

src/options.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,11 @@ json: Output the results as a machine-readable JSON array with an element per fi
208208
)
209209
.arg(
210210
Arg::new("strip-cr").long("strip-cr")
211+
.value_name("on/off")
211212
.env("DFT_STRIP_CR")
212-
.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`.")
213+
.possible_values(["on", "off"])
214+
.default_value("on")
215+
.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.")
213216
)
214217
.arg(
215218
Arg::new("check-only").long("check-only")
@@ -717,7 +720,7 @@ pub(crate) fn parse_args() -> Mode {
717720

718721
let set_exit_code = matches.is_present("exit-code");
719722

720-
let strip_cr = matches.is_present("strip-cr");
723+
let strip_cr = matches.value_of("strip-cr") == Some("on");
721724

722725
let check_only = matches.is_present("check-only");
723726

0 commit comments

Comments
 (0)