Skip to content

Commit

Permalink
Add jane/pull-flambda-patches script
Browse files Browse the repository at this point in the history
  • Loading branch information
stedolan committed Nov 17, 2021
1 parent 7116602 commit efe80c9
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions jane/pull-flambda-patches
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

set -e
repo="$(git rev-parse --show-toplevel)"
cd "$repo"

if ! git diff --quiet; then
echo "Working directory must be clean before using this script,"
echo "but currently has the following changes:"
git diff --stat
exit 1
fi

configure_remote () {
name="$1"
url="$2"
set +e
curr="$(git remote get-url "$name" 2>/dev/null)"
err=$?
set -e
if [ $err = 2 ]; then
git remote add "$name" "$url"
elif [ "$curr" != "$url" ]; then
{
echo "Error: remote $name should point to $url, not $curr"
echo "Try 'git remote rm $name'."
} 1>&2
exit 1
fi
}

configure_remote origin 'git@github.com:janestreet/ocaml-jst'
configure_remote flambda-backend 'git@github.com:ocaml-flambda/flambda-backend'
configure_remote ocaml 'git@github.com:ocaml/ocaml'

git fetch -q origin
git fetch -q flambda-backend

git checkout -q flambda-backend/main
rev=$(git subtree split -P ocaml --annotate='flambda-backend: ' flambda-backend/main)
git push -q origin $rev:refs/heads/flambda-patches |& sed '/^remote: /d'
git checkout -q -

count=$(git rev-list HEAD..origin/flambda-patches | wc -l)
echo "$count new patches:"
git --no-pager log --oneline HEAD..origin/flambda-patches
git merge --no-ff -m 'Merge flambda-backend changes' origin/flambda-patches

0 comments on commit efe80c9

Please sign in to comment.