Git Conversion Lazarus
This page has the detailed steps used to convert the Lazarus SVN repro to git.
SubGIT
The initial conversion will be done using TMate Subgit.
Install
Unpack subgit to
~/subgit/subgit-3.3.11
Required
An author.txt file
svn-name - git-name <email>
Run / main repro
cd ~/subgit/subgit-3.3.11 ./bin/subgit configure https://svn.freepascal.org/svn/lazarus laz.git gedit laz.git/subgit/config
And add the following (the first line, replaces an existing setting)
[svn] trunk = trunk:refs/heads/main gitCommitMessage = %message\\n\\n SVN %revision@%branch\\n [translate] eols = false otherProperties = false ignores = false
The translate options prevent .gitignore and .gitattributes. Those can be translated, but will later be replaced...
cp authors.txt laz.git/subgit/authors.txt
./bin/subgit install laz.git
Without skipping the gitignore/gitattributes, there will be an error at revision 47330. The process will hang. nterrupt it and editI
lazarus.git/svn/.metadata
and set branches-maxRev and tags-maxRev to 47332 (it should be at 47330) https://stackoverflow.com/questions/18918215/skip-revisions-when-installing-subgit-repository Continue with
./bin/subgit install laz-bin.git
Stop the daemon
./bin/subgit shutdown laz-bin.git/
Run / binaries repro
./bin/subgit configure https://svn.freepascal.org/svn/lazarus laz-bin.git
gedit laz.git/subgit/config [svn] gitCommitMessage = %message\\n\\n SVN %revision@%branch\\n trunk = binaries:refs/heads/main
cp authors.txt laz-bin.git/subgit/authors.txt
follow the steps above
Part 2
- Updating gitignore
- Prefixing all issue references with #
- translating svn revisions to git hashes
Clean out left overs from subgit
git for-each-ref --format="%(refname)" refs/svn/ | xargs -n 1 git update-ref -d
Updating gitignore/gitattributes / Prefix issues with #
The below combines the 2 steps. It can be run in 2 separate calls.
It will run for about one hour.
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --index-filter ' cp ~/subgit/subgit-3.3.11/.gitignore ~/subgit/subgit-3.3.11/.gitattributes . ; git add .gitignore .gitattributes ' --msg-filter ' perl -ne "while (s/((?:iss?ues?|[ (](?:bugs?|mantis|fix|fixes|patch)\b)(?: +id)?[ :]+(?:#?0*[1-9][0-9]{2,4}(?: *(?:[ ,]| and ) *))*)(0*[1-9][0-9]{2,4})\b/\1#\2/i) {}; print" ' -f -- --all
Cleanup
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d git reflog expire --expire=now --all ;git gc --prune=now
Comparing data before/after filter-branch
With subject line / Will show changes in subject
git log --pretty='format:%ae %an %cd %s %d' --graph --all > ../log.txt
Without subject line / Should have no diff
git log --pretty='format:%ae %an %cd %d' --graph --all > ../log.txt