﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
22	diff, patch and EOL style	dmik		"There is a fundamental problem with `diff`, `patch` and line endings. It happens when line endings in either party do not match the system-default (CRLF in case of OS/2). With the default diff/patch behavior, the following happens:

- everything (LF, CRLF) is accepted on input (files, patches)
- patches apply cleanly even if there is a mismatch in EOL style
- output is always CRLF

The worst case in this scenario is when your file's endings are LF. After doing a diff/patch cycle on such a file all line endings will be unconditionally converted to CRLF. This is annoying in many cases.

There is one solution. Both tools support the `--binary` option that turns off automatic CRLF<->LF conversion. As a result, you will get the following behavior:

- all input files must have the same line ending style (either LF or CRLF)
- patches will not apply if EOL style of the target differs from the source
- output has the same EOL style as input

This solves the above problem with the LF file but it breaks patching if e.g. the patch file's EOL style gets accidentally changed while transferring (in an email message or in a ticket's comment).

A better solution might be to combine the above two behaviors:
- in `diff`, accept any EOL style when comparing files and write a patch in system default EOL style
- in `patch`, accept any EOL style of both the patch and the target file and preserve EOL style of the target on output after patching it"	enhancement	new	major	dev tools	*none		low			
