From 656c7cc70449a2116de4e3475bce21809ee4a3f1 Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Thu, 5 Mar 2026 12:01:09 +0100 Subject: [PATCH] sync-upstream: Clarify that we merge a *single* upstream ref Roughly speaking, this changes (assuming 3 upstream PRs) git merge into git merge This is more intuitive. We're merging a single upstream revision, namely . The other two commits are simply parents of that one, i.e., they're included anyway, and git merge ignores them. (In fact, passing multiple refs looks like we're doing an octopus merge. It's just that git recognizes the fact that everything is included in the last ref anyway, and behaves as if only the last one had been passed.) This commit also makes some further clean ups and improvements. --- contrib/sync-upstream.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/contrib/sync-upstream.sh b/contrib/sync-upstream.sh index a0495f60..1cb285bb 100755 --- a/contrib/sync-upstream.sh +++ b/contrib/sync-upstream.sh @@ -22,7 +22,7 @@ help() { echo echo "Listing upstream merge commits:" echo " To list merge commits in upstream/master that are missing from (oldest first):" - echo " git log --oneline --merges \$(git merge-base upstream/master )..upstream/master | tac" + echo " git log --oneline --topo-order --reverse --merges \$(git merge-base upstream/master )..upstream/master" echo " These are candidates for [end]." exit 1 } @@ -53,15 +53,7 @@ range() { if [ "$#" = 1 ]; then RANGEEND_COMMIT=$1 fi - - 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 + COMMITS=$(git --no-pager log --pretty=format:%H --topo-order --reverse --merges "$RANGESTART_COMMIT".."$RANGEEND_COMMIT") } # Process -b and -h arguments @@ -94,6 +86,7 @@ do PRNUM=$(git log -1 "$COMMIT" --pretty=format:%s | sed s/'Merge \(bitcoin-core\/secp256k1\)\?#\([0-9]*\).*'/'\2'/) 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]'/)") + LAST_COMMIT="$COMMIT" done # Remove trailing "," TITLE=${TITLE%?} @@ -109,6 +102,13 @@ Tips: EOF ) +echo "Merging $TITLE. Continue with y" +read -r yn +case $yn in + [Yy]* ) ;; + * ) exit 1;; +esac + echo "-----------------------------------" echo "$TITLE" echo "-----------------------------------" @@ -140,4 +140,4 @@ EOT chmod +x "$FNAME" 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"