+# ---- Pushing dgit view to maintainer view
+
+if ! [ "x$last_debian_tag" = "x" ] && ! [ "x$last_archive_tag" = "x" ]; then
+ last_debian_tag_c=$(git rev-parse "$last_debian_tag"^{})
+ last_archive_tag_c=$(git rev-parse "$last_archive_tag"^{})
+ if ! [ "$last_debian_tag_c" = "$last_archive_tag_c" ] \
+ && git merge-base --is-ancestor \
+ "$last_debian_tag" "$last_archive_tag"; then
+ fail_check dgit-view \
+"looks like you might be trying to push the dgit view to the maintainer branch?"
+ fi
+fi
+
+# ---- Targeting different suite
+
+if ! [ "x$last_debian_tag" = "x" ]; then
+ temp=$(mktemp -d)
+ trap cleanup EXIT
+ mkdir "$temp/debian"
+ git cat-file blob "$last_debian_tag":debian/changelog >"$temp/debian/changelog"
+ prev_target=$(cd $temp; dpkg-parsechangelog -SDistribution)
+ rm -rf "$temp"
+ trap - EXIT
+
+ if ! [ "$prev_target" = "$target" ] && ! [ "$target" = "UNRELEASED" ]; then
+ fail_check suite \
+"last upload targeted $prev_target, now targeting $target; might be a mistake?"
+ fi
+fi
+
+# ---- Upstream tag is not ancestor of $branch
+
+if ! [ "x$upstream_tag" = "x" ] \
+ && ! git merge-base --is-ancestor "$upstream_tag" "$branch" \
+ && ! [ "$quilt_mode" = "baredebian" ]; then
+ fail_check upstream-nonancestor \
+ "upstream tag $upstream_tag is not an ancestor of $branch; probably a mistake"
+fi
+
+# ---- Upstream tag tree nonidentical
+
+case "$quilt_mode" in
+ gbp)
+ check_treesame "$upstream_tag" "$branch" ':!debian' ':!**.gitignore' \
+ || fail_check_upstream_nonidentical
+ ;;
+ unapplied)
+ check_treesame "$upstream_tag" "$branch" ':!debian' \
+ || fail_check_upstream_nonidentical
+ ;;
+esac
+
+# ---- Summary
+
+if $failed_check; then
+ # We don't mention the --force=check options here as those are
+ # mainly for use by scripts, or when you already know what check
+ # is going to fail before you invoke git-debpush. Keep the
+ # script's terminal output as simple as possible. No "see the
+ # manpage"!
+ fail "some check(s) failed; you can pass --force to ignore them"
+fi
+
+# **** Create the git tag ****
+