sync-upstream: Remove "select" mode and simplify
I believe it was introduced to cherry-pick upstream PRs, but that simply doesn't work. Assume upstream is two PRs A and B ahead, and A has been merged before B. Then trying to cherry-picking B by merging the state of upstream's master after the merge-B commit won't do what we expect. In particular, the merge result will *include A's changes* because A had already been merged in upstream's master when B was merged. (One could think that merging the PR branch of B instead works, but this will yield the same result if B was rebased on master before it was merged.) The proper way to cherry-pick B is to create a PR that cherry-picks all commits that had been included in B. This could be done automatically, but the need to cherry-pick a PR is rare enough that we don't need tool support for it. In fact, because we want to keep cherry-picking at a minimum, there's a good chance that we'd anyway want to pick only a subset of the commits in a upstream PR, and that would need manual work anyway.
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)."
|
||||||
@@ -26,7 +23,7 @@ help() {
|
|||||||
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 --merges \$(git merge-base upstream/master <branch>)..upstream/master | tac"
|
||||||
echo " Use these for [end] in 'range' or as arguments to 'select'."
|
echo " These are candidates for [end]."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,14 +64,18 @@ range() {
|
|||||||
esac
|
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,31 +83,11 @@ 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
|
||||||
|
|||||||
Reference in New Issue
Block a user