Degenerate behaviour from bzr diff

John Arbash Meinel john at arbash-meinel.com
Tue Sep 25 01:24:31 BST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Paul Moore wrote:
> On 24/09/2007, Michael Alan Dorman <mdorman at tendentious.org> wrote:
>> On Mon, 24 Sep 2007 20:50:35 +0100
>> "Paul Moore" <p.f.moore at gmail.com> wrote:
>>
>>> I just tried using bzr to manage a quick patching session. Nothing
>>> fancy, grab a small distribution, bzr init, hack a bit, then bzr diff
>>> to create a patch.
>>>
>>> Or so I thought. In spite of the changes being pretty small, bzr diff
>>> chose to show the complete file being replaced! Clearly completely
>>> useless as a patch to send back upstream :-(
>>>
>>> I was originally using bzr 0.18, but I updated to 0.91 rc 2, and get
>>> the same behaviour.
>>>
>>> Any suggestions?
>> I can't help but notice you are on Windows.  Did your editor change the
>> line endings?
> 
> Aaaaaargh!!!!
> 
> You're absolutely right. Well, sort of. My *editor* (vim) didn't
> change the line endings (I won't use an editor that can't keep line
> endings in the form the file had them in). However, I created the new
> version of my file via "patch", rather than directly in my editor, and
> the version of patch I have on Windows *does* mangle line endings.
> 
> The irony is that I'm a strong believer in programs never mangling
> line endings on Windows - either \r\n or \n should be valid, but they
> are *not* interchangeable. That's why I use programs like bzr in the
> first place. Grumble. I really must find a version of patch that
> preserves line endings properly.
> 
> Thanks for noticing this. I wonder - would it be possible for bzr to
> notice this (obviously not uncommon!) mistake, and issue a warning?
> 
> Paul.
> 
> 

I believe patch on windows (at least Cygwin patch) allows you to use
"patch --binary" which won't munge the line endings.

You have to be a little careful when passing things in through stdin
(patch -p0 < foo), but I think 'patch -p0 --binary < foo' will work.

(Remembering the good old days when tla/Arch would silently corrupt
itself because it didn't supply --binary, and would build up a cache of
old revisions where all of them (mistakenly) had \r\n line endings. Good
times.)

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG+FU/JdeBCYSNAAMRAg9rAKDTq1n2wKMzqS1HIVzyOJxl1Zr2HwCePMCc
Cc6fWo1kZ5MkalabBLeFy80=
=7QHh
-----END PGP SIGNATURE-----



More information about the bazaar mailing list