diff --git a/contrib/sync-upstream.sh b/contrib/sync-upstream.sh index 451456c9..e4815041 100755 --- a/contrib/sync-upstream.sh +++ b/contrib/sync-upstream.sh @@ -7,7 +7,7 @@ cat < + $0 [--switch] This script creates a sync local branch pointing to . Moreover, it generates a helper script for opening a pull request (PR) merging the created @@ -18,13 +18,13 @@ The synced upstream PRs are listed in the title and the description of the PR. "Merge #: ...".) Arguments: + --switch: Try to switch to the created sync branch : The branch to sync with upstream : The upstream ref to merge into Usage examples: - $0 master upstream/master + $0 --switch master upstream/master $0 master abc1234 - $0 --switch origin/master upstream/master To find candidate merge commits from (oldest first), use: git log --oneline --topo-order --reverse --merges \$(git merge-base ).. @@ -32,6 +32,11 @@ EOT } ### Parse arguments +SWITCH=false +if [ "$#" -ge 1 ] && [ "$1" = "--switch" ]; then + SWITCH=true + shift +fi if [ "$#" -ne 2 ]; then help exit 1 @@ -109,3 +114,10 @@ echo "You can now:" echo " 1. Optionally resolve merge conflicts by merging $BASE_BRANCH into $SYNC_BRANCH." echo " 2. Push $SYNC_BRANCH to some GitHub remote." echo " 3. Run ./$FNAME to create a pull request. (Tip: Pass --dry-run first.)" + +if [ "${SWITCH:-false}" = true ]; then + echo + echo "Trying to switch to the sync branch..." + echo + git switch "$SYNC_BRANCH" +fi