All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Seth W. Klein" <sk@sethwklein.net>
To: Art Haas <ahaas@airmail.net>
Cc: git@vger.kernel.org
Subject: Re: Converting SVN repository to git
Date: Fri, 17 Jun 2005 23:26:48 -0400	[thread overview]
Message-ID: <20050618032648.GA23034@bubook.sethwklein.net> (raw)
In-Reply-To: <20050615184720.GF31997@artsapartment.org>

On Wed, Jun 15, 2005 at 01:47:20PM -0500, Art Haas wrote:
> 
> [....] I've not seen anything, though,
> on switching Subversion repositories to git. Has there been any public
> activity in writing a tool/script to do this? Perhaps some offline
> discussion about doing this?

The following script is what I used to convert a simple svn repository.
It doesn't handle branches or tags and contains buggy use of grep and
inscrutable uncommented use of sed but it should be a starting place for
someone with a more complex repository available for testing.

export GIT_AUTHOR_EMAIL=sk@sethwklein.net
export GIT_COMMITTER_EMAIL=sk@sethwklein.net
svn co -r 1 file:///home/sk/rep/oakheart/trunk oakheart
cd oakheart
git-init-db
for REV in `seq 2 692`; do
    echo -n $REV' '
    svn update -r $REV > .svnupdate
    sed -nr 's/^A +//p' .svnupdate \
    | while read F; do [ -f "$F" ] && echo "$F"; done \
    | xargs -r git-update-cache --add --
    sed -nr 's/^D +//p' .svnupdate \ 
    | while read F; do git-ls-files | grep "^$F"'\(/\|$\)'; done \
    | xargs -r git-update-cache --remove --
    sed -nr 's/^U +//p' .svnupdate \
    | while read F; do [ -f "$F" ] && echo "$F"; done \
    | xargs -r git-update-cache --
    PARENT=
    [ -f .git/HEAD ] &&
        PARENT='-p '`cat .git/HEAD`
    svn log -r $REV | sed -n '1,3d;$d;H;/^$/!{s/.*//;x;s/\n//;p}' \
    | git-commit-tree `git-write-tree` $PARENT > .git/HEAD
done

Cheers,
Seth W. Klein
-- 
sk@sethwklein.net     AIM: sethwklein     http://www.sethwklein.net/

      parent reply	other threads:[~2005-06-18  3:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-15 18:47 Converting SVN repository to git Art Haas
2005-06-15 22:02 ` Adam Mercer
2005-06-18  3:26 ` Seth W. Klein [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050618032648.GA23034@bubook.sethwklein.net \
    --to=sk@sethwklein.net \
    --cc=ahaas@airmail.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.