15

Let's say I create a symbolic link file inside an SVN managed path, commit the path to SVN, and later checkout the path.

  1. Will the symbolic link file survive?

  2. If the symbolic link file is made up of a relative path, will it work "everywhere" a checkout is done?

  3. Are there gotchas?

jldupont
  • 6,864

5 Answers5

23

From the Subversion Features page:

Symbolic links can be versioned.

Unix users can place symbolic links under version control. The links are recreated in Unix working copies, but not in win32 working copies.

  1. Yes

  2. As long as permissions aren't changed, it should.

  3. Won't work on Windows checkouts.

CaldeiraG
  • 2,623
  • 8
  • 21
  • 34
17

In general, Yes.

However, some clients don't work with symbolic links properly. Subclipse, for the Eclipse IDE, creates directories instead of symlinks.

So it's best to make sure your client is doing it right before getting into development.

8

Symlinks won't survive on a Windows machine, this can be a problem.
On Windows machines the symlinks take the form of placeholder files*), for example:

style.css:

link ../www_public/styles.css

*): these files have "svn:special" propery with a value of "*".

I sometimes have to export stuff to a windows machine before I can move/upload the project to it's destination server.

I use a small shell script that does a wonderful job at recreating the actual symlinks from the placeholder files:

#!/bin/sh

grep -lr '^link ' . | while read placeholderfile
do
  linecount=`wc -l $placeholderfile | cut -c1`
  if [ $linecount -eq 0 ] ; then
    linkfile=`cut -c6- "$placeholderfile"`
    ln -sf "$linkfile" "$placeholderfile"

    echo -e "[\E[32;40mOK\E[37;40m] Replaced $placeholderfile with symlink"
  else
    echo -e "[\E[31;40mWARNING\E[37;40m] $placeholderfile contains newline(s)"
  fi
  tput sgr0
done

This script works on the assumption that all files that start with the string "link" and do not contain newlines are symlinks.

Jacco
  • 359
1

From Windows 7 onwards, the OS understands symbolic links; see here for some documentation. The regular SVN clients under Windows do not yet support this, but svn under cygwin does!

Arend
  • 111
0

NTFS supports symlinks from the very beginning - this is a legacy of the POSIX sub-system of NT. So you can create symlinks. But Windows as OS can recognize symlinks as such only from Win 7 onwards. And they are restricted - by default policy, normal users cannot create symlinks with MKLINK.

jm73
  • 41