3

Given a pre-existing SVN structure like this:

trunk/
   tools/
      frob-1.2/
      frob-1.4/
      frob-1.8/
      frob-latest/ => frob-1.8/

Where "frob-latest" is created by an svn:external property as a within-same-repository link...

What is the best way to replicate this in a Git-SVN mirror of the above repository, and in a pure Git repository (as we are considering migrating to Git in the future)? I'm looking for something that works in both Windows and Linux, as we use both.

The standard Git-SVN checkout ignores the external property and hence the frob-latest directory does not exist in checkouts, which breaks things.

On Linux, it is possible to manually create a symlink in the working copy, but this can only be propagated to other Linux users in a pure Git repository (as in the Git-SVN repository it would cause a conflict with the SVN external, and symlinks don't work with any of the Windows tools).

On Windows, it is possible to manually create a directory junction in the working copy, but this can't be propagated to any other users (and requires admin permissions to set up in the first place).

Git has a "submodules" concept, which on the surface sounds like an equivalent to svn:external, but as far as I can tell they can only point at an entire repository, not a sub-path within a repository (in this case the same repository), so they're not useful for this application. They also seem like they're a lot more painful to work with than externals, but that might just be unfamiliarity.

Miral
  • 12,637
  • 4
  • 53
  • 93
  • Related: http://stackoverflow.com/q/5917249/1390430 (I hesitate to call it a duplicate, because it's nowhere close to equivalent to `svn:externals` and its ability to pull in arbitrary locations from specific revisions). – Ben May 15 '15 at 03:53
  • Yes, I saw that, but I don't consider requiring Windows users to remember to run special custom git commands both before and after commit/checkout to be a valid solution. Especially since the Windows users in question will be using TortoiseGit rather than the command line most of the time, and the Windows users outnumber the Linux ones. (The converse, requiring Linux users to run the arcane commands, I would be happier with.) – Miral May 15 '15 at 04:09
  • I should possibly add that currently our *only* use of `svn:external` is for such within-same-repository links, but we do have more than just this one. (We haven't gone overboard with them though.) This doesn't seem like it should be a unique thing though -- I've read of a school of thought that recommends partitioning SVN repositories with each project's dependencies as `svn:external` subdirectory links rather than reaching upwards in the folder hierarchy to find common code, since that makes it easier to do partial checkouts. – Miral May 15 '15 at 04:15
  • I believe you can set up a repository hook of some kind to run that custom command for you, if you like. – Ben May 15 '15 at 14:33
  • Repository hooks run on the server, which is not useful in this case. It would have to be a client-side hook, but then every client has to install the hook, which makes it less hassle to just manually create a junction. – Miral May 17 '15 at 23:37
  • Yes each user would install. But each client copy in git *is* a repository, is what I meant by "repository hook". – Ben May 18 '15 at 00:05
  • Right, sorry, I still had my SVN brain in. I suppose that could be feasible, albeit still a bit of a pain in the butt. Any pointers? – Miral May 18 '15 at 01:34
  • Nope, sorry. I use SVN at work and use Hg in my free time. And I don't do anything fancy like using hook scripts in Hg. – Ben May 18 '15 at 01:41

0 Answers0