Changeset View
Standalone View
contrib/extract-secp256k1.sh
- This file was added.
Property | Old Value | New Value |
---|---|---|
File Mode | null | 100755 |
#!/usr/bin/env bash | |||||
export LC_ALL=C | |||||
jasonbcox: Rather than follow the linter's advice regarding pushd ... || exit, use something like `set… | |||||
pushd "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | |||||
Lint: ShellCheck found an issue: Use 'pushd ... || exit' or 'pushd ... || return' in case pushd fails. Lint: ShellCheck found an issue:: Use 'pushd ... || exit' or 'pushd ... || return' in case pushd fails. | |||||
REPO_DIR=$(git rev-parse --show-toplevel) | |||||
popd | |||||
Lint: ShellCheck found an issue: Use 'popd ... || exit' or 'popd ... || return' in case popd fails. Lint: ShellCheck found an issue:: Use 'popd ... || exit' or 'popd ... || return' in case popd fails. | |||||
git clone "file://${REPO_DIR}" workdir -b master | |||||
jasonbcoxUnsubmitted Not Done Inline Actionsuse mktemp -d rather than a hardcoded workdir. jasonbcox: use `mktemp -d` rather than a hardcoded workdir. | |||||
pushd workdir | |||||
Lint: ShellCheck found an issue: Use 'pushd ... || exit' or 'pushd ... || return' in case pushd fails. Lint: ShellCheck found an issue:: Use 'pushd ... || exit' or 'pushd ... || return' in case pushd fails. | |||||
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch \ | |||||
--index-filter 'git ls-files \ | |||||
Lint: ShellCheck found an issue: This backslash+linefeed is literal. Break outside single quotes if you just want to break the line. Lint: ShellCheck found an issue:: This backslash+linefeed is literal. Break outside single quotes if you just want to break the… | |||||
| grep -v ^src/secp256k1 \ | |||||
Lint: ShellCheck found an issue: This backslash+linefeed is literal. Break outside single quotes if you just want to break the line. Lint: ShellCheck found an issue:: This backslash+linefeed is literal. Break outside single quotes if you just want to break the… | |||||
| xargs git rm -q --cached; | |||||
git ls-files -s \ | |||||
Lint: ShellCheck found an issue: This backslash+linefeed is literal. Break outside single quotes if you just want to break the line. Lint: ShellCheck found an issue:: This backslash+linefeed is literal. Break outside single quotes if you just want to break the… | |||||
| sed "s%src/secp256k1/%%" \ | |||||
Lint: ShellCheck found an issue: This backslash+linefeed is literal. Break outside single quotes if you just want to break the line. Lint: ShellCheck found an issue:: This backslash+linefeed is literal. Break outside single quotes if you just want to break the… | |||||
| git update-index --index-info; | |||||
git rm -rq --cached --ignore-unmatch src/secp256k1' \ | |||||
--prune-empty -- --all | |||||
popd | |||||
Lint: ShellCheck found an issue: Use 'popd ... || exit' or 'popd ... || return' in case popd fails. Lint: ShellCheck found an issue:: Use 'popd ... || exit' or 'popd ... || return' in case popd fails. | |||||
# 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 | |||||
jasonbcoxUnsubmitted Not Done Inline ActionsCall this in an exit trap that is set right after the creation of the directory so that it cleans up if the script fails at any point. jasonbcox: Call this in an exit trap that is set right after the creation of the directory so that it… | |||||
pushd secp256k1 | |||||
Lint: ShellCheck found an issue: Use 'pushd ... || exit' or 'pushd ... || return' in case pushd fails. Lint: ShellCheck found an issue:: Use 'pushd ... || exit' or 'pushd ... || return' in case pushd fails. | |||||
git remote add github https://github.com/Bitcoin-ABC/secp256k1.git | |||||
git pull github master --rebase | |||||
git gc --prune=now | |||||
Rather than follow the linter's advice regarding pushd ... || exit, use something like set -euo pipefail instead. The set -eu is also good practice either way.