[fpc-pascal] Re: 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 16:34:25 CEST 2011
On 7-10-2011 11:28, Marco van de Voort wrote:
> I usually apply patches on FreeBSD, and in rarer cases Linux.
>
> Even up to date patch doesn't always process lineendings properly btw. I
> have to dos2unix often on *nix too.
>
> Recently a lot of patches with incorrect filenames, or no filenames if the
> patch is for a single file, or even not in universal format have been
> submitted, and it takes some work (doable, but annoying) to apply them.
Ok, so there's some options:
1. Get a better patch.exe on Windows that deals with LF.
2. Output patches using CRLF. Inconvenience Linux/Unix users
3. Output patches using LF. Inconvenience Windows users
I'm going with option 2, as I'm running Windows and people will probably
excpect CRLF patches from me (in line with SVN diff).
(Of course, I could always use 3 and use git patch...)
Created a batch file fpdiff.cmd:
@echo off
rem Uses git on windows to create a patch with crlf endings.
rem Requirements:
rem git, linespace converter program (sfk, unix2dos)
rem git core.autocrlf setting is true
rem Tested git core.whitespace trailing-space,space-before-tab,cr-at-eol
but had no effect
set OUTPUTNAME=your.diff
del %OUTPUTNAME% > NUL 2>1
rem Git diff gives Unix LF line endings;
rem we're on Windows so convert to CRLF
rem Also, use --no-prefix to strip git prefixes from path
rem Redirect errors to bit bucket
rem YOU NEED TO USE CALL to call msysgit git commands:
rem http://osdir.com/ml/version-control.msysgit/2008-04/msg00012.html
call git diff --unified=3 --no-prefix > %OUTPUTNAME% 2>NUL
rem Use swiss file knife to convert, but could
rem also use cygwin unix2dos
sfk lf-to-crlf %OUTPUTNAME%
echo Done, output in %OUTPUTNAME%
Gives output like attachment.
I think I'm satisfied. Hope the committers will be too, when I submit
the next patch...
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: your.diff
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20111007/19bb4d97/attachment.ksh>
More information about the fpc-pascal
mailing list