diff --git a/contrib/extract-secp256k1.sh b/contrib/extract-secp256k1.sh new file mode 100755 --- /dev/null +++ b/contrib/extract-secp256k1.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +export LC_ALL=C + +pushd "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +REPO_DIR=$(git rev-parse --show-toplevel) +popd + +git clone "file://${REPO_DIR}" workdir -b master + +pushd workdir +FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch \ + --index-filter 'git ls-files \ + | grep -v ^src/secp256k1 \ + | xargs git rm -q --cached; + git ls-files -s \ + | sed "s%src/secp256k1/%%" \ + | git update-index --index-info; + git rm -rq --cached --ignore-unmatch src/secp256k1' \ + --prune-empty -- --all +popd + +# filter-branch is full of gotcha and can leave the repo is a strange state, +# so we make a fresh new one. +git clone "file://$(pwd)/workdir" secp256k1 +rm -rf workdir + +pushd secp256k1 +git remote add github https://github.com/Bitcoin-ABC/secp256k1.git +git pull github master --rebase +git gc --prune=now +