2

I have a project hosted on GitHub and I use Git for source versioning.

I have to pull the code on another platform but it can't have Git, so I am using Subversion Support of GitHub to checkout the code, but it doesn't handle symlinks.

For example, on my machine I have a symlink :

sf -> ../lib/vendor/symfony/data/web/sf

But when the sources are updated on the remote platform, I have this :

$ svn up
# updating sources...
$ cat sf
../lib/vendor/symfony/data/web/sf

Any ideas?

Update

If possible I want to avoid the script solution, other developers may also pull sources from Subversion for example.

Romain Deveaud
  • 824
  • 5
  • 11

3 Answers3

4

GitHub's subversion support has been updated to handle symlinks.

It works for checking out from a git repo with symlinks:

$ svn co https://github.com/nickh/repo_with_symlinks
...
A    repo_with_symlinks/trunk/app/lib/foo
A    repo_with_symlinks/trunk/app/lib/foo/bar.txt
A    repo_with_symlinks/trunk/foo
Checked out revision 1.

$ ls -al repo_with_symlinks/trunk/foo
lrwxr-xr-x  1 github  staff   11 Dec 23 23:11 foo -> app/lib/foo

And when committing symlinks from svn clients:

$ ln -s app/lib/foo/bar.txt bar.txt

$ svn add bar.txt
A         bar.txt

$ svn commit -m 'added a symlink'
Adding         trunk/bar.txt
Transmitting file data .
Committed revision 2.
1

This IS really what's stored in the history. When Git sees this content in the log, instead of literally putting it in a file like Subversion does, it actually creates a symbolic link (see entry.c:113 for proof). There are two solutions as I see it:

  1. GitHub must detect that this is a symbolic link and represent the it differently through the SVN interface.
  2. You must use some sort of post-receive hook in Subversion to locally detect and replace such files with symbolic links. Don't actually touch the remote repository, otherwise the Git-side will have problems.

UPDATE: GitHub has fixed the problem now.

artagnon
  • 3,609
  • 3
  • 23
  • 26
  • Yeah I noticed that Git handles symlinks that way, GitHub subversion support just seems to need some improvement. Thank you ! – Romain Deveaud Jun 29 '10 at 14:17
  • You're welcome. On a related note, you might want to see the core.symlinks variable: if it's set to false, it won't create symbolic links corresponding to these files. – artagnon Jun 29 '10 at 14:50
0

Subversion seems to handle symlinks, but in a tricky way.

For your problem, you could try to reconvert back your symlinks to real ones, for example with some script like this (just showing the idea, untested):

#!/usr/bin/env bash

file=$1
filecontent=`cat $1`
if [[ -f "$filecontent" ]]; then
  svn delete $file --force
  svn commit -m "Deleting broken symlink $file"
  svn update
  ln -s $filecontent $file
  svn add --force $file
  svn commit -m "Recreating broken symlink $file"
fi

The svn instructions sequence comes from this question.

Community
  • 1
  • 1
nicoulaj
  • 3,463
  • 4
  • 27
  • 32
  • Your solution could work, except the fact that I don't want to commit the changes : this is a git repository and the subversion write support for github isn't quite stable currently (http://github.com/blog/644-subversion-write-support). – Romain Deveaud Jun 28 '10 at 16:14