Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does git decide which version of svn to use in git-svn?

I have installed git and svn with homebrew on my mac running 10.7.4. There is a version of svn on my machine in /usr/bin which appears to be the version that git svn is using.

$ git --version
git version 1.7.10.4

$ svn --version
svn, version 1.7.5 (r1336830)

$ git svn --version
git-svn version 1.7.10.4 (svn 1.6.17)

$ /usr/bin/svn --version
svn, version 1.6.17 (r1128011)

So, can I change the version of svn that git-svn uses? If so, how do I go about it?

Thanks for reading.

--Updated for comment--

$ which git svn
/usr/local/bin/git
/usr/local/bin/svn

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/local/git/bin
like image 308
lashleigh Avatar asked Jun 13 '12 19:06

lashleigh


People also ask

How does SVN version control work?

Centralized version control means that the version history is stored in a central server. When a developer wants to make changes to certain files, they pull files from that central server to their own computer. After the developer has made changes, they send the changed files back to the central server.

Is SVN version control system?

It is a centralized version control system. It is an open-source tool for version control. SVN is used to manage the current and previous versions of files like source code, documentation, and files. It acts as the time machine for the developers and allows them to go back and browse the history of the project.

Is SVN based on Git?

The difference between Git and SVN version control systems is that Git is a distributed version control system, whereas SVN is a centralized version control system. Git uses multiple repositories including a centralized repository and server, as well as some local repositories.

What is SVN update equivalent in Git?

An equivalent of "svn update" would be "git pull --rebase".


2 Answers

I did a little digging, and it looks like git-svn uses subversion's perl bindings. After a little experimentation, I found that installing an upgraded version of svn with perl enabled fixed the problem. On Mac OSX, this would go something like this:

# First, I had to take ownership of the perl libs dir,
# so homebrew could create perl modules
chown $USER -R /Library/Perl/5.12/darwin-thread-multi-2level

# Then, remove and reinstall Subversion, but add the perl option:
brew remove svn
brew install --perl svn

# Lastly, reinstall git (this may be optional, but it may also help.)
brew remove git
brew install git

Your problem boils down to the simple fact that your updated Subversion installation didn't include the accompanying perl modules, so git-svn was falling back on the more complete system installation.

For the record, symlinking /usr/bin/svn to /usr/local/bin/svn did absolutely no good. This has nothing to do with $PATH or anything else, and everything to do with perl modules.

like image 143
Benson Avatar answered Sep 24 '22 02:09

Benson


Your system has two versions of Subversion installed: 1.6.17 in /usr/bin/svn, and 1.7.5 in /usr/local/bin/svn. When you run svn, it parses your $PATH correctly to pick up the one in /usr/local/bin/svn, but git-svn doesn't bother, and just uses the version in /usr/bin.

Having had a quick glance through the code, there's nothing in git-svn.pl or Alien-SVN (the Perl Subversion library that git-svn uses) that explicitly points to any particular svn binary, so I suspect it's a security "feature" to avoid looking at your custom $PATH.

The easy option, if you have access, is to replace /usr/bin/svn with /usr/local/bin/svn; possibly by deleting and replacing with a symlink. Otherwise, I suspect you'll need to dig into the source of git-svn.pl and rewrite it to accept your custom $PATH.

like image 35
me_and Avatar answered Sep 24 '22 02:09

me_and