#!/usr/bin/env bash
set -x -e

source ./functions.sh

cd ..
rm -rf sqliteX-tests
mkdir sqliteX-tests

if [ -d sqlite ]
then
	cd sqlite
	git pull -a
	cd ..
else
	git clone https://github.com/sqlite/sqlite.git
fi

cp -Rp sqlite sqliteX-tests/sqliteX-data
cd sqliteX-tests/sqliteX-data

pijul init .
for G in $(git log  --pretty=format:%h --reverse); do
	git checkout -q "$G"
	add
	record
done

rm -rf .git
cd ..
pijul clone sqliteX-data sqliteX-data2
eq 1 "$(diff -qr sqliteX-data/ sqliteX-data2/ | wc -l)"

cd ..
rm -rf sqliteX-tests
echo "All OK."