GIT Filter
Using git filters to extract or separate FreeBSD components into their own git repos.
This is still a work in progress. Two examples will be provided.
git-filter-repo
git-filter-repo is a handy port that will rewrite git history, including separating FreeBSD components from the tree. Following is how I separated telnet (telnetd, libtelnet, and telnet) into its own repo.
- git clone a fresh copy of src.
- git filter-repo --path contrib/telnet --path lib/libtelnet --path libexec/telnetd --path usr.bin/telnet
- git reflog expire --all --expire-unreachable=0
- git repack -A -d
- git prune
This resulted in a 1 MB git repo containing only telnet.
git-filter-repo is recommended by the authors of git. git-filter-branch displays a message suggesting that git-filter-repo be used.
git-filter-branch
As efficient as git-filter-repo is, I discovered it deleted files that should not have been deleted when extracting ftpd into its own repo. The other tool at our disposal is git-filter-branch, which is already packaged with git. Though git warns about git-filter-branch caveats and the possibility of repo corruption, it was the only solution to separate ftpd into its own repo. The steps I used are:
- git clone a fresh copy of src.
- git filter-branch --subdirectory-filter libexec/ftpd
- git filter-branch --tag-name-filter cat --index-filter 'git rm -r --cached --ignore-unmatch filename' --prune-empty -f -- --all
- rm -r .git/refs/original
- git reflog expire --expire=now --all
- git gc --prune=now
- git gc --aggressive
This resulted in a 448KB git repo only containing ftpd.
Hopefully this will be of use to someone. I will expound on the above at a later date as time permits.