diff --git a/make-rhat-patches.sh b/make-rhat-patches.sh
index f392409..ce8365f 100755
--- a/make-rhat-patches.sh
+++ b/make-rhat-patches.sh
@@ -15,9 +15,9 @@ git clone git@github.com:fedora-selinux/selinux-policy.git -q
 git clone git@github.com:fedora-cloud/docker-selinux.git -q
 
 pushd selinux-policy > /dev/null
-# prepare policy patches against upstream
-git checkout ${FEDORA_VERSION}-base -q; git diff eb4512f6eb13792c76ff8d3e6f2df3a7155db577 ${FEDORA_VERSION}-base > policy-${FEDORA_VERSION}-base.patch
-git checkout ${FEDORA_VERSION}-contrib -q; git diff 64302b790bf2b39d93610e1452c8361d56966ae0 ${FEDORA_VERSION}-contrib > policy-${FEDORA_VERSION}-contrib.patch
+# prepare policy patches against upstream commits matching the last upstream merge
+git rev-parse --verify origin/${FEDORA_VERSION}-base; git diff eb4512f6eb13792c76ff8d3e6f2df3a7155db577 origin/${FEDORA_VERSION}-base > policy-${FEDORA_VERSION}-base.patch
+git rev-parse --verify origin/${FEDORA_VERSION}-contrib; git diff 64302b790bf2b39d93610e1452c8361d56966ae0 origin/${FEDORA_VERSION}-contrib > policy-${FEDORA_VERSION}-contrib.patch
 popd > /dev/null
 
 pushd docker-selinux > /dev/null