| 1 | = Creating a new library by refactoring existing Boost repositories = |
| 2 | [[PageOutline]] |
| 3 | |
| 4 | 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. |
| 5 | |
| 6 | Thanks to Peter for supplying this procedure! |
| 7 | |
| 8 | == Procedure == |
| 9 | |
| 10 | Since I already have created the new submodule from the existing components, I may as well document the procedure I used here... |
| 11 | |
| 12 | 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 |
| 13 | |
| 14 | [http://stackoverflow.com/questions/1365541/how-to-move-files-from-one-git-repo-to-another-not-a-clone-preserving-history?rq=1 How to move files from one git repo to another (not a clone), preserving history] on stackoverflow. |
| 15 | |
| 16 | Specifically - and step by step - what I did in the original repository (libs/utility) was: |
| 17 | |
| 18 | {{{ |
| 19 | git checkout master |
| 20 | 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 |
| 21 | |
| 22 | git checkout develop |
| 23 | 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 |
| 24 | }}} |
| 25 | |
| 26 | Then, in the new (empty) repository: |
| 27 | |
| 28 | {{{ |
| 29 | git checkout master |
| 30 | git am < ../utility/assert_master_patch.txt |
| 31 | |
| 32 | git checkout develop |
| 33 | git am < ../utility/assert_develop_patch.txt |
| 34 | |
| 35 | git checkout master |
| 36 | git merge --no-ff develop |
| 37 | |
| 38 | git checkout develop |
| 39 | git merge --no-ff master |
| 40 | }}} |
| 41 | |
| 42 | (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.) |
| 43 | |
| 44 | 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.) |
| 45 | |
| 46 | (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.) |