You are not logged in.

#1 Yesterday 20:05:01

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,057

[Solved] how to apply patches on files with non-linux line-ends

Today I tried to apply some patches from oolite forum thread to an oxp (mod) I use in my local Oolite install .

Copied them to a text file and ran patch. The changes were rejected due to different line endings .
(Not very surprising as oolite in 2015 ran on linux, windows and MacOS) .

Since only 1 line is changed and a few are added I copied the stuff line by line manually.

Is there a way to apply diff files created on windows systems to files on linux ?

Last edited by Lone_Wolf (Today 10:32:40)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#2 Yesterday 23:34:43

luser
Member
Registered: 2016-08-27
Posts: 115

Re: [Solved] how to apply patches on files with non-linux line-ends

Open the files in linux text apps such as kwrite, kate, or notepadqq which can change the line endings to either Windows (carriage return + new line) or Linux (new line). You may have to look through the menus to find the commands. In kwrite and kate, "line endings" are under the tools menus.


luser: an epithet applied by Windows users to linux users

Offline

#3 Today 00:56:13

jwodder
Member
Registered: 2026-05-14
Posts: 12

Re: [Solved] how to apply patches on files with non-linux line-ends

Running the `dos2unix` (or possibly `unix2dos`) program from the dos2unix package on the patch file will convert all of its line endings to the appropriate type.

Offline

#4 Today 10:31:24

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,057

Re: [Solved] how to apply patches on files with non-linux line-ends

The file that needed patching used CRLF , so I used unix2dos to convert to that style .
(I prefer staying as close to upstream as possible)

patching still failed but with another message :

(Stripping trailing CRs from patch; use --binary to disable.)

Adding --binary to the patch command solved that and the patched file now works as intended.
Marking as Solved.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

Board footer

Powered by FluxBB