dandavison / dandavison/delta

🐛 CRLF line endings are stripped from diff

Open
#754 11 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
32.2k
Forks
572
Avg merge
11m
Merged PRs (30d)
1

Description

I'm trying to show CRLF line endings in my diffs (on Linux, to quickly spot if someone committed a file with CRLF instead of LF). Less has the option `-u/--underline-special` to do just that, so I could just use that as pager for delta. However, delta _always_ seems to strip the carriage return byte from diffs, see:

![delta-CRLF](https://user-images.githubusercontent.com/5796100/139351646-83bb2209-6f72-46f6-94a9-b5629a865d8b.png)

Here is a hexdump of both diffs. You can see the CR-bytes (0x0d) are missing.
![delta-CRLF-hexdump2](https://user-images.githubusercontent.com/5796100/139352663-957e4c70-1cb2-45ec-9817-b4093860a2ab.png)

Even if delta strips the ANSI color escape codes (which is turned off here with `--raw`), it should never just delete any other character from the output. Let the pager decide to show those control chars or not.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with a CRLF-containing diff on Linux, using delta with --raw and a pager that displays control characters. Trace the diff-output processing to find where 0x0d is removed; done means the carriage return bytes reach the pager unchanged while ANSI handling still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.