bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug in patch


From: Abraham vd Merwe
Subject: bug in patch
Date: Mon, 15 Oct 2001 14:00:34 +0200
User-agent: Mutt/1.2.5i

Hi!

patch doesn't handle files with spaces in the file names correctly. I've
attached a small test suite. If you do the following:

------------< snip <------< snip <------< snip <------------
$ tar zxf diff-test-suite.tar.gz
$ cd diff-test-suite/a
$ diff -Nru . ../c >& ../patch.diff
$ cd ..
$ cp -a a A
$ cd A
$ patch -p2 < ../patch.diff
------------< snip <------< snip <------< snip <------------

you will notice that patch completely screws up when patching the files with
spaces in them.

There's only one way you can solve this problem imho:

1) with the ---/+++ lines, you know it's

---<space><source-file><tab><date>\n
+++<space><dest-file><tab><date>\n

so if you strip ---<space> at the beginning and then the <tab><date> at the
end, you get the filename


By examining the diff -Nru part you can always get a screw up since you'll
have to compare the source file and dest file and see where it differs, but
you have spaces in the destination first-level directory, there's no way to
detect it.

I have no idea how you're going to detect it for non-unified diffs...

-- 

Regards
 Abraham

If I'd known computer science was going to be like this, I'd never have
given up being a rock 'n' roll star.
                -- G. Hirst

__________________________________________________________
 Abraham vd Merwe - 2d3D, Inc.

 Device Driver Development, Outsourcing, Embedded Systems

  Cell: +27 82 565 4451         Snailmail:
   Tel: +27 21 761 7549            Block C, Antree Park
   Fax: +27 21 761 7648            Doncaster Road
 Email: address@hidden         Kenilworth, 7700
  Http: http://www.2d3d.com        South Africa

Attachment: diff-test-suite.tar.gz
Description: Binary data

Attachment: pgpqQ3Jex2IWs.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]