X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Date: Tue, 16 Mar 2010 21:29:16 +0100 From: Spiro Trikaliotis To: cygwin AT cygwin DOT com Message-ID: <20100316202916.GO4290@trikaliotis.net> Mail-Followup-To: cygwin AT cygwin DOT com References: <5ef8ba411003161215g7844d7edi6412ca57e5eb6e3d AT mail DOT gmail DOT com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5ef8ba411003161215g7844d7edi6412ca57e5eb6e3d@mail.gmail.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-SA-Exim-Connect-IP: 87.163.210.1 X-SA-Exim-Mail-From: an-cygwin AT spiro DOT trikaliotis DOT net Subject: Re: Patch, diff, and line-endings X-SA-Exim-Version: 4.2.1 (built Wed, 25 Jun 2008 17:14:11 +0000) X-SA-Exim-Scanned: Yes (on mail.trikaliotis.net) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Hello David, * On Tue, Mar 16, 2010 at 03:15:13PM -0400 David Eisner wrote: > I'm running into a problem when applying patches. Here's a toy > example. I have a file, test.txt, with a one line change. I use diff > -u to generate a patch, and then I use patch to apply it. > > With unix-style line-endings (\n), everything works fine: [...] > But with dos-style line-endings (\r\n), the patch fails: > > $ file {a,b}/test.txt > a/test.txt: ASCII text, with CRLF line terminators > b/test.txt: ASCII text, with CRLF line terminators [...] > Shouldn't this work, regardless of the line-ending type? No: patch is very picky here. From my experience, you will observe the same behaviour on a Linux machine. In a project I am involved, we were using diffs frequently to send in changes. (Only recently, we changed to something more reasonable.) We always had this problem from DOS/Windows users. > I repeated the same experiment on a Solaris 10 box with GNU diff 2.8.1 > and GNU patch 2.5.4, and it worked fine, with both unix- and dos-style > line endings. Now, this is surprising to me, as I have seen the same exact problem on Linux. AFAIR, this is a problem of patch itself. Perhaps, Solaris 10 does something differently, hiding the CRLF from patch? BTW: In the project mentioned above, we always solved the issue with dos2unix. Best regards, Spiro. -- Spiro R. Trikaliotis http://opencbm.sf.net/ http://www.trikaliotis.net/ http://www.viceteam.org/ -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple