You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Vincent Lefevre <vi...@vinc17.net> on 2022/08/15 00:08:08 UTC
[BUG] svn patch with svn:eol-style set to native
About this bug:
On 2022-08-14 14:11:15 -0400, Nathan Hartman wrote:
> But applying your original patch to a clean working copy and then
> running 'svn diff' does show it -- note the - and + of </Project> and
> "\ No newline at end of file" at the end of the output:
[...]
> That looks like a bug in SVN. This machine (the one I'm using now) has
> 1.13.0 so I'll try this with 1.14.2 later...
I can reproduce the issue with svn 1.14.2, and this is due to
svn:eol-style being set to native.
To reproduce:
------------------------------------------------------------
#!/bin/sh
set -ex
svn --version
mkdir my-test-svn
cd my-test-svn
svnadmin create svn
root=file://`pwd`/svn
svn co "$root" wc
cd wc
printf %s "$(printf "%d\n" `seq 8`)" > file
svn add file
svn ps svn:eol-style native file
svn ci -m 'add file'
printf %s "$(printf "%d\n" `seq 2 8`)" > file
svn diff > file.patch
cat file.patch
svn revert file
svn patch file.patch
svn diff
cd ../..
rm -rf my-test-svn
------------------------------------------------------------
--
Vincent Lefèvre <vi...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Re: [BUG] svn patch with svn:eol-style set to native
Posted by Vincent Lefevre <vi...@vinc17.net>.
On 2022-08-15 10:06:48 -0400, Nathan Hartman wrote:
> On Sun, Aug 14, 2022 at 8:08 PM Vincent Lefevre <vi...@vinc17.net> wrote:
> > printf %s "$(printf "%d\n" `seq 2 8`)" > file
>
> One thing I don't understand about the above is why does the outer
> printf %s strip the last newline from the inner one?
It is the $(...) that strips the trailing newline(s):
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_03
That's why I've used that.
--
Vincent Lefèvre <vi...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Re: [BUG] svn patch with svn:eol-style set to native
Posted by Nathan Hartman <ha...@gmail.com>.
On Mon, Aug 15, 2022 at 10:06 AM Nathan Hartman
<ha...@gmail.com> wrote:
> I'll file an issue in the issue tracker...
Filed: https://issues.apache.org/jira/browse/SVN-4906
Cheers,
Nathan
Re: [BUG] svn patch with svn:eol-style set to native
Posted by Nathan Hartman <ha...@gmail.com>.
On Sun, Aug 14, 2022 at 8:08 PM Vincent Lefevre <vi...@vinc17.net> wrote:
>
> About this bug:
>
> On 2022-08-14 14:11:15 -0400, Nathan Hartman wrote:
> > But applying your original patch to a clean working copy and then
> > running 'svn diff' does show it -- note the - and + of </Project> and
> > "\ No newline at end of file" at the end of the output:
> [...]
> > That looks like a bug in SVN. This machine (the one I'm using now) has
> > 1.13.0 so I'll try this with 1.14.2 later...
>
> I can reproduce the issue with svn 1.14.2, and this is due to
> svn:eol-style being set to native.
Nice catch!
Thanks for the reproduction script.
The issue: When the file has the svn:eol-style property set and the
last line of the file does not end with a newline, 'svn patch' adds a
newline to the last line of the file, even when the diff does not call
for it.
I've confirmed that the same issue is reproduced for all possible
svn:eol-style settings. (I did that by using the reproduction script
as-is, and then also modifying it to try the other svn:eol-style
settings of CRLF, LF, and CR.)
I went through the issue tracker looking for similar issues. SVN-3556
and SVN-3991 are *not* similar, but I'm making a note of them here as
they may be relevant. In particular, SVN-3991 seems to be somewhat a
reverse of this issue, where the patch file, rather than the file
being patched, lacks a last newline.
For reference, this was found during the recent dev@s.a.o mail thread
"[PATCH] URL update to https" -- see the part starting with "Are you
sure" in 14 August 2022 message:
https://lists.apache.org/thread/w0fld2p0qzg5oo6tqgw1tcvtolndvg9t
I'll file an issue in the issue tracker...
> printf %s "$(printf "%d\n" `seq 2 8`)" > file
One thing I don't understand about the above is why does the outer
printf %s strip the last newline from the inner one?
Cheers,
Nathan