Merge BlockstreamResearch/secp256k1-zkp#341: sync-upstream: Overhaul
656c7cc704sync-upstream: Clarify that we merge a *single* upstream ref (Tim Ruffing)349a94b169sync-upstream: Remove "select" mode and simplify (Tim Ruffing) Pull request description: Please see individual commit messages for details. --- Here's an example session that shows why `select` doesn't make sense: ``` ### Let's find some PRs to sync (master is at5a67b63) ❯ ./contrib/sync-upstream.sh -b master range Mergingb9cb1cbf1aafe151. Continue with y n ### Let's look at them in the order they have been merged ❯ git showb9cb1cbfcommitb9cb1cbfd7Merge:c0a2aba0921b9711Author: merge-script <me@real-or-random.org> Date: Tue Mar 3 15:31:46 2026 +0100 Merge bitcoin-core/secp256k1#1824: util: introduce and use `ARRAY_SIZE` macro [...] ❯ git --no-pager show1aafe151commit1aafe15139(upstream/master, upstream/HEAD) Merge:b9cb1cbf4d92a083Author: merge-script <me@real-or-random.org> Date: Wed Mar 4 08:43:07 2026 +0100 Merge bitcoin-core/secp256k1#1777: Make SHA256 compression runtime pluggable [...] ### Let's assume I want to cherry-pick1aafe151but not sync b9cb1bcf ❯ ./contrib/sync-upstream.sh -b master select1aafe151----------------------------------- Upstream PRs 1777 ----------------------------------- [bitcoin-core/secp256k1#1777]: Make SHA256 compression runtime pluggable This PR can be recreated with `./contrib/sync-upstream.sh -b master select 1aafe151`. [...] ### Let's check if it's really only PR #1777 ❯ git diff | grep ARRAY_SIZE + #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) ### Ah damn, we also got the other PR #1824... ``` ACKs for top commit: mllwchrry: ACK656c7ccjonasnick: ACK656c7cc704Tree-SHA512: 27cdfe7c6decce840ef4f2d12fa0a5fd829b35ac24403272c4b34c0a3b0da2303cee36bcb419d0608c6b1297fd5bf8a6cd6d41672850ac092814c140638f9d83
This commit is contained in:
@@ -6,14 +6,11 @@ help() {
|
|||||||
echo "Sync merge commits from bitcoin-core/secp256k1 into secp256k1-zkp."
|
echo "Sync merge commits from bitcoin-core/secp256k1 into secp256k1-zkp."
|
||||||
echo
|
echo
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo " $0 [-b <branch>] range [end]"
|
echo " $0 [-b <branch>] [end]"
|
||||||
echo " Merges every merge commit present in upstream/master and missing in <branch>"
|
echo " Merges every merge commit present in upstream/master and missing in <branch>"
|
||||||
echo " (default: master). If the optional [end] commit is provided, only merges"
|
echo " (default: master). If the optional [end] commit is provided, only merges"
|
||||||
echo " up to and including [end]."
|
echo " up to and including [end]."
|
||||||
echo
|
echo
|
||||||
echo " $0 [-b <branch>] select <commit> ... <commit>"
|
|
||||||
echo " Merges every selected merge commit into <branch> (default: master)."
|
|
||||||
echo
|
|
||||||
echo "This tool creates a temporary branch and attempts to merge the upstream commits."
|
echo "This tool creates a temporary branch and attempts to merge the upstream commits."
|
||||||
echo "If there are merge conflicts, resolve them and run tests, then use the generated"
|
echo "If there are merge conflicts, resolve them and run tests, then use the generated"
|
||||||
echo "script contrib/gh-pr-create.sh to create the PR (requires the gh tool)."
|
echo "script contrib/gh-pr-create.sh to create the PR (requires the gh tool)."
|
||||||
@@ -25,8 +22,8 @@ help() {
|
|||||||
echo
|
echo
|
||||||
echo "Listing upstream merge commits:"
|
echo "Listing upstream merge commits:"
|
||||||
echo " To list merge commits in upstream/master that are missing from <branch> (oldest first):"
|
echo " To list merge commits in upstream/master that are missing from <branch> (oldest first):"
|
||||||
echo " git log --oneline --merges \$(git merge-base upstream/master <branch>)..upstream/master | tac"
|
echo " git log --oneline --topo-order --reverse --merges \$(git merge-base upstream/master <branch>)..upstream/master"
|
||||||
echo " Use these for [end] in 'range' or as arguments to 'select'."
|
echo " These are candidates for [end]."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,25 +53,21 @@ range() {
|
|||||||
if [ "$#" = 1 ]; then
|
if [ "$#" = 1 ]; then
|
||||||
RANGEEND_COMMIT=$1
|
RANGEEND_COMMIT=$1
|
||||||
fi
|
fi
|
||||||
|
COMMITS=$(git --no-pager log --pretty=format:%H --topo-order --reverse --merges "$RANGESTART_COMMIT".."$RANGEEND_COMMIT")
|
||||||
COMMITS=$(git --no-pager log --oneline --merges "$RANGESTART_COMMIT".."$RANGEEND_COMMIT")
|
|
||||||
COMMITS=$(echo "$COMMITS" | tac | awk '{ print $1 }' ORS=' ')
|
|
||||||
echo "Merging $COMMITS. Continue with y"
|
|
||||||
read -r yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) ;;
|
|
||||||
* ) exit 1;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Process -b <branch> argument
|
# Process -b <branch> and -h arguments
|
||||||
while getopts "b:" opt; do
|
while getopts "b:h" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
b)
|
b)
|
||||||
LOCAL_BRANCH=$OPTARG
|
LOCAL_BRANCH=$OPTARG
|
||||||
;;
|
;;
|
||||||
\?)
|
h)
|
||||||
echo "Invalid option: -$OPTARG" >&2
|
help
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo
|
||||||
|
help
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -82,37 +75,18 @@ done
|
|||||||
# Shift off the processed options
|
# Shift off the processed options
|
||||||
shift $((OPTIND -1))
|
shift $((OPTIND -1))
|
||||||
|
|
||||||
if [ "$#" -lt 1 ]; then
|
setup
|
||||||
help
|
range "$@"
|
||||||
fi
|
|
||||||
|
|
||||||
case $1 in
|
|
||||||
range)
|
|
||||||
shift
|
|
||||||
setup
|
|
||||||
range "$@"
|
|
||||||
REPRODUCE_COMMAND="$0 -b $LOCAL_BRANCH range $RANGEEND_COMMIT"
|
|
||||||
;;
|
|
||||||
select)
|
|
||||||
shift
|
|
||||||
setup
|
|
||||||
COMMITS=$*
|
|
||||||
REPRODUCE_COMMAND="$0 -b $LOCAL_BRANCH select $@"
|
|
||||||
;;
|
|
||||||
help)
|
|
||||||
help
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
help
|
|
||||||
esac
|
|
||||||
|
|
||||||
TITLE="Upstream PRs"
|
TITLE="Upstream PRs"
|
||||||
|
REPRODUCE_COMMAND="$0 -b $LOCAL_BRANCH $RANGEEND_COMMIT"
|
||||||
BODY=""
|
BODY=""
|
||||||
for COMMIT in $COMMITS
|
for COMMIT in $COMMITS
|
||||||
do
|
do
|
||||||
PRNUM=$(git log -1 "$COMMIT" --pretty=format:%s | sed s/'Merge \(bitcoin-core\/secp256k1\)\?#\([0-9]*\).*'/'\2'/)
|
PRNUM=$(git log -1 "$COMMIT" --pretty=format:%s | sed s/'Merge \(bitcoin-core\/secp256k1\)\?#\([0-9]*\).*'/'\2'/)
|
||||||
TITLE="$TITLE $PRNUM,"
|
TITLE="$TITLE $PRNUM,"
|
||||||
BODY=$(printf "%s\n%s" "$BODY" "$(git log -1 "$COMMIT" --pretty=format:%s | sed s/'Merge \(bitcoin-core\/secp256k1\)\?#\([0-9]*\)'/'[bitcoin-core\/secp256k1#\2]'/)")
|
BODY=$(printf "%s\n%s" "$BODY" "$(git log -1 "$COMMIT" --pretty=format:%s | sed s/'Merge \(bitcoin-core\/secp256k1\)\?#\([0-9]*\)'/'[bitcoin-core\/secp256k1#\2]'/)")
|
||||||
|
LAST_COMMIT="$COMMIT"
|
||||||
done
|
done
|
||||||
# Remove trailing ","
|
# Remove trailing ","
|
||||||
TITLE=${TITLE%?}
|
TITLE=${TITLE%?}
|
||||||
@@ -128,6 +102,13 @@ Tips:
|
|||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
|
echo "Merging $TITLE. Continue with y"
|
||||||
|
read -r yn
|
||||||
|
case $yn in
|
||||||
|
[Yy]* ) ;;
|
||||||
|
* ) exit 1;;
|
||||||
|
esac
|
||||||
|
|
||||||
echo "-----------------------------------"
|
echo "-----------------------------------"
|
||||||
echo "$TITLE"
|
echo "$TITLE"
|
||||||
echo "-----------------------------------"
|
echo "-----------------------------------"
|
||||||
@@ -159,4 +140,4 @@ EOT
|
|||||||
chmod +x "$FNAME"
|
chmod +x "$FNAME"
|
||||||
echo Run "$FNAME" after solving the merge conflicts
|
echo Run "$FNAME" after solving the merge conflicts
|
||||||
|
|
||||||
git merge --no-edit -m "Merge commits '$COMMITS' into temp-merge-$PRNUM" $COMMITS
|
git merge --no-edit -m "Merge upstream '${LAST_COMMIT:0:7}' into temp-merge-$PRNUM" "$LAST_COMMIT"
|
||||||
|
|||||||
Reference in New Issue
Block a user