Bug 254545 - Creating a patch with a file that does not end with a newline places the "no newline" marker incorrectly
Summary: Creating a patch with a file that does not end with a newline places the "no ...
Status: RESOLVED FIXED
Alias: None
Product: Subversive
Classification: Technology
Component: Core (show other bugs)
Version: 0.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Alexander Gurov CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-06 19:32 EST by Hilton Campbell CLA
Modified: 2009-02-06 09:56 EST (History)
2 users (show)

See Also:


Attachments
An example patch with the "No newline" at the end (1006 bytes, application/octet-stream)
2008-12-12 09:11 EST, Hilton Campbell CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hilton Campbell CLA 2008-11-06 19:32:49 EST
Build ID: I20080617-2000

Steps To Reproduce:
1. Create a file in an SVN managed project with some text but no newline at the end (or remove the newline on the end of an existing file).
2. Create a patch for the project.
3. Revert changes to the project.
4. Apply the patch to the project.
5. Look at the new (or modified) file. Notice that it ends with "\ No newline at end of file".


More information:
An SVN patch for a file that does not end with a newline includes the special marker "\ No newline at end of file". This marker should not actually be inserted in the file. You can distinguish the marker from the literal text in the patch (if for some reason a file was supposed to actually say that at the end) by the presence or absence of an actual newline.

My current workaround is to use a different SVN client to apply the patches (TortoiseSVN, specifically). Prior to that I would perform a search-and-replace over the entire project.
Comment 1 Oliver Klee CLA 2008-11-07 09:52:37 EST
We have a similar problem with some of our projects. The problem seems to be with creating the patch in the first place (because the newline before "\ No newline..." is missing from the patch).

Bernd, which version of Subversive are you using?

BTW, this works fine for me using the Subversive client (team stuff 0.7.3.i20080814 and the connectors 2.0.3.i20080814) that came with Zend Studio for Eclipse 6.1.0 for Linux.
Comment 2 Bernd Schoenbach CLA 2008-12-12 09:05:14 EST
(In reply to comment #0)
> Build ID: I20080617-2000
>
> Steps To Reproduce:
> 1. Create a file in an SVN managed project with some text but no newline at the
> end (or remove the newline on the end of an existing file).
> 2. Create a patch for the project.
> 3. Revert changes to the project.
> 4. Apply the patch to the project.
> 5. Look at the new (or modified) file. Notice that it ends with "\ No newline
> at end of file".

Is the created patch ok, or does the patch allready have the mistake with the newline? Can you post the patch which is involved in this problem?
Comment 3 Hilton Campbell CLA 2008-12-12 09:11:04 EST
Created attachment 120320 [details]
An example patch with the "No newline" at the end
Comment 4 Hilton Campbell CLA 2008-12-12 09:12:12 EST
The patch is created correctly (and can be applied with TortoiseSVN correctly). The problem is that Subversive does not apply it correctly.
Comment 5 Bernd Schoenbach CLA 2008-12-12 09:19:35 EST
(In reply to comment #4)
> The patch is created correctly (and can be applied with TortoiseSVN correctly).

It looks like the patch is the problem, because regular patches with files which have no newline at the end look like this:

+?>
\ No newline at end of file

Your patch looks like this:

+}\ No newline at end of file


Which should be the problem. Because in my understanding of patches there needs to be a newline before the \No newline at end of file statement.
Comment 6 Hilton Campbell CLA 2008-12-12 09:24:11 EST
I just created a patch with TortoiseSVN and I see that it agrees with you. The example patch I attached was created with Subversive, so I guess the real problem is that Subversive is creating the patch incorrectly.
Comment 7 Bernd Schoenbach CLA 2008-12-12 09:34:26 EST
To complete the picture: 
I'am using:
Eclipse with PDT 1.0.3.v20080603

Subversive SVN Team Provider: 0.7.5.I20081029-1900
Connectors: 2.0.6.I20081205-1900
Comment 8 Hilton Campbell CLA 2008-12-12 09:38:19 EST
I'm running Eclipse JEE 3.4.0.I20080617-2000

Subversive SVN Team Provider: 0.7.3.I20080814-1500
Connectors: 2.0.3.I20080814-1500
Comment 9 Hilton Campbell CLA 2008-12-12 09:53:26 EST
I just updated to the latest (same Team versions as Bernd) and still see this problem when creating a patch.
Comment 10 Oliver Klee CLA 2008-12-12 10:10:45 EST
By the way, this is the version which I'm using which does *not* exhibit this problem:

Zend Studiod for Eclipse 6.1.0 (based on Eclipse 3.4.0)
SVN Team Provider (incubation) 0.7.3.i20080814-1500
Subversive SVN Kit Connector 1.4 2.0.3.i20080814-1500
Subversive SVN Kit Connector 1.5 2.0.3.i20080814-1500
Subversive SVN Kit Connectors 2.0.3.i20080814-1500
Comment 11 Hilton Campbell CLA 2008-12-12 10:31:43 EST
It may be a special case. I created a patch on a very large change and see that the "No newline" marker is placed properly on changing files, but not on new files.
Comment 12 Oliver Klee CLA 2008-12-14 07:24:58 EST
Hilton, I don't have the permission to edit this bug's summary. Could you edit it to better reflect the problem (creating the patch)?
Comment 13 Igor Burilo CLA 2008-12-19 09:44:02 EST
Fixed
Comment 14 Bernd Schoenbach CLA 2009-02-06 09:56:26 EST
Here is a workaround for those who don't have the possibility to apply the patch:

1. add the new file to verion control: 
 - Right Mouse Button -> Team -> Add to version control...

2. create the patch.

This fixes this issue.