How to skip first N commits when converting svn repo to Git using reposurgeon?

132 Views Asked by At

How do I skip the first two commits of a subversion repository when converting it to Git using reposurgeon?

The first svn commit imported code using the wrong branch layout (trunk, tags, branches) and the second commit deleted all of it.

The third commit was an import to the correct branch layout (subdir/trunk, subdir/tags, subdir/branches).

This false start seems to confuse reposurgeon, because the resulting Git repository only has a single commit: the initial false start. All later commits are ignored.

Here's what I tried:

# installed reposurgeon 3.29
mkdir foo
cd foo
repotool initialize foo svn git
# edited the Makefile and set REMOTE_URL
make stubmap
# edited the resulting authors map (foo.map)
echo "1..2 delete" >>foo.lift
make
2

There are 2 best solutions below

0
On BEST ANSWER

Use the following to delete the first two svn commits:

<1>..<2> delete

This line means "select the commits from legacy ID 1 to legacy ID 2 (inclusive) and delete them". Alternatively, you can use this syntax:

<#1>..<#2> delete

This means "select the commits from the first commit to the second (inclusive) and delete them". This syntax works with non-svn input repositories. Be careful—commit #2 might not be a child of commit #1 (e.g., they might be two root commits from a Git repository).

The 1..2 selector means "select the events from the first to the second (inclusive) and delete them". Events are not the same as commits—events include blobs (files), tags, resets, etc. Because blob events must appear before the commits that refer to them, 1..2 is likely to select blobs, not commits.

2
On

Im not familiar with reposurgeon bot if you clone from the command line you can specify the number of commits you wish to clone + the name of the name of the branch which you wish to clone.

// Clona last X commits of branchA
git clone ... --depth=X --branch=branchA

Now you can add this repository to your reposurgeon server