Over the last weekend this repo inspired me to write FaTul - a way to store blueprints with minimal changes between revisions, and being able to easily inspect them. I ran my tool on the whole history of this repo, resulting in https://github.com/nyurik/brians-blueprints/tree/rebase -- a branch with the significantly smaller history and easy to diff each revision.
I ran git log --shortstat "--pretty=format:%ad | %s [%an]\n%h" --date=short --reverse to see the difference between the old and the new (even this command took 5s on the new branch, and 20s on the old one):
To test how this repo would look if stored using fatul, I wrote a simple script to convert it. To try this rebasing yourself:
make sure your repo is clean, and up to date with github. You may want to create another clone dir to be certain.
create a new branch git checkout -b fatul fead642 (this will only have the initial files without any data)
copy fatul.py, encode, decode, and dump files to the /tools dir and commit it with git commit -a -m "adding fatul tools"
create a new branch off of the main branch for the rebase, e.g. git checkout -b rebase main
place this script (inside the details section below) one level above the brians-blueprints git repo, e.g. as ../recode.sh and make it executable chmod +x ../recode.sh
run automatic rebase with git rebase fatul --exec ../recode.sh (will take 10-15 min)
Make sure you have filter-repo installed -- this is a massively popular tool for complex git changes.
Delete all of the old data, keeping various top level files and the tools/ dir: git filter-repo --path-glob '*.md' --path LICENSE --path .gitignore --path tools/
Move all dirs from tools/results to root dir, and keep all top level files and the tools/ dir: git filter-repo --path-glob '*.md' --path LICENSE --path .gitignore --path tools/ --subdirectory-filter=tools/results/
At this point I had some issues with the repo possibly due to messing up the filter-repo tool, so I created another clone, fetched the data from the first one, created another branch rebase2 set to the initial commit git reset --hard fa54 and used git cherry-pick <revision_of_the_fatul_addition>^..rebase to apply all changes from the original rebase branch.
The rebase branch now has all the same data as the main, except it is stored in fatul format, and without any giant data blobs in history.
```bash
#!/usr/bin/env bash
set -e -o pipefail
fatul=tools/fatul.py
fbp=tools/fbp.py
output=tools/results
tmp_file=../tmp.txt
tmp_output1=../output1.txt
tmp_err1=../err1.txt
tmp_output2=../output2.txt
tmp_err2=../err2.txt
rm -rf "${output}"
for d in *; do
if [ -d "$d" ] && [ "$d" != "tools" ]; then
dir="$(basename "$d")"
mkdir -p "$output/$dir"
if [ -f "$d/.metadata" ]; then
echo "Processing dir $d ($dir)"
rm -rf "$tmp_file"
python3 "$fbp" build --outfile="$tmp_file" --indir "$d" > "$tmp_output1" 2> "$tmp_err1"
python3 "$fatul" decode "$output/$dir" "$tmp_file" > "$tmp_output2" 2> "$tmp_err2"
else
echo "processing files in $d"
for d2 in "$d/"*; do
if [ -d "$d2" ]; then
echo "It's a dir! $d2"
exet 1
fi
filename="$(basename "$d2")"
echo "processing file $d2 ($filename)"
rm -rf "$tmp_file"
python3 "$fbp" pack --outfile="$tmp_file" --infile "$d2" > "$tmp_output1" 2> "$tmp_err1"
python3 "$fatul" decode "$output/$dir/$filename" "$tmp_file" > "$tmp_output2" 2> "$tmp_err2"
done
fi
fi
done
git add .
git commit -C HEAD --amend
```
Over the last weekend this repo inspired me to write FaTul - a way to store blueprints with minimal changes between revisions, and being able to easily inspect them. I ran my tool on the whole history of this repo, resulting in https://github.com/nyurik/brians-blueprints/tree/rebase -- a branch with the significantly smaller history and easy to diff each revision.
I ran
git log --shortstat "--pretty=format:%ad | %s [%an]\n%h" --date=short --reverse
to see the difference between the old and the new (even this command took 5s on the new branch, and 20s on the old one):How I got it
To test how this repo would look if stored using fatul, I wrote a simple script to convert it. To try this rebasing yourself:
git checkout -b fatul fead642
(this will only have the initial files without any data)/tools
dir and commit it withgit commit -a -m "adding fatul tools"
git checkout -b rebase main
brians-blueprints
git repo, e.g. as../recode.sh
and make it executablechmod +x ../recode.sh
git rebase fatul --exec ../recode.sh
(will take 10-15 min)git filter-repo --path-glob '*.md' --path LICENSE --path .gitignore --path tools/
git filter-repo --path-glob '*.md' --path LICENSE --path .gitignore --path tools/ --subdirectory-filter=tools/results/
rebase2
set to the initial commitgit reset --hard fa54
and usedgit cherry-pick <revision_of_the_fatul_addition>^..rebase
to apply all changes from the original rebase branch.The rebase branch now has all the same data as the main, except it is stored in fatul format, and without any giant data blobs in history.