Building svn2git from Qt

Trying to convert a SVN repo to Git. The Ruby version works, but does not commit all the files with the correct CRLF chars – seems to ignore the global settings.

svn2git --rootistrunk --verbose > x

I can reconvert the repo afterwards to fix the endings (see this) but it makes diffing before and after tricky. Tried to hack the Ruby code to add “text = *” to the .gitattributes file. No dice.

So I tried another version of svn2git based on Qt. First, use Linux. Windows would have no chance.

Installed the Qt libs. I build subversion, apr, and aprutil from scratch, and then link failed. Tried:

export LD_LIBRARY_PATH=/usr/local/lib
export QTDIR=/home/dchwalis/tools/QtSDK/Desktop/Qt/4.8.1/gcc

Changed all the APR includes to local

# must use local APR
APR_INCLUDE = /usr/local/apr/include/apr-1 
APR_LIB_DIR = /usr/local/apr/lib
APR_UTIL_INCLUDE = /usr/local/apr/include/apr-1 
APR_UTIL_LIB_DIR = /usr/local/apr/lib

and rules :

create repository demo-convert 
end repository

match /trunk/
  repository demo-convert
  branch master
end match

So it compiled and linked. But when I run I got an error message, basically SVN could not use the "http:" access method. Looks like I was missing the neon lib. (ra_neon). Download and build neon. No change. Sigh.

Then I apt-get all the -dev versions of subversion, APR, and APR-util. Changed all the APR includes to local

SVN_INCLUDE = /usr/include/subversion-1
APR_INCLUDE = /usr/include/apr-1.0/
APR_LIB_DIR = /usr/lib
SVN_LIBDIR = /usr/lib

Now it works, but there is a problem with the SVN itself.

Invoked as:' ./svn-all-fast-export --rules=rules'
WARNING; no identity-map specified, all commits will be without email address
Loading rules from "rules" 
svn: Can't open file '': No such file or directory
Failed to open repository 

Sigh. I give up.

This entry was posted in Computers, howto, Software and tagged , , . Bookmark the permalink.

3 Responses to Building svn2git from Qt

  1. dave says:

    Then I found this article which I adopted for an Android project.

    find . -type f -a \( -name '*.tpl' -o -name '*.php' -o -name '*.java' -o -name '*.xml' -o -name '*.js' -o -name   '*.css' -o -name '*.sh' -o -name '*.rtf' -o -name '*.bat' -o -name '*.gitignore' -o -name '*.classpath' -o -name '*.cfg' -o -name '*.iml' -o -name '*.txt' -o -name '*.html' \) | xargs fromdos

    . I first had to install tofrodos to allow fromdos and then ran it.

    First you gotta clear up the newline problem on the HEAD. So use Renormalizing a repo

     git rm --cached -r .
    git reset --hard
    git add .
    git commit -m "normalize line endings" 


    $ git filter-branch --tree-filter '~/Scripts/' -- --all

    The final commit shows the items not in the script, and you can fix and redo.

  2. dave says:

    Current Problems:
    a. We have two stupid commits at the end, one to redo the CRLFs, which we had to do, and one to remove the x file committed in error.
    b. There is a whole bunch of original commits in the repo which are the original versions of the commits. Note that all the SHAs have changed in your new tree. That is why you never do this to a repo that others have cloned and are working on.

    To remove the commits for a)

    1. Save the commit on a branch from gc (optional)

    $ git branch branch_to_save_this_commit_to

    2. Ditch that commit on this branch

    $ git reset --hard HEAD^

    3. Repeat for the number of additional commits. Two when you commit x.

    (Thanks to this article)

    To remove the junk commits.
    1. Remove all the tags and branches on this old commits.

    $ vi .git/info/refs
    $ vi .git/packed-refs

    remove the lines like refs/original/refs/*
    2. git gc
    3. They fall off of the tree.

  3. dave says:

    And don’t forget on the remote repo the configs git config core.sharedRepository "all" and git config receive.denyNonFastForwards true. Else you can pull but not push.

Leave a Reply