[fpc-pascal] [Semi-OT] Git format patches don't seem to work

2011-10-04 Thread Reinier Olislagers
Hi all,

Having some trouble creating patches that actually work.
(On Windows)
I've been using git to get FPC trunk and
git diff --no-prefix  %temp%\mypatch.diff
rem --no-prefix : Do not show any source or destination prefix.
to create patches.

Using Msysgit:
git --version
git version 1.7.6.msysgit.0

However, if I try to apply the patch with
cd /d c:\development\fpc\source
rem use fpc binutils patch
patch -p0  %temp%\mypatch.diff
I often get a nasty error:
patching file `packages/fcl-extra/src/win/ServiceManager.pas'
Assertion failed: hunk, file patch.c, line 321

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

Patch version:
patch --version
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

As an alternative, I've used diff with two directories like this:
diff -u --minimal --recursive --unified -N olddir newdir  mypatch.diff
but that may have some issues with Linux/Windows line endings..

Any suggestions for creating/applying better patches using git or diff?

Thanks,
Reinier
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] [Semi-OT] Git format patches don't seem to work

2011-10-04 Thread Marco van de Voort
In our previous episode, Reinier Olislagers said:
 Having some trouble creating patches that actually work.
 (On Windows)
 I've been using git to get FPC trunk and
 git diff --no-prefix  %temp%\mypatch.diff
 rem --no-prefix : Do not show any source or destination prefix.
 to create patches.

I don't know about GIT, but some tips:

1. Play with lineending.  (I use cygwin's dos2unix and unix2dos to convert)
2. Also make sure that the generated diffs are in the universal format.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] [Semi-OT] Git format patches don't seem to work

2011-10-04 Thread cobines
I'm sure it is because patch contains non CRLF linefeeds, as I had
such errors previously, not even using Git. It seems the patch
binary only supports Windows EOLs.

--
cobines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] [Semi-OT] Git format patches don't seem to work

2011-10-04 Thread Reinier Olislagers
On 4-10-2011 13:14, Marco van de Voort wrote:
 In our previous episode, Reinier Olislagers said:
 Having some trouble creating patches that actually work.
 (On Windows)
 I've been using git to get FPC trunk and
 git diff --no-prefix  %temp%\mypatch.diff
 rem --no-prefix : Do not show any source or destination prefix.
 to create patches.
 
 I don't know about GIT, but some tips:
 
 1. Play with lineending.  (I use cygwin's dos2unix and unix2dos to convert)
 2. Also make sure that the generated diffs are in the universal format.
Thanks, Marco  cobines:

That seems to be it!

Unified format: yep, running either
git diff --no-prefix  %temp%\mypatch.diff
or
git diff --no-prefix --unified=3  %temp%\mypatch.diff
gives the same results.

git diff (in my install at least) seems to generate Unix line endings.
If I do something like
cd /d C:\Development\Fpc\Source\packages\fcl-extra\src\win
git diff --no-prefix  %temp%\gitpatch.diff
rem convert unix line endings to dos:
sfk lf-to-crlf %temp%\gitpatch.diff
rem using swiss file knife, for some reason I hate cygwin ;)
ren %temp%\gitpatch.diff gitpatch_convertedtodoslineending.diff
patch -p5  %temp%\gitpatch_convertedtodoslineending.diff
it seems to work.

Unfortunately, git diff doesn't seem to have any arguments for line end
conversion, but there must be some setting/config somewhere that I had
set incorrectly...

I'll get back when I know more...

Thanks!

Reinier
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal