You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Phillip Susi <ps...@cfl.rr.com> on 2005/04/25 21:55:18 UTC

Junction Point bug report and possible solution

I found a bug with subversion and NTFS Junction points, which are NT 
versions of symbolic links for directories.  The problem may also apply 
to symbolic links on unix.  I also think I have found the cause of the 
problem in the source, and a way to fix it, so I am posting my findings 
here in hopes that a developer can verify and apply them.

Background:

If you check out a working copy to c:\wc then create a junction called 
c:\junction that points to c:\wc, then you cd \junction and run svn 
status, it reports "." with a "~" status, indicating that it thinks the 
current directory is a file, not a directory.  TortoisSVN also will not 
treat c:\junction as a working copy.

Cause:

subversion/libsvn_subr/io.c line 137 reads:

   else if (finfo.filetype == APR_LNK)
     {
       is_special = TRUE;
       *kind = svn_node_file;
     }

I believe the bug is here.  The code calls apr_stat with the 
APR_FINFO_LINK flag, and apr_stat returns a file type of APR_LNK because 
the file in question is a symbolic link.  The above code assumes that a 
symbolic link points to a file, not a directory.  This assumption is 
incorrect, as symbolic links can also point to directories.

Solution:

When apr_stat indicates APR_LNK on the file, is_special should be set to 
true, and then apr_stat should be called again WITHOUT the 
APR_FINFO_LINK flag, which will cause it to indicate APR_REG or APR_DIR 
depending on weather the link points to a file or a directory.  That 
value should then be used to set *kind to svn_node_file or svn_node_dir.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Symlink handling in svn status broken

Posted by Aleksey Nogin <al...@nogin.org>.
On 22.09.2005 11:06, Philip Martin wrote:

> Phillip Susi <ps...@cfl.rr.com> writes:
> 
> 
>>Try this:
>>
>>svnadmin create repo
>>svn co file://`pwd`/repo wc
>>svn mkdir wc/trunk
>>svn ci -m "" wc
>>cd wc
>>mv trunk ..
>>ln -s ../trunk trunk
>>svn st
>>
>>The key thing is to be in the wc directory which has a .svn/entries
>>file that says it should have a child directory named trunk.  Trunk
>>gets moved elsewhere and replaced with a symlink, then when you do an
>>svn st, it thinks that trunk is a file but should be a directory, so
>>it reports it as a collision.
> 
> 
> I'm not sure that qualifies as a bug, you are disrupting the versined
> filesystem.  Subversion assumes that versioned files are files and
> that versioned directories are directories.  If you deliberately break
> those assumptions it's not surprising things don't work.
> 
Still, sometimes it's very useful to be able to relocate a part of a wc 
(say, to a different partition), replacing it with a symlink. IMHO it 
would be very nice if this would be supported.

-- 
Aleksey Nogin

Home Page: http://nogin.org/
E-Mail: nogin@cs.caltech.edu (office), aleksey@nogin.org (personal)
Office: Moore 04, tel: (626) 395-2200

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Symlink handling in svn status broken

Posted by Greg Hudson <gh...@MIT.EDU>.
On Thu, 2005-09-22 at 14:29 -0400, Phillip Susi wrote:
> The versioned directory IS still a directory, it just has been moved and 
> replaced with a symbolic link to the new location.  Shouldn't subversion 
> follow the symbolic link transparently to the versioned directory?

We version symlinks these days.  To Subversion, this looks a lot like
the directory has been replaced with something else.  (Although without
a corresponding "svn rm" and "svn add" it looks to Subversion like it
has been replaced incorrectly.)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Symlink handling in svn status broken

Posted by Philip Martin <ph...@codematters.co.uk>.
Phillip Susi <ps...@cfl.rr.com> writes:

> Philip Martin wrote:
>> I'm not sure that qualifies as a bug, you are disrupting the versined
>> filesystem.  Subversion assumes that versioned files are files and
>> that versioned directories are directories.  If you deliberately break
>> those assumptions it's not surprising things don't work.
>
> The versioned directory IS still a directory, it just has been moved
> and replaced with a symbolic link to the new location.  Shouldn't
> subversion follow the symbolic link transparently to the versioned
> directory?

That's a feature request, not a bug.

There are costs to supporting it, all the code (update, commit, copy,
etc.) that currently assumes that directories are directories and
files are files needs to checked.

How many bugs will arise if we try to support this?  How many
regression tests will we need to write to ensure that it keeps
working?  None of the existing tests have bits of working copy
replaced by symlinlks.

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Symlink handling in svn status broken

Posted by Phillip Susi <ps...@cfl.rr.com>.
Philip Martin wrote:
> 
> I'm not sure that qualifies as a bug, you are disrupting the versined
> filesystem.  Subversion assumes that versioned files are files and
> that versioned directories are directories.  If you deliberately break
> those assumptions it's not surprising things don't work.
> 

The versioned directory IS still a directory, it just has been moved and 
replaced with a symbolic link to the new location.  Shouldn't subversion 
follow the symbolic link transparently to the versioned directory?




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Symlink handling in svn status broken

Posted by Philip Martin <ph...@codematters.co.uk>.
Phillip Susi <ps...@cfl.rr.com> writes:

> Try this:
>
> svnadmin create repo
> svn co file://`pwd`/repo wc
> svn mkdir wc/trunk
> svn ci -m "" wc
> cd wc
> mv trunk ..
> ln -s ../trunk trunk
> svn st
>
> The key thing is to be in the wc directory which has a .svn/entries
> file that says it should have a child directory named trunk.  Trunk
> gets moved elsewhere and replaced with a symlink, then when you do an
> svn st, it thinks that trunk is a file but should be a directory, so
> it reports it as a collision.

I'm not sure that qualifies as a bug, you are disrupting the versined
filesystem.  Subversion assumes that versioned files are files and
that versioned directories are directories.  If you deliberately break
those assumptions it's not surprising things don't work.

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Symlink handling in svn status broken

Posted by Phillip Susi <ps...@cfl.rr.com>.
Philip Martin wrote:
> svnadmin create repo
> svn co file://`pwd`/repo wc
> svn mkdir wc/trunk
> svn ci -m "" wc
> ln -s trunk wc/branches
> svn add wc/branches
> svn ci -m "" wc
> svn up wc
> svn st -v wc/trunk wc/branches
> 

Try this:

svnadmin create repo
svn co file://`pwd`/repo wc
svn mkdir wc/trunk
svn ci -m "" wc
cd wc
mv trunk ..
ln -s ../trunk trunk
svn st

The key thing is to be in the wc directory which has a .svn/entries file 
that says it should have a child directory named trunk.  Trunk gets 
moved elsewhere and replaced with a symlink, then when you do an svn st, 
it thinks that trunk is a file but should be a directory, so it reports 
it as a collision.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Symlink handling in svn status broken

Posted by Philip Martin <ph...@codematters.co.uk>.
Phillip Susi <ps...@cfl.rr.com> writes:

> What did you do to reproduce it?

I used the script in the email referenced in the issue.  Of course it
would have been better if the script was in the issue itself, then we
would all be sure we were doing the same thing.

svnadmin create repo
svn co file://`pwd`/repo wc
svn mkdir wc/trunk
svn ci -m "" wc
ln -s trunk wc/branches
svn add wc/branches
svn ci -m "" wc
svn up wc
svn st -v wc/trunk wc/branches

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Symlink handling in svn status broken

Posted by Phillip Susi <ps...@cfl.rr.com>.
Philip Martin wrote:

> 
> Obvious to whom?  Perhaps symlinks should be neither svn_node_file or
> svn_node_directory.
> 

Well, obvious to me of course.  It seemed to me that the code set 
another 'special' flag to indicate that the node is a link, and the 
other type field to svn_node_file so that it is treated like a file by 
the rest of the system that doesn't care if it is a link or not.  It 
would be analogous then to set the special flag and svn_node_dir if the 
link is in fact, to a directory.  Of course, I'm no expert on the code, 
which is why I ask that someone who knows better take a look and decide.


> 
> Have you tried it recently?  I can't reproduce with trunk on Linux.
> 
> $ svn st -v branches trunk
>                 2        1 pm           branches
>                 2        1 pm           trunk
> 

What did you do to reproduce it?  If you checkout a repository to the 
directory trunk, then enter trunk where a subdir 'subdir' is contained, 
then move subdir elsewhere and replace it with a symbolic link to the 
new location of subdir, when you do an svn st from the trunk directory, 
it should complain.

As far as I could see from reading the source, it complains because the 
node that represents subdir is flagged as svn_node_file instead of 
svn_node_dir, yet the entries file says subdir is a directory, so you 
get an error message because subversion thinks subdir is a file when it 
should be a directory.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Symlink handling in svn status broken

Posted by Philip Martin <ph...@codematters.co.uk>.
Phillip Susi <ps...@cfl.rr.com> writes:

> Thought I would try to draw some attention to this again, as it has
> been another few months.
>
> It seems like such a simple bug with a simple fix.

Changing code right in the middle of the io library is never simple.

>  The code sets a
> variable in a structure to indicate that the object is a file if
> apr_stat says it is a file, or a directory if apr_stat says it is a
> directory, but if apr_stat says it is a link, the code assumes it is a
> file and sets the object type to file.  It seems obvious that it needs
> to check if the link is to a directory, and if so, set the type to
> directory, not file.

Obvious to whom?  Perhaps symlinks should be neither svn_node_file or
svn_node_directory.

>
> Could someone take a look at this one?

>>> reported as #2284
>>> (http://subversion.tigris.org/issues/show_bug.cgi?id=2284)

Have you tried it recently?  I can't reproduce with trunk on Linux.

$ svn st -v branches trunk
                2        1 pm           branches
                2        1 pm           trunk

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Symlink handling in svn status broken (Was: Junction Point bug report and possible solution)

Posted by Phillip Susi <ps...@cfl.rr.com>.
Thought I would try to draw some attention to this again, as it has been 
another few months.

It seems like such a simple bug with a simple fix.  The code sets a 
variable in a structure to indicate that the object is a file if 
apr_stat says it is a file, or a directory if apr_stat says it is a 
directory, but if apr_stat says it is a link, the code assumes it is a 
file and sets the object type to file.  It seems obvious that it needs 
to check if the link is to a directory, and if so, set the type to 
directory, not file.

Could someone take a look at this one?

Phillip Susi wrote:
> It has been over a month so I thought I would try to call some attention 
> to this issue again.  If you read the emails linked to in the bug 
> ticket, the cause and ( simple ) solution to the problem are spelled 
> out.  If someone who is more familiar with the code base could take a 
> look at it and decide if the solution is appropriate or not, and apply 
> it if it is, I would appreciate it.
> 
> 
> Marcus Rueckert wrote:
> 
>> hi,
>>
>> reported as #2284 
>> (http://subversion.tigris.org/issues/show_bug.cgi?id=2284)
>>
>> darix
>>
>>  
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Symlink handling in svn status broken (Was: Junction Point bug report and possible solution)

Posted by Phillip Susi <ps...@cfl.rr.com>.
kfogel@collab.net wrote:

>If you read the issue, you'll see a statement from me indicating that
>a proper solution might be somewhat more complex than the "simple"
>solution initially spelled out.
>  
>

Right, which is why I'm asking someone who is familiar with the codebase 
to take a look at it and see what they think.  I just spent an hour 
looking over the code to find the problem, so I am not entirely sure how 
the change might impact the system as a whole. 

>Have you tried making your patch and then running the entire
>regression test suite?  If so, what was the result?
>
>  
>

No.  I don't have the time to set up the build environment and compile 
subversion myself.  I'm just too bogged down in other projects and work 
at the moment.  All I could manage was an hour looking over the source 
code until I found what appears to be an obvious bug with a simple fix.  
I'm afraid it's going to be up to a developer experienced with working 
on subversion to integrate and test. 

>Thanks,
>-Karl
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Symlink handling in svn status broken (Was: Junction Point bug report and possible solution)

Posted by kf...@collab.net.
Phillip Susi <ps...@cfl.rr.com> writes:
> It has been over a month so I thought I would try to call some
> attention to this issue again.  If you read the emails linked to in
> the bug ticket, the cause and ( simple ) solution to the problem are
> spelled out.  If someone who is more familiar with the code base could
> take a look at it and decide if the solution is appropriate or not,
> and apply it if it is, I would appreciate it. Marcus Rueckert wrote:
> 
> >hi,
> >
> >reported as #2284 (http://subversion.tigris.org/issues/show_bug.cgi?id=2284)

If you read the issue, you'll see a statement from me indicating that
a proper solution might be somewhat more complex than the "simple"
solution initially spelled out.

Have you tried making your patch and then running the entire
regression test suite?  If so, what was the result?

Thanks,
-Karl

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Symlink handling in svn status broken (Was: Junction Point bug report and possible solution)

Posted by Phillip Susi <ps...@cfl.rr.com>.
It has been over a month so I thought I would try to call some attention 
to this issue again.  If you read the emails linked to in the bug 
ticket, the cause and ( simple ) solution to the problem are spelled 
out.  If someone who is more familiar with the code base could take a 
look at it and decide if the solution is appropriate or not, and apply 
it if it is, I would appreciate it. 



Marcus Rueckert wrote:

>hi,
>
>reported as #2284 (http://subversion.tigris.org/issues/show_bug.cgi?id=2284)
>
>darix
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Symlink handling in svn status broken (Was: Junction Point bug report and possible solution)

Posted by Marcus Rueckert <da...@web.de>.
hi,

reported as #2284 (http://subversion.tigris.org/issues/show_bug.cgi?id=2284)

darix

-- 
irssi - the client of the smart and beautiful people

              http://www.irssi.de/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Symlink handling in svn status broken (Was: Junction Point bug report and possible solution)

Posted by Marcus Rueckert <da...@web.de>.
hi

sussman asked for a reproduction recipe:

[[[
#!/bin/sh
set -x
svnadmin create repos
svn co file://$PWD/repos wc
cd wc
svn mkdir trunk
svn ci -m ""
ln -s trunk branches
svn add branches
svn ci -m ""
svn up
svn st -v *
svn st -v .
]]] 

this results in
[[[
sh t.sh
+ svnadmin create repos
+ svn co file:///home/darix/tmp/symlinks/repos wc
Checked out revision 0.
+ cd wc
+ svn mkdir trunk
A         trunk
+ svn ci -m ''
Adding         trunk

Committed revision 1.
+ ln -s trunk branches
+ svn add branches
A         branches
+ svn ci -m ''
Adding         branches
Transmitting file data .
Committed revision 2.
+ svn up
At revision 2.
+ svn st -v branches trunk
~               2        1 darix        branches
                2        1 darix        trunk
+ svn st -v .
                2        2 darix        .
                2        1 darix        trunk
                2        2 darix        branches
]]]

the "svn status *" reports the link as obstructed. why?

i tested this with HEAD and 1.1.3. both show the same result.

darix

-- 
irssi - the client of the smart and beautiful people

              http://www.irssi.de/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Junction Point bug report and possible solution

Posted by Marcus Rueckert <da...@web.de>.
hi,

i just tested with Phillip Susi the same stuff on linux. it is broken
too.

[[[
$ ls -la 
total 0
drwxr-xr-x  4 darix users  64 2005-04-26 00:42 ./
drwxr-xr-x  4 darix users  27 2005-04-26 00:38 ../
lrwxrwxrwx  1 darix users   3 2005-04-26 00:42 bar -> foo
lrwxrwxrwx  1 darix users   5 2005-04-26 00:38 branches -> trunk/
-rw-r--r--  1 darix users   0 2005-04-26 00:42 foo
drwxr-xr-x  7 darix users 135 2005-04-26 00:42 .svn/
drwxr-xr-x  3 darix users  17 2005-04-26 00:38 trunk/
$ svn st -v *
                3        3 darix        bar
~               1        1 darix        branches
                3        3 darix        foo
                1        1 darix        trunk
$ svn st -v .
                0        0  ?           .
                1        1 darix        trunk
                3        3 darix        foo
                3        3 darix        bar
                2        2 darix        branches
]]]

looks a bit strange

darix

-- 
irssi - the client of the smart and beautiful people

              http://www.irssi.de/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org