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"