Creating a new library by refactoring existing Boost repositories
This page documents the procedure Peter Dimov used to refactor Boost's assert facilities out of Boost.Utility into a separate Boost.Assert library. This was done to reduce dependencies.
Thanks to Peter for supplying this procedure!
Procedure
Since I already have created the new submodule from the existing components, I may as well document the procedure I used here...
The usual way to extract a portion of a Git repository, along with its history, is by using "git filter-branch". filter-branch, however, is reasonably easy to apply if what one needs to extract is contained in a subdirectory, which was not the case with Assert, where one needs to extract individual files. So I used "git log" instead to prepare a patch, as suggested in
How to move files from one git repo to another (not a clone), preserving history on stackoverflow.
Specifically - and step by step - what I did in the original repository (libs/utility) was:
git checkout master git log --pretty=email --patch-with-stat --reverse -- assert.html assert_test.cpp current_function.html current_function_test.cpp verify_test.cpp include/boost/assert.hpp include/boost/current_function.hpp > assert_master_patch.txt git checkout develop git log --pretty=email --patch-with-stat --reverse -- assert.html assert_test.cpp current_function.html current_function_test.cpp verify_test.cpp include/boost/assert.hpp include/boost/current_function.hpp > assert_develop_patch.txt
Then, in the new (empty) repository:
git checkout master git am < ../utility/assert_master_patch.txt git checkout develop git am < ../utility/assert_develop_patch.txt git checkout master git merge --no-ff develop git checkout develop git merge --no-ff master
(For the merges, I take advantage of the fact that the files are identical in master
and develop
because I've ensured so while preparing the initial Boost.Utility merge point. For a repository in which master
and develop
have diverged and need to stay diverged in the new repository, the final two merges may need to be replaced by something else.)
I then added test/Jamfile.v2 as a new file, as I decided that most of the history of the original Boost.Utility would not be relevant. (I could, alternatively, have imported it along with the other files and then deleted the references to everything but Assert as required.)
(I prepared the initial empty repository by creating one via Github, cloning it, removing the README.md file, git push-ing the changes, then creating a "develop" branch via Github. There are other ways to do it. This one seemed easiest.)