[fpc-pascal] Git line endings leading to patch problems - was [Semi-OT] Git format patches don't seem to work

Reinier Olislagers reinierolislagers at gmail.com
Fri Oct 7 11:12:09 CEST 2011

On 7-10-2011 9:15, Graeme Geldenhuys wrote:
> On 06/10/2011 20:41, Reinier Olislagers wrote:
> The Git installation under Windows set mine to true (not input).
true it is, see other message ;)
>> So while it could be used, I'd have to remember to run unix2dos over it
>> - that is, if people expect a Windows patch (
> I don't think that is needed. I believe the 'patch' program will sort
> that out by itself. I have sent numerous patches to FPC and Lazarus
> (both those repositories are git ones on my Linux system). Nobody has
> ever complained that the EOL style was wrong. I also don't specify the
> --no-prefix when creating patches. Again, the 'patch' program can handle
> those a/... b/... prefixes for the committer without problems.
Thanks, did a quick test with svn/patch. SVN diff gives Windows line
endings. FPC patch applying diff works.

However, on Windows, the git diff doesn't seem to work, patch as
supplied by FPC on windows freaks out on Unix line endings:
cd /d C:\Development\Fpc\source
notepad packages\fcl-extra\src\win\ServiceManager.pas
rem do some changes
git diff > c:\windows\temp\gitdiff.diff
rem results in unix line endings, see attachment
type c:\windows\temp\gitdiff.diff
diff --git a/packages/fcl-extra/src/win/ServiceManager.pas
index 47bd1cc..af62487 100644
--- a/packages/fcl-extra/src/win/ServiceManager.pas
+++ b/packages/fcl-extra/src/win/ServiceManager.pas
@@ -136,7 +136,8 @@ type
     procedure GetServiceStatus(SHandle : THandle; Var Status :
     procedure GetServiceStatus(ServiceName : String; Var Status :
s); overload;
     Property  Handle : THandle Read FHandle;
-    Property  Acces : DWord read FAccess Write FAccess;
+    Property  Access : DWord read FAccess Write FAccess;
+    Property  Acces : DWord read FAccess Write FAccess; deprecated;
//Kept for
     Property  Services : TServiceEntries Read FServices;
     { Published declarations }

rem now try to reverse the change:
patch --dry-run -R -p1 < c:\windows\temp\gitdiff.diff
Assertion failed: hunk, file patch.c, line 321

This application has requested the Runtime to terminate it in an unusual
Please contact the application's support team for more information.

ok, converted LF=>CRLF into c:\windows\temp\gitdiff_crlf.diff (attached)
patch -R -p1 < c:\windows\temp\gitdiff_crlf.diff

Patch version:
C:\Development\Fpc\source>patch -v
patch 2.5
Copyright 1988 Larry Wall
Copyright 1997 Free Software Foundation, Inc.

This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of this program
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

written by Larry Wall with lots o' patches by Paul Eggert

File modification date 30 May 2005, 21:05, 28.160 bytes
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gitdiff.diff
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20111007/85792710/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gitdiff_crlf.diff
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20111007/85792710/attachment-0001.ksh>

More information about the fpc-pascal mailing list