User:Joelholdsworth/split-sigrok-repo.sh
Overview
split-sigrok-repo.sh
is a simple bash script to do the upcoming repository splitting task. I'm very keen that we filter the project history, so that we can retain the history of each subproject, but only show the work that was done on that submodule.
split-sigrok-repo.sh
#!/bin/bash SRCDIR=sigrok DSTDIR=split mkdir -p $DSTDIR for i in $SRCDIR/*/; do SUBDIR=$(basename $i) DSTREPO=$DSTDIR/$SUBDIR git clone $SRCDIR $DSTREPO ( cd $DSTREPO # Remove the origin to prohibit pushing back there git remote rm origin # Do the filter git filter-branch --tag-name-filter cat \ --prune-empty --subdirectory-filter $SUBDIR -- --all # Do aggressive garbage collection git reset --hard git for-each-ref --format="%(refname)" refs/original/ | \ xargs -n 1 git update-ref -d git reflog expire --expire=now --all git gc --aggressive --prune=now ) done echo echo --------------- DONE --------------- du -sh $DSTDIR/*
Porting Work in Progress to Split Repositories
For those working on branches from the currently combined repository, the procedure for rebasing over the split repository is fairly straightforward. This is my (untested) procedure:
- Look at your repo - which subprojects have you been working on in your branches touch? libsigrok, libsigrokdecode etc. ?
- Make a copy of your local sigrok repo for each subproject e.g. repo-libsigrok, repo-libsigrokdecode etc.
- For each repository do the following:
- Filter the *all* commits to the subproject
git filter-branch --tag-name-filter cat --prune-empty --subdirectory-filter $SUBDIR -- --all
. Where SUBDIR= the subproject: libsigrok, libsigrokdecode etc. - Add the new origin for the new subrepo remote
git remote add -mf git://sigrok.git.sourceforge.net/gitroot/sigrok/sigrok
. - You can now rebase your branches on origin head.
- If you want to for garbage collection to clear space, you can follow the garbage collection instructions from
split-sigrok-repo.sh
.
- Filter the *all* commits to the subproject
Note that in filtering origin/master for the subproject, the commits you generate should exactly match those generated in splitting the master repo. Therefore, the IDs of you master commits will exactly match the IDs of the origin repository's commits. Therefore, I don't believe that rebasing will actually be necessary, because your branches will already be based on origin.