git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git-apply can't apply patches to CRLF-files
@ 2006-05-26 16:00 Salikh Zakirov
  2006-05-26 18:05 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Salikh Zakirov @ 2006-05-26 16:00 UTC (permalink / raw)
  To: git

Hello, 

git-apply can't apply the patch to file with windows-style CRLF line endings,
even if the patch was generated by git-format-patch.

Is this a bug or known deficiency?

The following script reproduces the problem
---------
#!/bin/sh
set -e
mkdir trash
cd trash
git init-db
echo "abc" > a
unix2dos a
git add a
git commit -m "a added" a
echo "cde" >> a
unix2dos a
git commit -m "a modified" a
git format-patch HEAD^
git reset --hard HEAD^
git am 0001*.txt
---------

The resulting output is
---------
$ ./test
defaulting to local storage area
a: done.
Committing initial tree 357c56061b96c1548b15168bc0d02e8d1a319e0b
a: done.
0001-a-modified.txt

Applying 'a modified'

error: patch failed: a:1
error: a: patch does not apply
Patch failed at 0001.
When you have resolved this problem run "git-am --resolved".
If you would prefer to skip this patch, instead run "git-am --skip".
---------

If I remove unix2dos calls and so the file has normal unix LF line endings,
then the result is correct as expected

---------
$ ./test
defaulting to local storage area
Committing initial tree 6afc8719a182fed19980da0e53d13fba1f94dd3f
0001-a-modified.txt

Applying 'a modified'

Wrote tree 49f5181a399bbcaac1da3bf693c466a281c4a255
Committed: 2b0a2936d0a65b3511882b8e88586ab054dd15b2
---------

^ permalink raw reply	[flat|nested] 8+ messages in thread
* RE: [PATCH] Fixed Cygwin CR-munging problem in mailsplit
@ 2006-05-27 20:57 Zakirov, Salikh
  2006-05-28 16:39 ` Christopher Faylor
  2006-05-31  4:49 ` Junio C Hamano
  0 siblings, 2 replies; 8+ messages in thread
From: Zakirov, Salikh @ 2006-05-27 20:57 UTC (permalink / raw)
  To: git


Junio C Hamano <junkio@cox.net> writes:
> So even in this modern day, preserving CRLF is not
> something that happens by default -- you would need to make sure
> that everybody on your mailpath to the recipient is set up the
> right way.

> So now I am less in favor of the change than when I wrote that
> response.

I understand this reasoning, and I am not sure if the fix is correct
from the "GIT world" point of view.

However, I believe that the command sequence git-format-patch, git-am
without any e-mail transfer in between and in the same repository
should work perfectly regardless of the contents of the files, 
no matter if they are binary, text, or "CRLF text" or even 
"broken LF and CRLF text". This is a requirement from a nasty "real
world".

Junio, could you point at a right place to fix to get git-format-patch, 
git-am sequence work flawlessly on Cygwin?

By the way, the change affects only non-Unix users, as fopen(..., "rt")
is equivalent to fopen(..., "rb") on all Unixes anyway.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-05-31  4:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-26 16:00 git-apply can't apply patches to CRLF-files Salikh Zakirov
2006-05-26 18:05 ` Junio C Hamano
2006-05-27 17:57   ` [PATCH] Fixed Cygwin CR-munging problem in mailsplit Salikh Zakirov
2006-05-27 18:21     ` Junio C Hamano
2006-05-27 18:25       ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2006-05-27 20:57 Zakirov, Salikh
2006-05-28 16:39 ` Christopher Faylor
2006-05-31  4:49 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).