tags:

views:

1247

answers:

4

I'm using Subversion for one of my PHP projects. I have two questions/issues:

  1. How are file permissions handled with Subversion? If I have a file that I CHMOD to 755, and I check that file into the repository, will it have the same permissions when it's checked out into other working copies? If it does not copy, do I really need to change the permissions with every checkout?
  2. I have a .htaccess file that I don't want to check into the repository. If I do an update on a working copy that contains a .htaccess (but the repository doesn't have that file), will the file be deleted or will the update leave it alone?
A: 

1) ... permissions won't transfer.

2) ... update will leave it alone as long as it is not under version control.

That said, double check those ideas. Please.

vector
Thanks for the response. What do you mean by "double check those ideas"? If I'm doing something wrong, I'd love to get your advice. Thanks :)
James Skidmore
+6  A: 
  1. The only permission Subversion knows about, is the executable bit, which is stored as a special "svn:executable" property. If this property is defined, the file is checked out with the exec bit set. For the rw flags, it depends on your umask. If your umask is for example 0022, a file without the svn:executable bit will be checked out with permission 0644. If your umask is 0002, the permission will be 0664. If svn:executable is set, the exec bit is set for the owner, group and everyone else.
  2. If you don't mark the .htaccess for addition (svn add), svn will leave the file alone. It will not go into the repo when committing, and it will not be deleted when you run svn update. You will see a "?" in front of it when you run "svn status".
sunny256
Thanks for the great explanation sunny256. I'm not really an expert when it comes to permissions, but I do know that I have certain directories that need to have 755 and others that need to have 644 or 777. So in short, is the answer you gave a no to that? If so, do I really need to change the permissions manually for every checkout or is there another way? Thanks again.
James Skidmore
If you need to have special permissions on some directories, you might want to create a script that updates the working copy and then chmod the various directories, for example a Makefile placed outside the public www area. Do you want to hide the contents for the www-data user, limiting it to only the user, or...? If you set a directory permission to 644 (remove the executable bit, i.e. 111), nobody will be able to enter it.
sunny256
If you want to test all rwx combinations on directories, create an empty testdir, enter it and execute the following. It will create 512 directories with all possible rwx combinations, and you can see how the permissions work. Here goes: for a in $(seq 0 7); do for b in $(seq 0 7); do for c in $(seq 0 7); do echo Creating $a$b$c...; mkdir $a$b$c; chmod $a$b$c $a$b$c; done; done; done
sunny256
...or that's maybe a bit overkill. :) It's much easier to experiment with 8 directories: for a in $(seq 0 7); do echo Creating $a$a$a...; mkdir $a$a$a; chmod $a$a$a $a$a$a; done
sunny256
+1  A: 

For #2 you can simply add .htaccess to svn:ignore property. Here's a good take on what that does and how that work http://is.gd/1WYh8 Permission-wise if you check out file it gets read/write permissions unless it's executable which should have svn:executable permissions and will be checked out as such. The file can also be explicitly marked with svn:needs-lock which then makes it read-only when you checkout

DroidIn.net
I've read that svn:executable only works on files. How can I implement that for directories, or do I need to manually change the permissions with every checkout?
James Skidmore
You can do "svn propset svn:executable '*' <file>" and commit it on as many files as you need and from that point on it will retain executable flag.
DroidIn.net
+1  A: 
  1. As already mentioned, SVN will not store permissions.

    The reason is trivial:

    The user who did the checkout will be owner of all files inside his working copy, so it does not make sense to give permissions as he already has read/write permissions on all files inside his working copy (depending on his umask).

    For e**x**ecutable flag set svn-property svn:executable.

  2. .htaccess file

    You should add the .htaccess to the parent directories svn:ignore property.

    However, SVN will never change or overwrite your changes without asking you first. So if some of your buddys will store the .accessfile into repository, SVN will stop update and will mention that your own .htaccess file must be removed to continue.

Peter Parker