I have a problem that I describe poorly in another question. I'm posting this to make it more clear what I want to do, and what problem I'm encountering. There is a highly-voted answer, but it doesn't actually address my problem (short story: I'm not trying to add a symlinked directory to my version-controlled project).
If you already know how subversion works, skip to below to get the actual question.
I am at the command line, and the current working directory is my home directory.
$> pwd
/home/user
I have an svn project. Let's say it's called some_project
. I want to check the project out to real_directory/
.
$> svn checkout http://svnhost.net/some_project real_directory
A real_directory/index.php
...
A real_directory/robots.txt
Checked out revision 1143.
I haven't cd
ed into that directory; I'm still outside of it, in my home directory:
$> pwd
/home/user
Yet I can still use svn commands on files real_directory/
, even though it's not my current working directory
$> svn status real_directory/
$> touch real_directory/new_file.txt
$> svn status real_directory/
? real_directory/new_file.txt
$> svn add real_directory/new_file.txt
A real_directory/new_file.txt
I'm pointing this out to clarify misconceptions presented in the other question. Note that I added a file to the project, while still outside of the version-controlled directory. I can do this because of the existence of the .svn/
directory in the real_directory
directory. This is what makes real_directory/
contain the some_project
subversion project, even though it has a different name.
$> ls real_directory/.svn
all-wcprops entries format prop-base props text-base tmp
( If you already know this, please bear with me -- my original question had a well-voted answer that gave wrong information about the ability to do this with subversion! )
This is the syntax of the svn
command:
svn [svn-controlled directory] command
If you don't specify the directory, svn will assume you're talking about the current directory. So all of these are equivalent (current working directory is in the shell prompt):
[ /home/user ]$ svn status real_directory/
A real_directory/new_file.txt
[ /home/user ]$ cd real_directory/
[ /home/user/real_directory ]$ svn status .
A new_file.txt
[ /home/user/real_directory ]$ svn status
A new_file.txt
So, to recap: I can do anything I want while not inside the version controlled directory, just as if I were inside of it, simply by specifying the directory when I issue my svn commands.
OK, now that that's out of the way, here's the problem:
When I create a symlink to the subversion controlled directory, svn recognizes it for commands such as add
and status
, but not for commit
!
Here is the symlink directory working just like the real directory when I add files and ask its status:
$> svn status real_directory/
A real_directory/new_file.txt
$> ln -s real_directory/ symlink
$> svn status symlink
A symlink/new_file.txt
$> svn status real_directory/
A real_directory/new_file.txt
$> touch symlink/another_new_file.txt
$> svn status symlink
? symlink/another_new_file.txt
A symlink/new_file.txt
$> svn add symlink/another_new_file.txt
A symlink/another_new_file.txt
$> svn status symlink/
A symlink/another_new_file.txt
A symlink/new_file.txt
See how symlink/
acts just like real_directory/
for the purposes of add
and status
? Problem: this fails on the commit command:
$> svn commit symlink/ -m "test commit"
svn: '/home/user' is not a working copy
svn: Can't open file '/home/user/.svn/entries': No such file or directory
Huh? That's weird. Svn certainly thinks that file exists when I do status
and add
! Maybe it got deleted?
$> ls symlink/.svn/entries
symlink/.svn/entries
Nope, still there. Does it still have data in it?
$> ls -lha !$
ls -lha symlink/.svn/entries
-r--r--r-- 1 user group 14K 2009-12-18 06:36 symlink/.svn/entries
Yup, seems to be okay! Alright, forget trying to commit the directory by its symlink. What about just committing the directory by its real name?
$> svn commit real_directory/ -m "test commit"
Adding real_directory/another_new_file.txt
Adding real_directory/new_file.txt
Transmitting file data ..
Committed revision 1144.
Works fine. Why does svn work with add
and status
on a symlinked directory, but not commit
?