As part our rebase-heavy workflow, I am hoping to use a merge on the master branch. In particular I want to merge only when the topic branch has been rebased onto the most r
You don't want --ff-only because you do want to make a merge commit which --ff-only would inhibit.
The check that you want can be made as a separate check before running the merge command. You could package this into a simple shell function.
E.g.
merge_if_ahead () {
if test "$(git merge-base HEAD "$1")" = "$(git rev-parse HEAD)"; then
git merge --no-ff "$1"
else
echo >&2 "Not up to date; refusing to merge"
return 1
fi
}