Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git & svn externals - a final solution yet?

Tags:

this is the workflow I currently use for my svn projects (I never use svn branches, and some projects are actively worked on by other people as well):

  • on the server, do the inital git svn fetch which might take hours. Also create a 'build' branch.
  • on a development machine cloning is now fast: git clone srv://project.git, git checkout build followed by git update-refs ..., git svn fetch to restore the link to the svn repository
  • work, commit, work commit, ...
  • to check if things are sane, git push build to the server and trigger a build in Hudson for that branch
  • to store work so that I can work on it from another machine, also push build branch
  • when satisfied, join commits together in logical steps (eg one for each bug), commit to svn and reset everything like git checkout master, git merge build, git svn dcommit, git push, git checkout build, git rebase master, git push build

Enter svn externals. I tried every script here already but all of them fail. My externals are setup like this:

/path/to/x x
/path/to/y/z y/z
/path/to/a/b.file a/b.file

and the scripts do things like trying to create /path/to/x in the root of the filesystem and git svn fetch /path/to/x. Also the single files seem to cause more problems. (subquestion 1: what is the svn:externals format these scripts were written for then?)

It doesn't seem to hard modifying one of the scripts to handle my situation and replicate the directory structure I'm after correctly, but then I'm left with a major problem: if I change a file in both x and y/z directories, I don't see a way to join this into a single svn commit and that is one of the reasons I started using git in the first place.

Hence the question: is there a way I can replicate the above workflow, using only parts of a certain svn repository, in such a way that I can do svn dcommit in the root? I'd prefer a ready-to-use solution that works both on linux and windows.

edit I quickly hacked through one of the scripts I found and made it replicating the directory structure of the svn externals. I cannot clone single files though, here's output:

git svn clone -r HEAD srv://svn/repo/path/to/projects.sln
Initialized empty Git repository in xxx/projects.sln/.git/
Invalid filesystem path syntax: REPORT request failed on '/svn/repo/!svn/vcc/default':
  Cannot replace a directory from within at yyy/git/libexec/git-core/git-svn line 5114

subquestion 2: is it not possible fetching a single file through git svn?

like image 526
stijn Avatar asked Jan 14 '11 08:01

stijn


People also ask

What is Git and why is it used?

Git is a DevOps tool used for source code management. It is a free and open-source version control system used to handle small to very large projects efficiently. Git is used to tracking changes in the source code, enabling multiple developers to work together on non-linear development.

What is difference Git and GitHub?

what's the difference? Simply put, Git is a version control system that lets you manage and keep track of your source code history. GitHub is a cloud-based hosting service that lets you manage Git repositories. If you have open-source projects that use Git, then GitHub is designed to help you better manage them.

Why is it called Git?

Git, as a word, is an alternation of the word get, which itself was shortened from beget. The implicit reference is to illegitimate offspring, and the term is roughly synonymous with twit, dolt, moron or idiot.

Is Git a programming language or tool?

Git is not a programming language, but it's become incredibly important for computer programmers working in almost any language you can name. Today, Git is the de facto standard for what's known as version control software.


2 Answers

Unfortunately, svn's externals are quite flexible. I've run across a number of scripts that treat them as <path> <url>, but <url> <path> is also allowed. So I think some of the scripts are just broken in that regard.

To answer your second subquestion: no. 'git svn fetch' needs to operate on a subtree of Subversion's repo, but it needs to be something it can treat like a branch. The only thing map well into that paradigm is a directory (trunk/, for example). FWIW, Bazaar and Mercurial suffer here too. At the end of the day, Subversion is just a versioned file system, whereas Git has a first class concept of a branch. This is one of those mismatches getting in the way. :-(

like image 64
John Szakmeister Avatar answered Sep 21 '22 06:09

John Szakmeister


Just a another note on the second subquestion. As far as I know subversion as of today also does not support svn externals for files, only folders. So I guess such entries in the properties would be invalid. Don't know if there is any tooling which handles this case.

like image 40
agross Avatar answered Sep 20 '22 06:09

agross