Skip to content

Commit

Permalink
Enable --strip-cr by default
Browse files Browse the repository at this point in the history
Line ending differences between input files often leads to confusing
diffs, so remove carriage returns unless explicitly requested.

Fixes #653
Fixes #696
  • Loading branch information
Wilfred committed Apr 9, 2024
1 parent 287ddd7 commit f52ca70
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 5 additions & 2 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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");

Expand Down

0 comments on commit f52ca70

Please sign in to comment.