I want to convert a Subversion repository sub-directory (denoted by module
here) into a git repository with full history. There are many svn copy
operations (Subversion people call them branches) in the history of my Subversion repository. The release policy has been that after each release or other branches created, the old URL is left unused and the new URL replaces the old one for containing the work.
Optimally, by my reading, it seems like this should do the trick:
$ git svn clone --username=mysvnusername --authors-file=authors.txt \
--follow-parent \
http://svnserver/svn/src/branches/x/y/apps/module module
(where branches/x/y/
depicts the newest branch). But I got an error, which looks something like this:
W: Ignoring error from SVN, path probably does not exist: (160013): Filesystem has no item: '/svn/src/!svn/bc/100/branches/x/y/apps/module' path not found
W: Do not be alarmed at the above message git-svn is just searching aggressively for old history.
(Update: Adding option --no-minimize-url
to the above does not remove the error message.)
The directory module
get created and populated, but the Subversion history past the newest svn copy
commit is not imported (the git repository created ends up having just two commits when I expected hundreds).
The question is, how to export the full Subversion history in the presence of this situation?
Possible Cause
Searching for the error message, I found this: git-svn anonymous checkout fails with -s which linked to this Subversion issue: http://subversion.tigris.org/issues/show_bug.cgi?id=3242
What I understand by my reading, something in Subversion 1.5 changed about how the client accesses the repository. With newer Subversion, if there is no read access to some super directory of the URL path (true for me,
svn ls http://svnserver/svn
fails with403 Forbidden
), then we fail with some Subversion operations.Jeff Fairley in his answer points out that spaces in the Subversion URL might also cause this error message (confirmed by user Owen). Have a look at his solution to see how he solved the case if your
git svn clone
is failing for the same resson.Dejay Clayton in his answer reveals that if the deepest subdirectory components in branch and tag svn urls are equally named (e.g.
.../tags/release/1.0.0
and.../branches/release-candidates/1.0.0
) then this error could occur.
I ran into this problem when I had identically-named subdirectories within branches or tags.
For example, I had tags
candidates/1.0.0
andreleases/1.0.0
, and this caused the documented error because subdirectory1.0.0
appears within bothcandidates
andreleases
.Per git-svn docs:
So while the following command failed due to similarly named
candidates
andreleases
tags:the following sequence of commands did work:
Note that this only worked because there were no other conflicts within
branches
andtags
. If there were, I would have had to resolve them similarly.After successfully cloning the SVN repository, I then executed the following steps in order to: turn SVN tags into GIT tags; turn
trunk
intomaster
; turn other references into branches; and relocate remote paths:[This is the original poster
speakingwriting. The below used to be update to the question, but as it solved the case - albeit unsatisfactorily to my taste - I will post it as an answer lacking a better solution.]I do not like this, but I ended up doing
clone
splitted intoinit
andfetch
with some editing of.git/config
between (repopath=apps/module
,gitreponame=module
):I could not find how to specify the branches for subdirectory migration with
git svn
- hence the editing of the.git/config
file. The following unified diff illustrates the effect of the editing withsed
:As the actual desired
HEAD
was in an another URL, I ended just adding another[svn-remote]
section to.git/config
:(in real life experiment I also added here some branches that were not picked up by the first fetch), and fetching again:
This way I ended having the full Subversion history migrated to the newly generated git repository.
Note-1 : I probably could have just told my "trunk" to be
branches/x/y/apps/module
as the meaning of "trunk" forgit-svn
seems to basically have the meaning of gitHEAD
(Subversion concepts of trunk, branches, tags have no deep technical basis, they are matter of socially agreed convention).Note-2 : probably
--follow-parent
is not required forgit svn fetch
, but I have no way of knowing or experimenting now.Note-3 : While earlier reading of svn2git which seems to be a wrapper over
git-svn
I failed to see the motivation, but seeing the messy presentation of tags I kind of get it now. I would trysvn2git
next time if I had to try doing this again.P.S. This is rather awkward way of doing the operation. Secondary problem here (why the editing of the
.git/config
by external was required) seems to be thatgit svn
implementation strictly assumes the social Subversion conventions to be followed to a degree (which is not possible if you just want to migrate a subdirectory and not the whole Subversion repository).TODO: It would be helpful to have the format of the
.git/config
file explained here as it relates togit svn
- for example I have now (after one and half year of writing the original answer) no idea what the[svn-remote "svn-newest"]
means above. Also the approach could be automated by writing a script, but this is beyond my current interest in the problem and I do not have access to the original Subversion repository or replication of the issue.I recently migrated a long list of SVN repositories into Git and towards the end ran into this problem. Our SVN structure was pretty sloppy, so I had to use
--no-minimize-url
quite a bit. Typically, I'd run a command like:The last few migrations I ran had a space in the URL. I don't know if it was the space or something else, but I was getting the same error you were seeing. I didn't want to get into modifying config files if I didn't have to, and luckily I ended up finding a solution. I ended up skipping the
-s --no-minimize-url
options in favor of explicitly declaring the paths differently.--follow-parent
from your example, but I'm also not sure that it made any difference.""
around the trunk/branches/tags paths.[I realize this should be a comment on Jeff Fairley's answer but I don't have the reputation to post it as such. Since the original poster did ask for confirmation the approach worked I'm providing it as an answer.]
I can confirm that his solution works for the problem he (and I) ran into caused by spaces in the path. I had the same requirements (clone a single module from an SVN repo with history) except that I had no branches or tags to worry about whatsoever.
I tried several permutations of providing the full path to the module in the URL (e.g. using
--no-minimise-url
, specifying--trunk
or--stdlayout
) with no success. For me the result was usually a git repo with a full history log but no files whatsoever. This may or may not be the same problem FooF encountered (no read access in SVN) but it was certainly caused by having a space in the path to my module.Trying again with only the SVN repo base as the URL and the path to my module in
--trunk
worked flawlessly. Afterwards my .git/config looks like this:and subsequent
git
andgit svn
commands are throwing no errors at all. Thanks Jeff!Not a full answer, but perhaps the snippet you are missing (I am interested in migrating as well, so I have found that part of the puzzle).
When you look at the documentation of git-svn, you will find the following option:
This fits to the situation you have, so that
git svn
does not try to read a higher level of the directory tree (which will be blocked).At least you could give it a try ...